mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Merge pull request #119 from redPanther/bb_enable
make "enable" work for blackborder detector
This commit is contained in:
commit
5432aa7d27
@ -34,6 +34,18 @@ namespace hyperion
|
|||||||
///
|
///
|
||||||
BlackBorder getCurrentBorder() const;
|
BlackBorder getCurrentBorder() const;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Return activation state of black border detector
|
||||||
|
/// @return The current border
|
||||||
|
///
|
||||||
|
bool enabled() const;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set activation state of black border detector
|
||||||
|
/// @param enable current state
|
||||||
|
///
|
||||||
|
void setEnabled(bool enable);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Processes the image. This performs detecion of black-border on the given image and
|
/// Processes the image. This performs detecion of black-border on the given image and
|
||||||
/// updates the current border accordingly. If the current border is updated the method call
|
/// updates the current border accordingly. If the current border is updated the method call
|
||||||
@ -48,6 +60,11 @@ namespace hyperion
|
|||||||
{
|
{
|
||||||
// get the border for the single image
|
// get the border for the single image
|
||||||
BlackBorder imageBorder;
|
BlackBorder imageBorder;
|
||||||
|
if (!enabled())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (_detectionMode == "default") {
|
if (_detectionMode == "default") {
|
||||||
imageBorder = _detector.process(image);
|
imageBorder = _detector.process(image);
|
||||||
} else if (_detectionMode == "classic") {
|
} else if (_detectionMode == "classic") {
|
||||||
@ -69,7 +86,6 @@ namespace hyperion
|
|||||||
return borderUpdated;
|
return borderUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
///
|
///
|
||||||
/// Updates the current border based on the newly detected border. Returns true if the
|
/// Updates the current border based on the newly detected border. Returns true if the
|
||||||
@ -80,6 +96,9 @@ namespace hyperion
|
|||||||
///
|
///
|
||||||
bool updateBorder(const BlackBorder & newDetectedBorder);
|
bool updateBorder(const BlackBorder & newDetectedBorder);
|
||||||
|
|
||||||
|
/// flag for blackborder detector usage
|
||||||
|
bool _enabled;
|
||||||
|
|
||||||
/// 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;
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ public:
|
|||||||
void setSize(const unsigned width, const unsigned height);
|
void setSize(const unsigned width, const unsigned height);
|
||||||
|
|
||||||
/// Enable or disable the black border detector
|
/// Enable or disable the black border detector
|
||||||
void enableBalckBorderDetector(bool enable);
|
void enableBlackBorderDetector(bool enable);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Processes the image to a list of led colors. This will update the size of the buffer-image
|
/// Processes the image to a list of led colors. This will update the size of the buffer-image
|
||||||
@ -117,7 +117,7 @@ private:
|
|||||||
template <typename Pixel_T>
|
template <typename Pixel_T>
|
||||||
void verifyBorder(const Image<Pixel_T> & image)
|
void verifyBorder(const Image<Pixel_T> & image)
|
||||||
{
|
{
|
||||||
if(_enableBlackBorderRemoval && _borderProcessor->process(image))
|
if(_borderProcessor->enabled() && _borderProcessor->process(image))
|
||||||
{
|
{
|
||||||
Debug(Logger::getInstance("BLACKBORDER"), "BORDER SWITCH REQUIRED!!");
|
Debug(Logger::getInstance("BLACKBORDER"), "BORDER SWITCH REQUIRED!!");
|
||||||
|
|
||||||
@ -146,9 +146,6 @@ private:
|
|||||||
/// The Led-string specification
|
/// The Led-string specification
|
||||||
const LedString _ledString;
|
const LedString _ledString;
|
||||||
|
|
||||||
/// Flag the enables(true)/disabled(false) blackborder detector
|
|
||||||
bool _enableBlackBorderRemoval;
|
|
||||||
|
|
||||||
/// The processor for black border detection
|
/// The processor for black border detection
|
||||||
hyperion::BlackBorderProcessor * _borderProcessor;
|
hyperion::BlackBorderProcessor * _borderProcessor;
|
||||||
|
|
||||||
|
@ -9,7 +9,8 @@
|
|||||||
using namespace hyperion;
|
using namespace hyperion;
|
||||||
|
|
||||||
BlackBorderProcessor::BlackBorderProcessor(const Json::Value &blackborderConfig)
|
BlackBorderProcessor::BlackBorderProcessor(const Json::Value &blackborderConfig)
|
||||||
: _unknownSwitchCnt(blackborderConfig.get("unknownFrameCnt", 600).asUInt())
|
: _enabled(blackborderConfig.get("enable", true).asBool())
|
||||||
|
, _unknownSwitchCnt(blackborderConfig.get("unknownFrameCnt", 600).asUInt())
|
||||||
, _borderSwitchCnt(blackborderConfig.get("borderFrameCnt", 50).asUInt())
|
, _borderSwitchCnt(blackborderConfig.get("borderFrameCnt", 50).asUInt())
|
||||||
, _maxInconsistentCnt(blackborderConfig.get("maxInconsistentCnt", 10).asUInt())
|
, _maxInconsistentCnt(blackborderConfig.get("maxInconsistentCnt", 10).asUInt())
|
||||||
, _blurRemoveCnt(blackborderConfig.get("blurRemoveCnt", 1).asUInt())
|
, _blurRemoveCnt(blackborderConfig.get("blurRemoveCnt", 1).asUInt())
|
||||||
@ -20,7 +21,10 @@ BlackBorderProcessor::BlackBorderProcessor(const Json::Value &blackborderConfig)
|
|||||||
, _consistentCnt(0)
|
, _consistentCnt(0)
|
||||||
, _inconsistentCnt(10)
|
, _inconsistentCnt(10)
|
||||||
{
|
{
|
||||||
|
if (_enabled)
|
||||||
|
{
|
||||||
Debug(Logger::getInstance("BLACKBORDER"), "mode: %s", _detectionMode.c_str());
|
Debug(Logger::getInstance("BLACKBORDER"), "mode: %s", _detectionMode.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BlackBorder BlackBorderProcessor::getCurrentBorder() const
|
BlackBorder BlackBorderProcessor::getCurrentBorder() const
|
||||||
@ -28,6 +32,16 @@ BlackBorder BlackBorderProcessor::getCurrentBorder() const
|
|||||||
return _currentBorder;
|
return _currentBorder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BlackBorderProcessor::enabled() const
|
||||||
|
{
|
||||||
|
return _enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BlackBorderProcessor::setEnabled(bool enable)
|
||||||
|
{
|
||||||
|
_enabled = enable;
|
||||||
|
}
|
||||||
|
|
||||||
bool BlackBorderProcessor::updateBorder(const BlackBorder & newDetectedBorder)
|
bool BlackBorderProcessor::updateBorder(const BlackBorder & newDetectedBorder)
|
||||||
{
|
{
|
||||||
// the new changes ignore false small borders (no reset of consistance)
|
// the new changes ignore false small borders (no reset of consistance)
|
||||||
|
@ -66,7 +66,7 @@ Effect::Effect(PyThreadState * mainThreadState, int priority, int timeout, const
|
|||||||
_colors.resize(_imageProcessor->getLedCount(), ColorRgb::BLACK);
|
_colors.resize(_imageProcessor->getLedCount(), ColorRgb::BLACK);
|
||||||
|
|
||||||
// disable the black border detector for effects
|
// disable the black border detector for effects
|
||||||
_imageProcessor->enableBalckBorderDetector(false);
|
_imageProcessor->enableBlackBorderDetector(false);
|
||||||
|
|
||||||
// connect the finished signal
|
// connect the finished signal
|
||||||
connect(this, SIGNAL(finished()), this, SLOT(effectFinished()));
|
connect(this, SIGNAL(finished()), this, SLOT(effectFinished()));
|
||||||
|
@ -11,7 +11,6 @@ using namespace hyperion;
|
|||||||
//ImageProcessor::ImageProcessor(const LedString& ledString, bool enableBlackBorderDetector, uint8_t blackborderThreshold) :
|
//ImageProcessor::ImageProcessor(const LedString& ledString, bool enableBlackBorderDetector, uint8_t blackborderThreshold) :
|
||||||
ImageProcessor::ImageProcessor(const LedString& ledString, const Json::Value & blackborderConfig) :
|
ImageProcessor::ImageProcessor(const LedString& ledString, const Json::Value & blackborderConfig) :
|
||||||
_ledString(ledString),
|
_ledString(ledString),
|
||||||
_enableBlackBorderRemoval(blackborderConfig.get("enable", true).asBool()),
|
|
||||||
_borderProcessor(new BlackBorderProcessor(blackborderConfig) ),
|
_borderProcessor(new BlackBorderProcessor(blackborderConfig) ),
|
||||||
_imageToLeds(nullptr)
|
_imageToLeds(nullptr)
|
||||||
{
|
{
|
||||||
@ -44,9 +43,9 @@ void ImageProcessor::setSize(const unsigned width, const unsigned height)
|
|||||||
_imageToLeds = new ImageToLedsMap(width, height, 0, 0, _ledString.leds());
|
_imageToLeds = new ImageToLedsMap(width, height, 0, 0, _ledString.leds());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageProcessor::enableBalckBorderDetector(bool enable)
|
void ImageProcessor::enableBlackBorderDetector(bool enable)
|
||||||
{
|
{
|
||||||
_enableBlackBorderRemoval = enable;
|
_borderProcessor->setEnabled(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImageProcessor::getScanParameters(size_t led, double &hscanBegin, double &hscanEnd, double &vscanBegin, double &vscanEnd) const
|
bool ImageProcessor::getScanParameters(size_t led, double &hscanBegin, double &hscanEnd, double &vscanBegin, double &vscanEnd) const
|
||||||
|
Loading…
Reference in New Issue
Block a user