From 469ea42f49dc986d0bc507c5d6b1fa4adca0156d Mon Sep 17 00:00:00 2001 From: wisc Date: Sat, 2 Jan 2016 02:31:13 +0100 Subject: [PATCH 1/5] check for black pixel at center x/y Former-commit-id: d91f422f55638418d2517d91b1c925880d7ca448 --- include/blackborder/BlackBorderDetector.h | 41 +++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/include/blackborder/BlackBorderDetector.h b/include/blackborder/BlackBorderDetector.h index c5ee91e7..3f190c5c 100644 --- a/include/blackborder/BlackBorderDetector.h +++ b/include/blackborder/BlackBorderDetector.h @@ -61,11 +61,51 @@ namespace hyperion template BlackBorder process(const Image & image) { + + // only test the topleft third of the image + int width = image.width() / 3; + int height = image.height() / 3; + int xCenter = image.width() / 2; + int yCenter = image.height() / 2; +// int maxSize = std::max(width, height); + + + + int firstNonBlackXPixelIndex = -1; + int firstNonBlackYPixelIndex = -1; + + // find first X pixel of the image + for (int x = 0; x < width; ++x) + { + const Pixel_T & color = image(x, yCenter); + if (!isBlack(color)) + { + firstNonBlackXPixelIndex = x; + break; + } + } + + // find first Y pixel of the image + for (int y = 0; y < height; ++y) + { + const Pixel_T & color = image(xCenter, y); + if (!isBlack(color)) + { + firstNonBlackYPixelIndex = y; + break; + } + } + + + +/* // only test the topleft third of the image int width = image.width() /3; int height = image.height() / 3; int maxSize = std::max(width, height); + + int firstNonBlackXPixelIndex = -1; int firstNonBlackYPixelIndex = -1; @@ -103,6 +143,7 @@ namespace hyperion break; } } +*/ // Construct result BlackBorder detectedBorder; From 633985930b8ba55e001656d06f81b0034613e37c Mon Sep 17 00:00:00 2001 From: wisc Date: Mon, 4 Jan 2016 00:20:47 +0100 Subject: [PATCH 2/5] 3line detection Former-commit-id: a63c03bc276ef218981213fbb9743a3d6d12d8b6 --- include/blackborder/BlackBorderDetector.h | 14 ++++++++++---- libsrc/blackborder/BlackBorderProcessor.cpp | 21 +++++++++++++++------ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/include/blackborder/BlackBorderDetector.h b/include/blackborder/BlackBorderDetector.h index 3f190c5c..cd955b8a 100644 --- a/include/blackborder/BlackBorderDetector.h +++ b/include/blackborder/BlackBorderDetector.h @@ -65,6 +65,8 @@ namespace hyperion // only test the topleft third of the image int width = image.width() / 3; int height = image.height() / 3; + int width2 = width * 2; + int height2 = height * 2; int xCenter = image.width() / 2; int yCenter = image.height() / 2; // int maxSize = std::max(width, height); @@ -77,8 +79,10 @@ namespace hyperion // find first X pixel of the image for (int x = 0; x < width; ++x) { - const Pixel_T & color = image(x, yCenter); - if (!isBlack(color)) + const Pixel_T & color1 = image(x, yCenter); + const Pixel_T & color2 = image(x, height); + const Pixel_T & color3 = image(x, height2); + if (!isBlack(color1) || !isBlack(color2) || !isBlack(color3)) { firstNonBlackXPixelIndex = x; break; @@ -88,8 +92,10 @@ namespace hyperion // find first Y pixel of the image for (int y = 0; y < height; ++y) { - const Pixel_T & color = image(xCenter, y); - if (!isBlack(color)) + const Pixel_T & color1 = image(xCenter, y); + const Pixel_T & color2 = image(width, y); + const Pixel_T & color3 = image(width2, y); + if (!isBlack(color1) || !isBlack(color2) || !isBlack(color3)) { firstNonBlackYPixelIndex = y; break; diff --git a/libsrc/blackborder/BlackBorderProcessor.cpp b/libsrc/blackborder/BlackBorderProcessor.cpp index ee78efb9..b9c21eea 100644 --- a/libsrc/blackborder/BlackBorderProcessor.cpp +++ b/libsrc/blackborder/BlackBorderProcessor.cpp @@ -1,4 +1,4 @@ - +//#include // Blackborder includes #include @@ -29,7 +29,10 @@ bool BlackBorderProcessor::updateBorder(const BlackBorder & newDetectedBorder) // set the consistency counter if (newDetectedBorder == _previousDetectedBorder) { - ++_consistentCnt; + if (_consistentCnt < 100000) + { + ++_consistentCnt; + } } else { @@ -37,6 +40,8 @@ bool BlackBorderProcessor::updateBorder(const BlackBorder & newDetectedBorder) _consistentCnt = 0; } +// std::cout << "new: " << newDetectedBorder.verticalSize << " " << newDetectedBorder.horizontalSize << " cur: " << _currentBorder.verticalSize << " " << _currentBorder.horizontalSize << " cc " << _consistentCnt << std::endl; + // check if there is a change if (_currentBorder == newDetectedBorder) { @@ -48,7 +53,8 @@ bool BlackBorderProcessor::updateBorder(const BlackBorder & newDetectedBorder) if (newDetectedBorder.unknown) { // apply the unknown border if we consistently can't determine a border - if (_consistentCnt == _unknownSwitchCnt) +// if (_consistentCnt == _unknownSwitchCnt) + if (_consistentCnt >= _unknownSwitchCnt) { _currentBorder = newDetectedBorder; borderChanged = true; @@ -57,7 +63,8 @@ bool BlackBorderProcessor::updateBorder(const BlackBorder & newDetectedBorder) else { // apply the detected border if it has been detected consistently - if (_currentBorder.unknown || _consistentCnt == _borderSwitchCnt) +// if (_currentBorder.unknown || _consistentCnt == _borderSwitchCnt) + if (_currentBorder.unknown || _consistentCnt >= _borderSwitchCnt) { _currentBorder = newDetectedBorder; borderChanged = true; @@ -65,13 +72,15 @@ bool BlackBorderProcessor::updateBorder(const BlackBorder & newDetectedBorder) else { // apply smaller borders immediately - if (newDetectedBorder.verticalSize < _currentBorder.verticalSize) +// if (newDetectedBorder.verticalSize < _currentBorder.verticalSize) + if ( (newDetectedBorder.verticalSize < _currentBorder.verticalSize) && (_consistentCnt >= 1) )// almost immediatly - avoid switching for "abnormal" frames { _currentBorder.verticalSize = newDetectedBorder.verticalSize; borderChanged = true; } - if (newDetectedBorder.horizontalSize < _currentBorder.horizontalSize) +// if (newDetectedBorder.horizontalSize < _currentBorder.horizontalSize) + if ( (newDetectedBorder.horizontalSize < _currentBorder.horizontalSize) && (_consistentCnt >= 1) ) { _currentBorder.horizontalSize = newDetectedBorder.horizontalSize; borderChanged = true; From 544ae68429cf8e7eb026d912a508e6905d76e404 Mon Sep 17 00:00:00 2001 From: wisc Date: Sun, 10 Jan 2016 14:41:47 +0100 Subject: [PATCH 3/5] test old v1+ vs new v2 Former-commit-id: 5217ac135cd0c7a6907be0097df72506ca7f2d71 --- include/blackborder/BlackBorderProcessor.h | 8 ++ libsrc/blackborder/BlackBorderProcessor.cpp | 107 ++++++++++++++++++-- 2 files changed, 105 insertions(+), 10 deletions(-) diff --git a/include/blackborder/BlackBorderProcessor.h b/include/blackborder/BlackBorderProcessor.h index 4d0c4fca..19f90d3d 100644 --- a/include/blackborder/BlackBorderProcessor.h +++ b/include/blackborder/BlackBorderProcessor.h @@ -73,6 +73,8 @@ namespace hyperion /// @return True if the current border changed else false /// bool updateBorder(const BlackBorder & newDetectedBorder); + bool updateBorder1(const BlackBorder & newDetectedBorder); + bool updateBorder2(const BlackBorder & newDetectedBorder); /// The number of unknown-borders detected before it becomes the current border const unsigned _unknownSwitchCnt; @@ -87,12 +89,18 @@ namespace hyperion BlackBorderDetector _detector; /// The current detected border + BlackBorder _currentBorder1; BlackBorder _currentBorder; /// The border detected in the previous frame + BlackBorder _previousDetectedBorder1; BlackBorder _previousDetectedBorder; /// The number of frame the previous detected border matched the incomming border + unsigned _consistentCnt1; unsigned _consistentCnt; + /// The number of frame the previous detected border NOT matched the incomming border + unsigned _inconsistentCnt1; + unsigned _inconsistentCnt; }; } // end namespace hyperion diff --git a/libsrc/blackborder/BlackBorderProcessor.cpp b/libsrc/blackborder/BlackBorderProcessor.cpp index b9c21eea..b3f1824f 100644 --- a/libsrc/blackborder/BlackBorderProcessor.cpp +++ b/libsrc/blackborder/BlackBorderProcessor.cpp @@ -1,4 +1,4 @@ -//#include +#include // Blackborder includes #include @@ -12,9 +12,14 @@ BlackBorderProcessor::BlackBorderProcessor(const unsigned unknownFrameCnt, _borderSwitchCnt(borderFrameCnt), _blurRemoveCnt(blurRemoveCnt), _detector(blackborderThreshold), + _currentBorder1({true, -1, -1}), _currentBorder({true, -1, -1}), + _previousDetectedBorder1({true, -1, -1}), _previousDetectedBorder({true, -1, -1}), - _consistentCnt(0) + _consistentCnt1(0), + _consistentCnt(0), + _inconsistentCnt1(0), + _inconsistentCnt(0) { // empty } @@ -24,23 +29,102 @@ BlackBorder BlackBorderProcessor::getCurrentBorder() const return _currentBorder; } + bool BlackBorderProcessor::updateBorder(const BlackBorder & newDetectedBorder) +{ +bool result1 = updateBorder1(newDetectedBorder); +if (result1) +{ + std::cout << "border change v1 " << _currentBorder1.horizontalSize << ":" << _currentBorder1.verticalSize << std::endl; +} + +bool result2 = updateBorder2(newDetectedBorder); +if (result2) +{ + std::cout << "border change v2 " << _currentBorder.horizontalSize << ":" << _currentBorder.verticalSize << std::endl; +} + +return result2; +} + + +bool BlackBorderProcessor::updateBorder1(const BlackBorder & newDetectedBorder) +{ + // set the consistency counter + if (newDetectedBorder == _previousDetectedBorder1) + { + ++_consistentCnt1; + } + else + { + _previousDetectedBorder1 = newDetectedBorder; + _consistentCnt1 = 0; + } + +// std::cout << "cur: " << _currentBorder1.verticalSize << " " << _currentBorder1.horizontalSize << " new: " << newDetectedBorder.verticalSize << " " << newDetectedBorder.horizontalSize << " c:i " << _consistentCnt1 << ":" << _inconsistentCnt1 << std::endl; + + // check if there is a change + if (_currentBorder1 == newDetectedBorder) + { + // No change required + return false; + } + + bool borderChanged = false; + if (newDetectedBorder.unknown) + { + // apply the unknown border if we consistently can't determine a border + if (_consistentCnt1 == _unknownSwitchCnt) + { + _currentBorder1 = newDetectedBorder; + borderChanged = true; + } + } + else + { + // apply the detected border if it has been detected consistently + if (_currentBorder1.unknown || _consistentCnt1 == _borderSwitchCnt) + { + _currentBorder1 = newDetectedBorder; + borderChanged = true; + } + else + { + bool stable = (_consistentCnt >= 10) || (_inconsistentCnt >=30 ); + // apply smaller borders immediately + if ((newDetectedBorder.verticalSize < _currentBorder1.verticalSize) && (stable)) + { + _currentBorder1.verticalSize = newDetectedBorder.verticalSize; + borderChanged = true; + } + + if ((newDetectedBorder.horizontalSize < _currentBorder1.horizontalSize) && (stable)) + { + _currentBorder1.horizontalSize = newDetectedBorder.horizontalSize; + borderChanged = true; + } + } + } + + return borderChanged; +} + +bool BlackBorderProcessor::updateBorder2(const BlackBorder & newDetectedBorder) { // set the consistency counter if (newDetectedBorder == _previousDetectedBorder) { - if (_consistentCnt < 100000) - { - ++_consistentCnt; - } + ++_consistentCnt; + _inconsistentCnt = 0; } else { _previousDetectedBorder = newDetectedBorder; _consistentCnt = 0; + ++_inconsistentCnt; } -// std::cout << "new: " << newDetectedBorder.verticalSize << " " << newDetectedBorder.horizontalSize << " cur: " << _currentBorder.verticalSize << " " << _currentBorder.horizontalSize << " cc " << _consistentCnt << std::endl; +// std::cout << "cur: " << _currentBorder.verticalSize << " " << _currentBorder.horizontalSize << " new: " << newDetectedBorder.verticalSize << " " << newDetectedBorder.horizontalSize << " c:i " << _consistentCnt << ":" << _inconsistentCnt << std::endl; // check if there is a change if (_currentBorder == newDetectedBorder) @@ -71,16 +155,19 @@ bool BlackBorderProcessor::updateBorder(const BlackBorder & newDetectedBorder) } else { + bool stable = (_consistentCnt >= 10) || (_inconsistentCnt >=30 ); + //more then A consistent seems like a new size not only a short flicker + //more then B inconsistent seems like the image is changing a lot and we need to set smaller border // apply smaller borders immediately // if (newDetectedBorder.verticalSize < _currentBorder.verticalSize) - if ( (newDetectedBorder.verticalSize < _currentBorder.verticalSize) && (_consistentCnt >= 1) )// almost immediatly - avoid switching for "abnormal" frames + if ( (newDetectedBorder.verticalSize < _currentBorder.verticalSize) && (stable) )// almost immediatly - avoid switching for "abnormal" frames { _currentBorder.verticalSize = newDetectedBorder.verticalSize; borderChanged = true; } // if (newDetectedBorder.horizontalSize < _currentBorder.horizontalSize) - if ( (newDetectedBorder.horizontalSize < _currentBorder.horizontalSize) && (_consistentCnt >= 1) ) + if ( (newDetectedBorder.horizontalSize < _currentBorder.horizontalSize) && (stable) ) { _currentBorder.horizontalSize = newDetectedBorder.horizontalSize; borderChanged = true; @@ -89,4 +176,4 @@ bool BlackBorderProcessor::updateBorder(const BlackBorder & newDetectedBorder) } return borderChanged; -} +} \ No newline at end of file From ac86a779b076ff7f7b37a055b1ad2e7650f76ec2 Mon Sep 17 00:00:00 2001 From: wisc Date: Sun, 10 Jan 2016 14:55:23 +0100 Subject: [PATCH 4/5] cleanup Former-commit-id: 39cb3f76379990085407791ec391732c986790e6 --- include/blackborder/BlackBorderProcessor.h | 4 - libsrc/blackborder/BlackBorderProcessor.cpp | 88 +-------------------- 2 files changed, 1 insertion(+), 91 deletions(-) diff --git a/include/blackborder/BlackBorderProcessor.h b/include/blackborder/BlackBorderProcessor.h index 19f90d3d..ad8c7b83 100644 --- a/include/blackborder/BlackBorderProcessor.h +++ b/include/blackborder/BlackBorderProcessor.h @@ -89,18 +89,14 @@ namespace hyperion BlackBorderDetector _detector; /// The current detected border - BlackBorder _currentBorder1; BlackBorder _currentBorder; /// The border detected in the previous frame - BlackBorder _previousDetectedBorder1; BlackBorder _previousDetectedBorder; /// The number of frame the previous detected border matched the incomming border - unsigned _consistentCnt1; unsigned _consistentCnt; /// The number of frame the previous detected border NOT matched the incomming border - unsigned _inconsistentCnt1; unsigned _inconsistentCnt; }; } // end namespace hyperion diff --git a/libsrc/blackborder/BlackBorderProcessor.cpp b/libsrc/blackborder/BlackBorderProcessor.cpp index b3f1824f..28262229 100644 --- a/libsrc/blackborder/BlackBorderProcessor.cpp +++ b/libsrc/blackborder/BlackBorderProcessor.cpp @@ -1,4 +1,4 @@ -#include + // Blackborder includes #include @@ -12,13 +12,9 @@ BlackBorderProcessor::BlackBorderProcessor(const unsigned unknownFrameCnt, _borderSwitchCnt(borderFrameCnt), _blurRemoveCnt(blurRemoveCnt), _detector(blackborderThreshold), - _currentBorder1({true, -1, -1}), _currentBorder({true, -1, -1}), - _previousDetectedBorder1({true, -1, -1}), _previousDetectedBorder({true, -1, -1}), - _consistentCnt1(0), _consistentCnt(0), - _inconsistentCnt1(0), _inconsistentCnt(0) { // empty @@ -29,87 +25,7 @@ BlackBorder BlackBorderProcessor::getCurrentBorder() const return _currentBorder; } - bool BlackBorderProcessor::updateBorder(const BlackBorder & newDetectedBorder) -{ -bool result1 = updateBorder1(newDetectedBorder); -if (result1) -{ - std::cout << "border change v1 " << _currentBorder1.horizontalSize << ":" << _currentBorder1.verticalSize << std::endl; -} - -bool result2 = updateBorder2(newDetectedBorder); -if (result2) -{ - std::cout << "border change v2 " << _currentBorder.horizontalSize << ":" << _currentBorder.verticalSize << std::endl; -} - -return result2; -} - - -bool BlackBorderProcessor::updateBorder1(const BlackBorder & newDetectedBorder) -{ - // set the consistency counter - if (newDetectedBorder == _previousDetectedBorder1) - { - ++_consistentCnt1; - } - else - { - _previousDetectedBorder1 = newDetectedBorder; - _consistentCnt1 = 0; - } - -// std::cout << "cur: " << _currentBorder1.verticalSize << " " << _currentBorder1.horizontalSize << " new: " << newDetectedBorder.verticalSize << " " << newDetectedBorder.horizontalSize << " c:i " << _consistentCnt1 << ":" << _inconsistentCnt1 << std::endl; - - // check if there is a change - if (_currentBorder1 == newDetectedBorder) - { - // No change required - return false; - } - - bool borderChanged = false; - if (newDetectedBorder.unknown) - { - // apply the unknown border if we consistently can't determine a border - if (_consistentCnt1 == _unknownSwitchCnt) - { - _currentBorder1 = newDetectedBorder; - borderChanged = true; - } - } - else - { - // apply the detected border if it has been detected consistently - if (_currentBorder1.unknown || _consistentCnt1 == _borderSwitchCnt) - { - _currentBorder1 = newDetectedBorder; - borderChanged = true; - } - else - { - bool stable = (_consistentCnt >= 10) || (_inconsistentCnt >=30 ); - // apply smaller borders immediately - if ((newDetectedBorder.verticalSize < _currentBorder1.verticalSize) && (stable)) - { - _currentBorder1.verticalSize = newDetectedBorder.verticalSize; - borderChanged = true; - } - - if ((newDetectedBorder.horizontalSize < _currentBorder1.horizontalSize) && (stable)) - { - _currentBorder1.horizontalSize = newDetectedBorder.horizontalSize; - borderChanged = true; - } - } - } - - return borderChanged; -} - -bool BlackBorderProcessor::updateBorder2(const BlackBorder & newDetectedBorder) { // set the consistency counter if (newDetectedBorder == _previousDetectedBorder) @@ -124,8 +40,6 @@ bool BlackBorderProcessor::updateBorder2(const BlackBorder & newDetectedBorder) ++_inconsistentCnt; } -// std::cout << "cur: " << _currentBorder.verticalSize << " " << _currentBorder.horizontalSize << " new: " << newDetectedBorder.verticalSize << " " << newDetectedBorder.horizontalSize << " c:i " << _consistentCnt << ":" << _inconsistentCnt << std::endl; - // check if there is a change if (_currentBorder == newDetectedBorder) { From 4bc11548b4584f93b4e0b3fa83cf221d78e2edba Mon Sep 17 00:00:00 2001 From: wisc Date: Sun, 10 Jan 2016 18:42:55 +0100 Subject: [PATCH 5/5] faster detection less false positive Former-commit-id: 501de9bca4c20600fe1e6250e82143f0b0d6ade3 --- include/blackborder/BlackBorderDetector.h | 53 +-------------------- include/blackborder/BlackBorderProcessor.h | 2 - libsrc/blackborder/BlackBorderProcessor.cpp | 17 +++---- 3 files changed, 8 insertions(+), 64 deletions(-) diff --git a/include/blackborder/BlackBorderDetector.h b/include/blackborder/BlackBorderDetector.h index cd955b8a..14cf051c 100644 --- a/include/blackborder/BlackBorderDetector.h +++ b/include/blackborder/BlackBorderDetector.h @@ -62,15 +62,13 @@ namespace hyperion BlackBorder process(const Image & image) { - // only test the topleft third of the image + // test center and 1/3, 2/3 of width/heigth int width = image.width() / 3; int height = image.height() / 3; int width2 = width * 2; int height2 = height * 2; int xCenter = image.width() / 2; int yCenter = image.height() / 2; -// int maxSize = std::max(width, height); - int firstNonBlackXPixelIndex = -1; @@ -102,55 +100,6 @@ namespace hyperion } } - - -/* - // only test the topleft third of the image - int width = image.width() /3; - int height = image.height() / 3; - int maxSize = std::max(width, height); - - - - int firstNonBlackXPixelIndex = -1; - int firstNonBlackYPixelIndex = -1; - - // find some pixel of the image - for (int i = 0; i < maxSize; ++i) - { - int x = std::min(i, width); - int y = std::min(i, height); - - const Pixel_T & color = image(x, y); - if (!isBlack(color)) - { - firstNonBlackXPixelIndex = x; - firstNonBlackYPixelIndex = y; - break; - } - } - - // expand image to the left - for(; firstNonBlackXPixelIndex > 0; --firstNonBlackXPixelIndex) - { - const Pixel_T & color = image(firstNonBlackXPixelIndex-1, firstNonBlackYPixelIndex); - if (isBlack(color)) - { - break; - } - } - - // expand image to the top - for(; firstNonBlackYPixelIndex > 0; --firstNonBlackYPixelIndex) - { - const Pixel_T & color = image(firstNonBlackXPixelIndex, firstNonBlackYPixelIndex-1); - if (isBlack(color)) - { - break; - } - } -*/ - // Construct result BlackBorder detectedBorder; detectedBorder.unknown = firstNonBlackXPixelIndex == -1 || firstNonBlackYPixelIndex == -1; diff --git a/include/blackborder/BlackBorderProcessor.h b/include/blackborder/BlackBorderProcessor.h index ad8c7b83..14be0585 100644 --- a/include/blackborder/BlackBorderProcessor.h +++ b/include/blackborder/BlackBorderProcessor.h @@ -73,8 +73,6 @@ namespace hyperion /// @return True if the current border changed else false /// bool updateBorder(const BlackBorder & newDetectedBorder); - bool updateBorder1(const BlackBorder & newDetectedBorder); - bool updateBorder2(const BlackBorder & newDetectedBorder); /// The number of unknown-borders detected before it becomes the current border const unsigned _unknownSwitchCnt; diff --git a/libsrc/blackborder/BlackBorderProcessor.cpp b/libsrc/blackborder/BlackBorderProcessor.cpp index 28262229..2312da31 100644 --- a/libsrc/blackborder/BlackBorderProcessor.cpp +++ b/libsrc/blackborder/BlackBorderProcessor.cpp @@ -51,8 +51,7 @@ bool BlackBorderProcessor::updateBorder(const BlackBorder & newDetectedBorder) if (newDetectedBorder.unknown) { // apply the unknown border if we consistently can't determine a border -// if (_consistentCnt == _unknownSwitchCnt) - if (_consistentCnt >= _unknownSwitchCnt) + if (_consistentCnt == _unknownSwitchCnt) { _currentBorder = newDetectedBorder; borderChanged = true; @@ -61,8 +60,7 @@ bool BlackBorderProcessor::updateBorder(const BlackBorder & newDetectedBorder) else { // apply the detected border if it has been detected consistently -// if (_currentBorder.unknown || _consistentCnt == _borderSwitchCnt) - if (_currentBorder.unknown || _consistentCnt >= _borderSwitchCnt) + if (_currentBorder.unknown || _consistentCnt == _borderSwitchCnt) { _currentBorder = newDetectedBorder; borderChanged = true; @@ -70,17 +68,16 @@ bool BlackBorderProcessor::updateBorder(const BlackBorder & newDetectedBorder) else { bool stable = (_consistentCnt >= 10) || (_inconsistentCnt >=30 ); - //more then A consistent seems like a new size not only a short flicker - //more then B inconsistent seems like the image is changing a lot and we need to set smaller border - // apply smaller borders immediately -// if (newDetectedBorder.verticalSize < _currentBorder.verticalSize) - if ( (newDetectedBorder.verticalSize < _currentBorder.verticalSize) && (stable) )// almost immediatly - avoid switching for "abnormal" frames + //more then 10 consistent seems like a new size not only a short flicker + //more then 30 inconsistent seems like the image is changing a lot and we need to set smaller border + + // apply smaller borders (almost) immediately -> avoid switching for "abnormal" frames + if ( (newDetectedBorder.verticalSize < _currentBorder.verticalSize) && (stable) ) { _currentBorder.verticalSize = newDetectedBorder.verticalSize; borderChanged = true; } -// if (newDetectedBorder.horizontalSize < _currentBorder.horizontalSize) if ( (newDetectedBorder.horizontalSize < _currentBorder.horizontalSize) && (stable) ) { _currentBorder.horizontalSize = newDetectedBorder.horizontalSize;