mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
test old v1+ vs new v2
Former-commit-id: 5217ac135cd0c7a6907be0097df72506ca7f2d71
This commit is contained in:
parent
633985930b
commit
544ae68429
@ -73,6 +73,8 @@ namespace hyperion
|
|||||||
/// @return True if the current border changed else false
|
/// @return True if the current border changed else false
|
||||||
///
|
///
|
||||||
bool updateBorder(const BlackBorder & newDetectedBorder);
|
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
|
/// The number of unknown-borders detected before it becomes the current border
|
||||||
const unsigned _unknownSwitchCnt;
|
const unsigned _unknownSwitchCnt;
|
||||||
@ -87,12 +89,18 @@ namespace hyperion
|
|||||||
BlackBorderDetector _detector;
|
BlackBorderDetector _detector;
|
||||||
|
|
||||||
/// The current detected border
|
/// The current detected border
|
||||||
|
BlackBorder _currentBorder1;
|
||||||
BlackBorder _currentBorder;
|
BlackBorder _currentBorder;
|
||||||
|
|
||||||
/// The border detected in the previous frame
|
/// The border detected in the previous frame
|
||||||
|
BlackBorder _previousDetectedBorder1;
|
||||||
BlackBorder _previousDetectedBorder;
|
BlackBorder _previousDetectedBorder;
|
||||||
|
|
||||||
/// The number of frame the previous detected border matched the incomming border
|
/// The number of frame the previous detected border matched the incomming border
|
||||||
|
unsigned _consistentCnt1;
|
||||||
unsigned _consistentCnt;
|
unsigned _consistentCnt;
|
||||||
|
/// The number of frame the previous detected border NOT matched the incomming border
|
||||||
|
unsigned _inconsistentCnt1;
|
||||||
|
unsigned _inconsistentCnt;
|
||||||
};
|
};
|
||||||
} // end namespace hyperion
|
} // end namespace hyperion
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//#include <iostream>
|
#include <iostream>
|
||||||
// Blackborder includes
|
// Blackborder includes
|
||||||
#include <blackborder/BlackBorderProcessor.h>
|
#include <blackborder/BlackBorderProcessor.h>
|
||||||
|
|
||||||
@ -12,9 +12,14 @@ BlackBorderProcessor::BlackBorderProcessor(const unsigned unknownFrameCnt,
|
|||||||
_borderSwitchCnt(borderFrameCnt),
|
_borderSwitchCnt(borderFrameCnt),
|
||||||
_blurRemoveCnt(blurRemoveCnt),
|
_blurRemoveCnt(blurRemoveCnt),
|
||||||
_detector(blackborderThreshold),
|
_detector(blackborderThreshold),
|
||||||
|
_currentBorder1({true, -1, -1}),
|
||||||
_currentBorder({true, -1, -1}),
|
_currentBorder({true, -1, -1}),
|
||||||
|
_previousDetectedBorder1({true, -1, -1}),
|
||||||
_previousDetectedBorder({true, -1, -1}),
|
_previousDetectedBorder({true, -1, -1}),
|
||||||
_consistentCnt(0)
|
_consistentCnt1(0),
|
||||||
|
_consistentCnt(0),
|
||||||
|
_inconsistentCnt1(0),
|
||||||
|
_inconsistentCnt(0)
|
||||||
{
|
{
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
@ -24,23 +29,102 @@ BlackBorder BlackBorderProcessor::getCurrentBorder() const
|
|||||||
return _currentBorder;
|
return _currentBorder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool BlackBorderProcessor::updateBorder(const BlackBorder & newDetectedBorder)
|
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
|
// set the consistency counter
|
||||||
if (newDetectedBorder == _previousDetectedBorder)
|
if (newDetectedBorder == _previousDetectedBorder)
|
||||||
{
|
{
|
||||||
if (_consistentCnt < 100000)
|
++_consistentCnt;
|
||||||
{
|
_inconsistentCnt = 0;
|
||||||
++_consistentCnt;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_previousDetectedBorder = newDetectedBorder;
|
_previousDetectedBorder = newDetectedBorder;
|
||||||
_consistentCnt = 0;
|
_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
|
// check if there is a change
|
||||||
if (_currentBorder == newDetectedBorder)
|
if (_currentBorder == newDetectedBorder)
|
||||||
@ -71,16 +155,19 @@ bool BlackBorderProcessor::updateBorder(const BlackBorder & newDetectedBorder)
|
|||||||
}
|
}
|
||||||
else
|
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
|
// 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
|
if ( (newDetectedBorder.verticalSize < _currentBorder.verticalSize) && (stable) )// almost immediatly - avoid switching for "abnormal" frames
|
||||||
{
|
{
|
||||||
_currentBorder.verticalSize = newDetectedBorder.verticalSize;
|
_currentBorder.verticalSize = newDetectedBorder.verticalSize;
|
||||||
borderChanged = true;
|
borderChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (newDetectedBorder.horizontalSize < _currentBorder.horizontalSize)
|
// if (newDetectedBorder.horizontalSize < _currentBorder.horizontalSize)
|
||||||
if ( (newDetectedBorder.horizontalSize < _currentBorder.horizontalSize) && (_consistentCnt >= 1) )
|
if ( (newDetectedBorder.horizontalSize < _currentBorder.horizontalSize) && (stable) )
|
||||||
{
|
{
|
||||||
_currentBorder.horizontalSize = newDetectedBorder.horizontalSize;
|
_currentBorder.horizontalSize = newDetectedBorder.horizontalSize;
|
||||||
borderChanged = true;
|
borderChanged = true;
|
||||||
@ -89,4 +176,4 @@ bool BlackBorderProcessor::updateBorder(const BlackBorder & newDetectedBorder)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return borderChanged;
|
return borderChanged;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user