mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Implement letterbox-only blackbar detection mode (#1063)
This commit is contained in:
@@ -234,6 +234,49 @@ namespace hyperion
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// letterbox detection mode (5lines top-bottom only detection)
|
||||
template <typename Pixel_T>
|
||||
BlackBorder process_letterbox(const Image<Pixel_T> & image) const
|
||||
{
|
||||
// test center and 25%, 75% of width
|
||||
// 25 and 75 will check both top and bottom
|
||||
// center will only check top (minimise false detection of captions)
|
||||
int width = image.width();
|
||||
int height = image.height();
|
||||
int width25percent = width / 4;
|
||||
int height33percent = height / 3;
|
||||
int width75percent = width25percent * 3;
|
||||
int xCenter = width / 2;
|
||||
|
||||
|
||||
int firstNonBlackYPixelIndex = -1;
|
||||
|
||||
height--; // remove 1 pixel to get end pixel index
|
||||
|
||||
// find first Y pixel of the image
|
||||
for (int y = 0; y < height33percent; ++y)
|
||||
{
|
||||
if (!isBlack(image(xCenter, y))
|
||||
|| !isBlack(image(width25percent, y))
|
||||
|| !isBlack(image(width75percent, y))
|
||||
|| !isBlack(image(width25percent, (height - y)))
|
||||
|| !isBlack(image(width75percent, (height - y))))
|
||||
{
|
||||
firstNonBlackYPixelIndex = y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Construct result
|
||||
BlackBorder detectedBorder;
|
||||
detectedBorder.unknown = firstNonBlackYPixelIndex == -1;
|
||||
detectedBorder.horizontalSize = firstNonBlackYPixelIndex;
|
||||
detectedBorder.verticalSize = 0;
|
||||
return detectedBorder;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
@@ -79,6 +79,8 @@ namespace hyperion
|
||||
imageBorder = _detector->process_classic(image);
|
||||
} else if (_detectionMode == "osd") {
|
||||
imageBorder = _detector->process_osd(image);
|
||||
} else if (_detectionMode == "letterbox") {
|
||||
imageBorder = _detector->process_letterbox(image);
|
||||
}
|
||||
// add blur to the border
|
||||
if (imageBorder.horizontalSize > 0)
|
||||
|
Reference in New Issue
Block a user