5 #include <utils/Image.h> 63 uint8_t calculateThreshold(
double blackborderThreshold);
67 template <
typename Pixel_T>
73 int width = image.
width();
74 int height = image.
height();
75 int width33percent = width / 3;
76 int height33percent = height / 3;
77 int width66percent = width33percent * 2;
78 int height66percent = height33percent * 2;
79 int xCenter = width / 2;
80 int yCenter = height / 2;
83 int firstNonBlackXPixelIndex = -1;
84 int firstNonBlackYPixelIndex = -1;
90 for (
int x = 0; x < width33percent; ++x)
92 if (!isBlack(image((width - x), yCenter))
93 || !isBlack(image(x, height33percent))
94 || !isBlack(image(x, height66percent)))
96 firstNonBlackXPixelIndex = x;
102 for (
int y = 0; y < height33percent; ++y)
104 if (!isBlack(image(xCenter, (height - y)))
105 || !isBlack(image(width33percent, y))
106 || !isBlack(image(width66percent, y)))
108 firstNonBlackYPixelIndex = y;
115 detectedBorder.
unknown = firstNonBlackXPixelIndex == -1 || firstNonBlackYPixelIndex == -1;
118 return detectedBorder;
124 template <
typename Pixel_T>
128 int width = image.
width() /3;
129 int height = image.
height() / 3;
130 int maxSize = std::max(width, height);
132 int firstNonBlackXPixelIndex = -1;
133 int firstNonBlackYPixelIndex = -1;
136 for (
int i = 0; i < maxSize; ++i)
138 int x = std::min(i, width);
139 int y = std::min(i, height);
141 const Pixel_T & color = image(x, y);
144 firstNonBlackXPixelIndex = x;
145 firstNonBlackYPixelIndex = y;
151 for(; firstNonBlackXPixelIndex > 0; --firstNonBlackXPixelIndex)
153 const Pixel_T & color = image(firstNonBlackXPixelIndex-1, firstNonBlackYPixelIndex);
161 for(; firstNonBlackYPixelIndex > 0; --firstNonBlackYPixelIndex)
163 const Pixel_T & color = image(firstNonBlackXPixelIndex, firstNonBlackYPixelIndex-1);
172 detectedBorder.
unknown = firstNonBlackXPixelIndex == -1 || firstNonBlackYPixelIndex == -1;
175 return detectedBorder;
181 template <
typename Pixel_T>
186 int width = image.
width();
187 int height = image.
height();
188 int width33percent = width / 3;
189 int height33percent = height / 3;
190 int height66percent = height33percent * 2;
191 int yCenter = height / 2;
194 int firstNonBlackXPixelIndex = -1;
195 int firstNonBlackYPixelIndex = -1;
202 for (x = 0; x < width33percent; ++x)
204 if (!isBlack(image((width - x), yCenter))
205 || !isBlack(image(x, height33percent))
206 || !isBlack(image(x, height66percent)))
208 firstNonBlackXPixelIndex = x;
214 for (
int y = 0; y < height33percent; ++y)
217 if (!isBlack(image(x, y))
218 || !isBlack(image(x, (height - y)))
219 || !isBlack(image((width - x), y))
220 || !isBlack(image((width - x), (height - y))))
223 firstNonBlackYPixelIndex = y;
230 detectedBorder.
unknown = firstNonBlackXPixelIndex == -1 || firstNonBlackYPixelIndex == -1;
233 return detectedBorder;
247 template <
typename Pixel_T>
248 inline bool isBlack(
const Pixel_T & color)
251 return color.red < _blackborderThreshold && color.green < _blackborderThreshold && color.blue < _blackborderThreshold;
256 const uint8_t _blackborderThreshold;
Provide utility methods for Hyperion class.
Definition: BlackBorderDetector.h:7
int verticalSize
The size of the detected vertical border.
Definition: BlackBorderDetector.h:21
unsigned height() const
Returns the height of the image.
Definition: Image.h:129
BlackBorder process_osd(const Image< Pixel_T > &image)
osd detection mode (find x then y at detected x to avoid changes by osd overlays) ...
Definition: BlackBorderDetector.h:182
Result structure of the detected blackborder.
Definition: BlackBorderDetector.h:12
BlackBorder process(const Image< Pixel_T > &image)
default detection mode (3lines 4side detection)
Definition: BlackBorderDetector.h:68
bool operator==(const BlackBorder &other) const
Compares this BlackBorder to the given other BlackBorder.
Definition: BlackBorderDetector.h:30
unsigned width() const
Returns the width of the image.
Definition: Image.h:119
BlackBorder process_classic(const Image< Pixel_T > &image)
classic detection mode (topleft single line mode)
Definition: BlackBorderDetector.h:125
bool unknown
Falg indicating if the border is unknown.
Definition: BlackBorderDetector.h:15
int horizontalSize
The size of the detected horizontal border.
Definition: BlackBorderDetector.h:18
The BlackBorderDetector performs detection of black-borders on a single image.
Definition: BlackBorderDetector.h:46