mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
3line detection
Former-commit-id: a63c03bc276ef218981213fbb9743a3d6d12d8b6
This commit is contained in:
parent
469ea42f49
commit
633985930b
@ -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;
|
||||
|
@ -1,4 +1,4 @@
|
||||
|
||||
//#include <iostream>
|
||||
// Blackborder includes
|
||||
#include <blackborder/BlackBorderProcessor.h>
|
||||
|
||||
@ -28,15 +28,20 @@ bool BlackBorderProcessor::updateBorder(const BlackBorder & newDetectedBorder)
|
||||
{
|
||||
// set the consistency counter
|
||||
if (newDetectedBorder == _previousDetectedBorder)
|
||||
{
|
||||
if (_consistentCnt < 100000)
|
||||
{
|
||||
++_consistentCnt;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_previousDetectedBorder = 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;
|
||||
|
Loading…
Reference in New Issue
Block a user