Implement letterbox-only blackbar detection mode (#1063)

This commit is contained in:
Peter Eskdale 2020-11-01 18:20:27 +00:00 committed by GitHub
parent 958975975c
commit 85a55de28c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 52 additions and 4 deletions

View File

@ -15,7 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- New LED Device SK9822 (#1005) - New LED Device SK9822 (#1005)
- Support SK9822 type LEDs with adaptive brightness control via SPI (#1017) - Support SK9822 type LEDs with adaptive brightness control via SPI (#1017)
- Provide additional details on Hardware/CPU information (#1045) - Provide additional details on Hardware/CPU information (#1045)
- Allow execution with option "--version", while another hyperion daemon is running Allow execution with option "--version", while another hyperion daemon is running
- New blackbar detection mode "Letterbox", that considers only bars at the top and bottom of picture
- Systray icons added - Issue #925 (#1040) - Systray icons added - Issue #925 (#1040)
- DirectX9 Grabber (#1039) - DirectX9 Grabber (#1039)
- Added DirectX SDK to CompileHowto - Added DirectX SDK to CompileHowto

View File

@ -261,6 +261,7 @@
"edt_conf_enum_automatic": "Automatic", "edt_conf_enum_automatic": "Automatic",
"edt_conf_enum_bbclassic": "Classic", "edt_conf_enum_bbclassic": "Classic",
"edt_conf_enum_bbdefault": "Default", "edt_conf_enum_bbdefault": "Default",
"edt_conf_enum_bbletterbox": "Letterbox",
"edt_conf_enum_bbosd": "OSD", "edt_conf_enum_bbosd": "OSD",
"edt_conf_enum_bgr": "BGR", "edt_conf_enum_bgr": "BGR",
"edt_conf_enum_bottom_up": "Bottom up", "edt_conf_enum_bottom_up": "Bottom up",

View File

@ -178,7 +178,7 @@
/// * borderFrameCnt : Number of frames before a consistent detected border gets set (default 50) /// * borderFrameCnt : Number of frames before a consistent detected border gets set (default 50)
/// * maxInconsistentCnt : Number of inconsistent frames that are ignored before a new border gets a chance to proof consistency /// * maxInconsistentCnt : Number of inconsistent frames that are ignored before a new border gets a chance to proof consistency
/// * blurRemoveCnt : Number of pixels that get removed from the detected border to cut away blur (default 1) /// * blurRemoveCnt : Number of pixels that get removed from the detected border to cut away blur (default 1)
/// * mode : Border detection mode (values=default,classic,osd) /// * mode : Border detection mode (values=default,classic,osd,letterbox)
"blackborderdetector" : "blackborderdetector" :
{ {
"enable" : true, "enable" : true,

View File

@ -93,6 +93,7 @@ Explain the differences between the available modes for blackbar detection.
* **Default:** 3 scanlines in each direction (X Y) - fastest detection * **Default:** 3 scanlines in each direction (X Y) - fastest detection
* **Classic:** The original implementation - lower cpu time (legacy for RPi 1) just scan the top one third of the picture which leads to a slow detection and trouble with TV channel logo. * **Classic:** The original implementation - lower cpu time (legacy for RPi 1) just scan the top one third of the picture which leads to a slow detection and trouble with TV channel logo.
* **OSD:** Based on the default mode - not that effective but prevents border switching which may caused of OSD overlays (program infos and volume bar). * **OSD:** Based on the default mode - not that effective but prevents border switching which may caused of OSD overlays (program infos and volume bar).
* **Letterbox:** Based on the default mode - only considers blackbars at the top and bottom of the picture, ignoring the sides.
<ImageWrap src="/images/en/user_bbmodes.jpg" alt="Hyperion Blackbar detection modes" /> <ImageWrap src="/images/en/user_bbmodes.jpg" alt="Hyperion Blackbar detection modes" />
## Gamma Curve ## Gamma Curve

View File

@ -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: private:

View File

@ -79,6 +79,8 @@ namespace hyperion
imageBorder = _detector->process_classic(image); imageBorder = _detector->process_classic(image);
} else if (_detectionMode == "osd") { } else if (_detectionMode == "osd") {
imageBorder = _detector->process_osd(image); imageBorder = _detector->process_osd(image);
} else if (_detectionMode == "letterbox") {
imageBorder = _detector->process_letterbox(image);
} }
// add blur to the border // add blur to the border
if (imageBorder.horizontalSize > 0) if (imageBorder.horizontalSize > 0)

View File

@ -60,10 +60,10 @@
{ {
"type" : "string", "type" : "string",
"title": "edt_conf_bb_mode_title", "title": "edt_conf_bb_mode_title",
"enum" : ["default", "classic", "osd"], "enum" : ["default", "classic", "osd", "letterbox"],
"default" : "default", "default" : "default",
"options" : { "options" : {
"enum_titles" : ["edt_conf_enum_bbdefault", "edt_conf_enum_bbclassic", "edt_conf_enum_bbosd"] "enum_titles" : ["edt_conf_enum_bbdefault", "edt_conf_enum_bbclassic", "edt_conf_enum_bbosd", "edt_conf_enum_bbletterbox"]
}, },
"propertyOrder" : 7 "propertyOrder" : 7
} }