mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Merge remote-tracking branch 'refs/remotes/tvdzwan/master'
# Conflicts: # include/hyperion/Hyperion.h # libsrc/hyperion/CMakeLists.txt # libsrc/hyperion/Hyperion.cpp Former-commit-id: 1144520581d4531952038d2118cb11e01bebc10e
This commit is contained in:
@@ -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
|
||||
|
@@ -1,7 +1,3 @@
|
||||
|
||||
// STL includes
|
||||
#include <cmath>
|
||||
|
||||
// Hyperion includes
|
||||
#include <hyperion/ImageProcessorFactory.h>
|
||||
#include <hyperion/ImageProcessor.h>
|
||||
@@ -13,25 +9,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);
|
||||
}
|
||||
|
51
libsrc/hyperion/MessageForwarder.cpp
Normal file
51
libsrc/hyperion/MessageForwarder.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
// STL includes
|
||||
#include <stdexcept>
|
||||
|
||||
#include <hyperion/MessageForwarder.h>
|
||||
|
||||
|
||||
MessageForwarder::MessageForwarder()
|
||||
{
|
||||
}
|
||||
|
||||
MessageForwarder::~MessageForwarder()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void MessageForwarder::addJsonSlave(std::string slave)
|
||||
{
|
||||
QStringList parts = QString(slave.c_str()).split(":");
|
||||
if (parts.size() != 2)
|
||||
throw std::runtime_error(QString("Wrong address: unable to parse address (%1)").arg(slave.c_str()).toStdString());
|
||||
|
||||
bool ok;
|
||||
quint16 port = parts[1].toUShort(&ok);
|
||||
if (!ok)
|
||||
throw std::runtime_error(QString("Wrong address: Unable to parse the port number (%1)").arg(parts[1]).toStdString());
|
||||
|
||||
JsonSlaveAddress c;
|
||||
c.addr = QHostAddress(parts[0]);
|
||||
c.port = port;
|
||||
_jsonSlaves << c;
|
||||
}
|
||||
|
||||
void MessageForwarder::addProtoSlave(std::string slave)
|
||||
{
|
||||
_protoSlaves << QString(slave.c_str());
|
||||
}
|
||||
|
||||
QStringList MessageForwarder::getProtoSlaves()
|
||||
{
|
||||
return _protoSlaves;
|
||||
}
|
||||
|
||||
QList<MessageForwarder::JsonSlaveAddress> MessageForwarder::getJsonSlaves()
|
||||
{
|
||||
return _jsonSlaves;
|
||||
}
|
||||
|
||||
bool MessageForwarder::protoForwardingEnabled()
|
||||
{
|
||||
return ! _protoSlaves.empty();
|
||||
}
|
Reference in New Issue
Block a user