diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b932200..542dae87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - New LED Device SK9822 (#1005) - Support SK9822 type LEDs with adaptive brightness control via SPI (#1017) - 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) - DirectX9 Grabber (#1039) - Added DirectX SDK to CompileHowto diff --git a/assets/webconfig/i18n/en.json b/assets/webconfig/i18n/en.json index 6f9daa59..5e6f3d9d 100644 --- a/assets/webconfig/i18n/en.json +++ b/assets/webconfig/i18n/en.json @@ -261,6 +261,7 @@ "edt_conf_enum_automatic": "Automatic", "edt_conf_enum_bbclassic": "Classic", "edt_conf_enum_bbdefault": "Default", + "edt_conf_enum_bbletterbox": "Letterbox", "edt_conf_enum_bbosd": "OSD", "edt_conf_enum_bgr": "BGR", "edt_conf_enum_bottom_up": "Bottom up", diff --git a/config/hyperion.config.json.commented b/config/hyperion.config.json.commented index f1595970..3607892d 100644 --- a/config/hyperion.config.json.commented +++ b/config/hyperion.config.json.commented @@ -178,7 +178,7 @@ /// * 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 /// * 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" : { "enable" : true, diff --git a/docs/docs/en/user/advanced/Advanced.md b/docs/docs/en/user/advanced/Advanced.md index d44a7678..c8ce7119 100644 --- a/docs/docs/en/user/advanced/Advanced.md +++ b/docs/docs/en/user/advanced/Advanced.md @@ -93,6 +93,7 @@ Explain the differences between the available modes for blackbar 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. * **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. ## Gamma Curve diff --git a/include/blackborder/BlackBorderDetector.h b/include/blackborder/BlackBorderDetector.h index 436800db..f34ba27b 100644 --- a/include/blackborder/BlackBorderDetector.h +++ b/include/blackborder/BlackBorderDetector.h @@ -234,6 +234,49 @@ namespace hyperion } + /// + /// letterbox detection mode (5lines top-bottom only detection) + template + BlackBorder process_letterbox(const Image & 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: diff --git a/include/blackborder/BlackBorderProcessor.h b/include/blackborder/BlackBorderProcessor.h index 752c9f9e..aa8a3aa4 100644 --- a/include/blackborder/BlackBorderProcessor.h +++ b/include/blackborder/BlackBorderProcessor.h @@ -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) diff --git a/libsrc/hyperion/schema/schema-blackborderdetector.json b/libsrc/hyperion/schema/schema-blackborderdetector.json index 2b73d019..8247c61e 100644 --- a/libsrc/hyperion/schema/schema-blackborderdetector.json +++ b/libsrc/hyperion/schema/schema-blackborderdetector.json @@ -60,10 +60,10 @@ { "type" : "string", "title": "edt_conf_bb_mode_title", - "enum" : ["default", "classic", "osd"], + "enum" : ["default", "classic", "osd", "letterbox"], "default" : "default", "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 }