bugfix, config enhancement and 3 detection modes

Former-commit-id: edfc3e7ccf7b7d727e73a8563acb521045026d5b
This commit is contained in:
wisc
2016-02-07 13:26:40 +01:00
parent 6b052081f7
commit 2b703de669
11 changed files with 213 additions and 60 deletions

View File

@@ -282,8 +282,8 @@ Hyperion::Hyperion(const Json::Value &jsonConfig) :
// initialize the image processor factory
ImageProcessorFactory::getInstance().init(
_ledString,
jsonConfig["blackborderdetector"].get("enable", true).asBool(),
jsonConfig["blackborderdetector"].get("threshold", 0.01).asDouble());
jsonConfig["blackborderdetector"]
);
// initialize the color smoothing filter
_device = createColorSmoothing(jsonConfig["color"]["smoothing"], _device);

View File

@@ -8,10 +8,11 @@
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) :
_ledString(ledString),
_enableBlackBorderRemoval(enableBlackBorderDetector),
_borderProcessor(new BlackBorderProcessor(600, 50, 1, blackborderThreshold)),
_enableBlackBorderRemoval(blackborderConfig.get("enable", true).asBool()),
_borderProcessor(new BlackBorderProcessor(blackborderConfig) ),
_imageToLeds(nullptr)
{
// empty

View File

@@ -13,25 +13,13 @@ ImageProcessorFactory& ImageProcessorFactory::getInstance()
return instance;
}
void ImageProcessorFactory::init(const LedString& ledString, bool enableBlackBorderDetector, double blackborderThreshold)
void ImageProcessorFactory::init(const LedString& ledString, const Json::Value & blackborderConfig)
{
_ledString = ledString;
_enableBlackBorderDetector = enableBlackBorderDetector;
int threshold = int(std::ceil(blackborderThreshold * 255));
if (threshold < 0)
threshold = 0;
else if (threshold > 255)
threshold = 255;
_blackborderThreshold = uint8_t(threshold);
if (_enableBlackBorderDetector)
{
std::cout << "Black border threshold set to " << blackborderThreshold << " (" << int(_blackborderThreshold) << ")" << std::endl;
}
_blackborderConfig = blackborderConfig;
}
ImageProcessor* ImageProcessorFactory::newImageProcessor() const
{
return new ImageProcessor(_ledString, _enableBlackBorderDetector, _blackborderThreshold);
return new ImageProcessor(_ledString, _blackborderConfig);
}