2013-08-21 16:25:27 +02:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
// Utils includes
|
|
|
|
#include <utils/RgbImage.h>
|
|
|
|
|
2013-08-23 07:08:44 +02:00
|
|
|
namespace hyperion
|
2013-08-21 16:25:27 +02:00
|
|
|
{
|
2013-08-21 16:52:03 +02:00
|
|
|
///
|
2013-08-23 07:08:44 +02:00
|
|
|
/// Result structure of the detected blackborder.
|
2013-08-21 16:52:03 +02:00
|
|
|
///
|
2013-08-23 07:08:44 +02:00
|
|
|
struct BlackBorder
|
2013-08-21 16:25:27 +02:00
|
|
|
{
|
2013-08-23 07:08:44 +02:00
|
|
|
///
|
|
|
|
/// Enumeration of the possible types of detected borders
|
|
|
|
///
|
|
|
|
enum Type
|
|
|
|
{
|
|
|
|
none,
|
|
|
|
horizontal,
|
|
|
|
vertical,
|
|
|
|
unknown
|
|
|
|
};
|
2013-08-21 16:25:27 +02:00
|
|
|
|
2013-08-23 07:08:44 +02:00
|
|
|
/// The type of detected border
|
|
|
|
Type type;
|
2013-08-21 16:25:27 +02:00
|
|
|
|
2013-08-23 07:08:44 +02:00
|
|
|
/// The size of detected border (negative if not applicable)
|
|
|
|
int size;
|
|
|
|
};
|
2013-08-21 16:25:27 +02:00
|
|
|
|
2013-08-21 16:52:03 +02:00
|
|
|
///
|
2013-08-23 07:08:44 +02:00
|
|
|
/// The BlackBorderDetector performs detection of black-borders on a single image.
|
|
|
|
/// The detector will scan the border of the upper-left quadrant of an image. Based on detected
|
|
|
|
/// black pixels it will give an estimate of the black-border.
|
2013-08-21 16:52:03 +02:00
|
|
|
///
|
2013-08-23 07:08:44 +02:00
|
|
|
class BlackBorderDetector
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
/// Constructs a black-border detector
|
|
|
|
///
|
|
|
|
BlackBorderDetector();
|
2013-08-21 16:25:27 +02:00
|
|
|
|
2013-08-23 07:08:44 +02:00
|
|
|
///
|
|
|
|
/// Performs the actual black-border detection on the given image
|
|
|
|
///
|
|
|
|
/// @param[in] image The image on which detection is performed
|
|
|
|
///
|
|
|
|
/// @return The detected (or not detected) black border info
|
|
|
|
///
|
|
|
|
BlackBorder process(const RgbImage& image);
|
2013-08-21 16:25:27 +02:00
|
|
|
|
2013-08-23 07:08:44 +02:00
|
|
|
private:
|
2013-08-21 16:25:27 +02:00
|
|
|
|
2013-08-23 07:08:44 +02:00
|
|
|
///
|
|
|
|
/// Checks if a given color is considered black and therefor could be part of the border.
|
|
|
|
///
|
|
|
|
/// @param[in] color The color to check
|
|
|
|
///
|
|
|
|
/// @return True if the color is considered black else false
|
|
|
|
///
|
|
|
|
inline bool isBlack(const RgbColor& color)
|
|
|
|
{
|
|
|
|
// Return the simple compare of the color against black
|
|
|
|
return RgbColor::BLACK == color;
|
|
|
|
// TODO[TvdZ]: We could add a threshold to check that the color is close to black
|
|
|
|
}
|
|
|
|
};
|
|
|
|
} // end namespace hyperion
|