mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Moved black border detection code to seperate library
Former-commit-id: 590029949b79689ea05409149677e51b748cb64f
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
|
||||
// Local-Hyperion includes
|
||||
#include <hyperion/BlackBorderDetector.h>
|
||||
|
||||
using namespace hyperion;
|
||||
|
||||
BlackBorderDetector::BlackBorderDetector(uint8_t blackborderThreshold) :
|
||||
_blackborderThreshold(blackborderThreshold)
|
||||
{
|
||||
// empty
|
||||
}
|
@@ -1,83 +0,0 @@
|
||||
|
||||
// Local-Hyperion includes
|
||||
#include <hyperion/BlackBorderProcessor.h>
|
||||
|
||||
using namespace hyperion;
|
||||
|
||||
BlackBorderProcessor::BlackBorderProcessor(const unsigned unknownFrameCnt,
|
||||
const unsigned borderFrameCnt,
|
||||
const unsigned blurRemoveCnt,
|
||||
uint8_t blackborderThreshold) :
|
||||
_unknownSwitchCnt(unknownFrameCnt),
|
||||
_borderSwitchCnt(borderFrameCnt),
|
||||
_blurRemoveCnt(blurRemoveCnt),
|
||||
_detector(blackborderThreshold),
|
||||
_currentBorder({true, -1, -1}),
|
||||
_previousDetectedBorder({true, -1, -1}),
|
||||
_consistentCnt(0)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
BlackBorder BlackBorderProcessor::getCurrentBorder() const
|
||||
{
|
||||
return _currentBorder;
|
||||
}
|
||||
|
||||
bool BlackBorderProcessor::updateBorder(const BlackBorder & newDetectedBorder)
|
||||
{
|
||||
// set the consistency counter
|
||||
if (newDetectedBorder == _previousDetectedBorder)
|
||||
{
|
||||
++_consistentCnt;
|
||||
}
|
||||
else
|
||||
{
|
||||
_previousDetectedBorder = newDetectedBorder;
|
||||
_consistentCnt = 0;
|
||||
}
|
||||
|
||||
// check if there is a change
|
||||
if (_currentBorder == 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 (_consistentCnt == _unknownSwitchCnt)
|
||||
{
|
||||
_currentBorder = newDetectedBorder;
|
||||
borderChanged = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// apply the detected border if it has been detected consistently
|
||||
if (_currentBorder.unknown || _consistentCnt == _borderSwitchCnt)
|
||||
{
|
||||
_currentBorder = newDetectedBorder;
|
||||
borderChanged = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// apply smaller borders immediately
|
||||
if (newDetectedBorder.verticalSize < _currentBorder.verticalSize)
|
||||
{
|
||||
_currentBorder.verticalSize = newDetectedBorder.verticalSize;
|
||||
borderChanged = true;
|
||||
}
|
||||
|
||||
if (newDetectedBorder.horizontalSize < _currentBorder.horizontalSize)
|
||||
{
|
||||
_currentBorder.horizontalSize = newDetectedBorder.horizontalSize;
|
||||
borderChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return borderChanged;
|
||||
}
|
@@ -17,9 +17,6 @@ SET(Hyperion_HEADERS
|
||||
${CURRENT_HEADER_DIR}/LedString.h
|
||||
${CURRENT_HEADER_DIR}/PriorityMuxer.h
|
||||
|
||||
${CURRENT_HEADER_DIR}/BlackBorderDetector.h
|
||||
${CURRENT_HEADER_DIR}/BlackBorderProcessor.h
|
||||
|
||||
${CURRENT_SOURCE_DIR}/MultiColorTransform.h
|
||||
)
|
||||
|
||||
@@ -30,8 +27,6 @@ SET(Hyperion_SOURCES
|
||||
${CURRENT_SOURCE_DIR}/LedString.cpp
|
||||
${CURRENT_SOURCE_DIR}/PriorityMuxer.cpp
|
||||
|
||||
${CURRENT_SOURCE_DIR}/BlackBorderDetector.cpp
|
||||
${CURRENT_SOURCE_DIR}/BlackBorderProcessor.cpp
|
||||
${CURRENT_SOURCE_DIR}/ImageToLedsMap.cpp
|
||||
${CURRENT_SOURCE_DIR}/MultiColorTransform.cpp
|
||||
${CURRENT_SOURCE_DIR}/LinearColorSmoothing.cpp
|
||||
@@ -54,6 +49,7 @@ add_library(hyperion
|
||||
)
|
||||
|
||||
target_link_libraries(hyperion
|
||||
blackborder
|
||||
hyperion-utils
|
||||
leddevice
|
||||
effectengine
|
||||
|
@@ -2,7 +2,9 @@
|
||||
// Hyperion includes
|
||||
#include <hyperion/ImageProcessor.h>
|
||||
#include <hyperion/ImageToLedsMap.h>
|
||||
#include <hyperion/BlackBorderProcessor.h>
|
||||
|
||||
// Blacborder includes
|
||||
#include <blackborder/BlackBorderProcessor.h>
|
||||
|
||||
using namespace hyperion;
|
||||
|
||||
|
Reference in New Issue
Block a user