JsonCpp to QTJson (Part 3) (#257)

* Update BlackBorderProcessor.h

* Update Hyperion.h

* Update ImageProcessor.h

* Update ImageProcessorFactory.h

* Update LedString.h

* Update BlackBorderProcessor.cpp

* Update ImageProcessor.cpp

* Update ImageProcessorFactory.cpp

* Update Hyperion.cpp

* Update hyperiond.cpp

* Update TestImage2LedsMap.cpp

* Update TestBlackBorderProcessor.cpp

* Update Hyperion.cpp

* Update Hyperion.cpp
This commit is contained in:
Paulchen Panther 2016-09-25 21:59:31 +02:00 committed by redPanther
parent d6a34edfb2
commit f146894799
12 changed files with 212 additions and 180 deletions

View File

@ -1,8 +1,8 @@
#pragma once #pragma once
// Jsoncpp includes // QT includes
#include <json/json.h> #include <QJsonObject>
// Local Hyperion includes // Local Hyperion includes
#include "BlackBorderDetector.h" #include "BlackBorderDetector.h"
@ -26,7 +26,7 @@ namespace hyperion
/// outer pixels is blurred (black and color combined due to image scaling)) /// outer pixels is blurred (black and color combined due to image scaling))
/// @param[in] blackborderThreshold The threshold which the blackborder detector should use /// @param[in] blackborderThreshold The threshold which the blackborder detector should use
/// ///
BlackBorderProcessor(const Json::Value &blackborderConfig); BlackBorderProcessor(const QJsonObject &blackborderConfig);
/// ///
/// Return the current (detected) border /// Return the current (detected) border

View File

@ -8,6 +8,9 @@
#include <QObject> #include <QObject>
#include <QTimer> #include <QTimer>
#include <QSize> #include <QSize>
#include <QJsonObject>
#include <QJsonValue>
#include <QJsonArray>
// hyperion-utils includes // hyperion-utils includes
#include <utils/Image.h> #include <utils/Image.h>
@ -79,7 +82,7 @@ public:
~Hyperion(); ~Hyperion();
static Hyperion* initInstance(const Json::Value& jsonConfig, const std::string configFile); static Hyperion* initInstance(const Json::Value& jsonConfig, const QJsonObject& qjsonConfig, const std::string configFile);
static Hyperion* getInstance(); static Hyperion* getInstance();
/// ///
@ -270,7 +273,7 @@ public slots:
public: public:
static Hyperion *_hyperion; static Hyperion *_hyperion;
static ColorOrder createColorOrder(const Json::Value & deviceConfig); static ColorOrder createColorOrder(const QJsonObject & deviceConfig);
/** /**
* Construct the 'led-string' with the integration area definition per led and the color * Construct the 'led-string' with the integration area definition per led and the color
* ordering of the RGB channels * ordering of the RGB channels
@ -278,24 +281,24 @@ public:
* @param deviceOrder The default RGB channel ordering * @param deviceOrder The default RGB channel ordering
* @return The constructed ledstring * @return The constructed ledstring
*/ */
static LedString createLedString(const Json::Value & ledsConfig, const ColorOrder deviceOrder); static LedString createLedString(const QJsonValue & ledsConfig, const ColorOrder deviceOrder);
static LedString createLedStringClone(const Json::Value & ledsConfig, const ColorOrder deviceOrder); static LedString createLedStringClone(const QJsonValue & ledsConfig, const ColorOrder deviceOrder);
static MultiColorTransform * createLedColorsTransform(const unsigned ledCnt, const Json::Value & colorTransformConfig); static MultiColorTransform * createLedColorsTransform(const unsigned ledCnt, const QJsonObject & colorTransformConfig);
static MultiColorCorrection * createLedColorsTemperature(const unsigned ledCnt, const Json::Value & colorTemperatureConfig); static MultiColorCorrection * createLedColorsTemperature(const unsigned ledCnt, const QJsonObject & colorTemperatureConfig);
static MultiColorAdjustment * createLedColorsAdjustment(const unsigned ledCnt, const Json::Value & colorAdjustmentConfig); static MultiColorAdjustment * createLedColorsAdjustment(const unsigned ledCnt, const QJsonObject & colorAdjustmentConfig);
static ColorTransform * createColorTransform(const Json::Value & transformConfig); static ColorTransform * createColorTransform(const QJsonObject & transformConfig);
static ColorCorrection * createColorCorrection(const Json::Value & correctionConfig); static ColorCorrection * createColorCorrection(const QJsonObject & correctionConfig);
static ColorAdjustment * createColorAdjustment(const Json::Value & adjustmentConfig); static ColorAdjustment * createColorAdjustment(const QJsonObject & adjustmentConfig);
static HsvTransform * createHsvTransform(const Json::Value & hsvConfig); static HsvTransform * createHsvTransform(const QJsonObject & hsvConfig);
static HslTransform * createHslTransform(const Json::Value & hslConfig); static HslTransform * createHslTransform(const QJsonObject & hslConfig);
static RgbChannelTransform * createRgbChannelTransform(const Json::Value& colorConfig); static RgbChannelTransform * createRgbChannelTransform(const QJsonObject& colorConfig);
static RgbChannelAdjustment * createRgbChannelCorrection(const Json::Value& colorConfig); static RgbChannelAdjustment * createRgbChannelCorrection(const QJsonObject& colorConfig);
static RgbChannelAdjustment * createRgbChannelAdjustment(const Json::Value& colorConfig, const RgbChannel color); static RgbChannelAdjustment * createRgbChannelAdjustment(const QJsonObject& colorConfig, const RgbChannel color);
static LinearColorSmoothing * createColorSmoothing(const Json::Value & smoothingConfig, LedDevice* leddevice); static LinearColorSmoothing * createColorSmoothing(const QJsonObject & smoothingConfig, LedDevice* leddevice);
static MessageForwarder * createMessageForwarder(const Json::Value & forwarderConfig); static MessageForwarder * createMessageForwarder(const QJsonObject & forwarderConfig);
static QSize getLedLayoutGridSize(const Json::Value& ledsConfig); static QSize getLedLayoutGridSize(const QJsonValue& ledsConfig);
signals: signals:
/// Signal which is emitted when a priority channel is actively cleared /// Signal which is emitted when a priority channel is actively cleared
@ -322,7 +325,7 @@ private:
/// ///
/// @param[in] jsonConfig The Json configuration /// @param[in] jsonConfig The Json configuration
/// ///
Hyperion(const Json::Value& jsonConfig, const std::string configFile); Hyperion(const Json::Value& jsonConfig, const QJsonObject& qjsonConfig, const std::string configFile);
/// The specifiation of the led frame construction and picture integration /// The specifiation of the led frame construction and picture integration
LedString _ledString; LedString _ledString;

View File

@ -109,7 +109,7 @@ private:
/// @param[in] ledString The led-string specification /// @param[in] ledString The led-string specification
/// @param[in] blackborderThreshold The threshold which the blackborder detector should use /// @param[in] blackborderThreshold The threshold which the blackborder detector should use
/// ///
ImageProcessor(const LedString &ledString, const Json::Value &blackborderConfig); ImageProcessor(const LedString &ledString, const QJsonObject &blackborderConfig);
/// ///
/// Performs black-border detection (if enabled) on the given image /// Performs black-border detection (if enabled) on the given image

View File

@ -3,6 +3,14 @@
// STL includes // STL includes
#include <memory> #include <memory>
// QT includes
#include <QJsonObject>
// if (jsoncpp_converted_to_QtJSON)
// {
// remove("#include <json/json.h>");
// }
// Jsoncpp includes // Jsoncpp includes
#include <json/json.h> #include <json/json.h>
@ -33,7 +41,7 @@ public:
/// @param[in] enableBlackBorderDetector Flag indicating if the blacborder detector should be enabled /// @param[in] enableBlackBorderDetector Flag indicating if the blacborder detector should be enabled
/// @param[in] blackborderThreshold The threshold which the blackborder detector should use /// @param[in] blackborderThreshold The threshold which the blackborder detector should use
/// ///
void init(const LedString& ledString, const Json::Value &blackborderConfig); void init(const LedString& ledString, const QJsonObject &blackborderConfig);
/// ///
/// Creates a new ImageProcessor. The onwership of the processor is transferred to the caller. /// Creates a new ImageProcessor. The onwership of the processor is transferred to the caller.
@ -47,5 +55,5 @@ private:
LedString _ledString; LedString _ledString;
// Reference to the blackborder json configuration values // Reference to the blackborder json configuration values
Json::Value _blackborderConfig; QJsonObject _blackborderConfig;
}; };

View File

@ -9,6 +9,9 @@
// Local includes // Local includes
#include <utils/ColorRgb.h> #include <utils/ColorRgb.h>
// QT includes
#include <QString>
// Forward class declarations // Forward class declarations
namespace Json { class Value; } namespace Json { class Value; }
@ -18,7 +21,7 @@ enum ColorOrder
ORDER_RGB, ORDER_RBG, ORDER_GRB, ORDER_BRG, ORDER_GBR, ORDER_BGR ORDER_RGB, ORDER_RBG, ORDER_GRB, ORDER_BRG, ORDER_GBR, ORDER_BGR
}; };
inline std::string colorOrderToString(const ColorOrder colorOrder) inline QString colorOrderToString(const ColorOrder colorOrder)
{ {
switch (colorOrder) switch (colorOrder)
{ {
@ -38,7 +41,7 @@ inline std::string colorOrderToString(const ColorOrder colorOrder)
return "not-a-colororder"; return "not-a-colororder";
} }
} }
inline ColorOrder stringToColorOrder(const std::string & order) inline ColorOrder stringToColorOrder(const QString & order)
{ {
if (order == "rgb") if (order == "rgb")
{ {
@ -65,7 +68,7 @@ inline ColorOrder stringToColorOrder(const std::string & order)
return ORDER_GRB; return ORDER_GRB;
} }
std::cout << "Unknown color order defined (" << order << "). Using RGB." << std::endl; std::cout << "Unknown color order defined (" << order.toStdString() << "). Using RGB." << std::endl;
return ORDER_RGB; return ORDER_RGB;
} }

View File

@ -8,14 +8,14 @@
using namespace hyperion; using namespace hyperion;
BlackBorderProcessor::BlackBorderProcessor(const Json::Value &blackborderConfig) BlackBorderProcessor::BlackBorderProcessor(const QJsonObject &blackborderConfig)
: _enabled(blackborderConfig.get("enable", true).asBool()) : _enabled(blackborderConfig["enable"].toBool(true))
, _unknownSwitchCnt(blackborderConfig.get("unknownFrameCnt", 600).asUInt()) , _unknownSwitchCnt(blackborderConfig["unknownFrameCnt"].toInt(600))
, _borderSwitchCnt(blackborderConfig.get("borderFrameCnt", 50).asUInt()) , _borderSwitchCnt(blackborderConfig["borderFrameCnt"].toInt(50))
, _maxInconsistentCnt(blackborderConfig.get("maxInconsistentCnt", 10).asUInt()) , _maxInconsistentCnt(blackborderConfig["maxInconsistentCnt"].toInt(10))
, _blurRemoveCnt(blackborderConfig.get("blurRemoveCnt", 1).asUInt()) , _blurRemoveCnt(blackborderConfig["blurRemoveCnt"].toInt(1))
, _detectionMode(blackborderConfig.get("mode", "default").asString()) , _detectionMode(blackborderConfig["mode"].toString("default").toStdString())
, _detector(blackborderConfig.get("threshold", 0.01).asDouble()) , _detector(blackborderConfig["threshold"].toDouble(0.01))
, _currentBorder({true, -1, -1}) , _currentBorder({true, -1, -1})
, _previousDetectedBorder({true, -1, -1}) , _previousDetectedBorder({true, -1, -1})
, _consistentCnt(0) , _consistentCnt(0)

View File

@ -37,11 +37,11 @@
Hyperion* Hyperion::_hyperion = nullptr; Hyperion* Hyperion::_hyperion = nullptr;
Hyperion* Hyperion::initInstance(const Json::Value& jsonConfig, const std::string configFile) Hyperion* Hyperion::initInstance(const Json::Value& jsonConfig, const QJsonObject& qjsonConfig, const std::string configFile) // REMOVE jsonConfig variable when the conversion from jsonCPP to QtJSON is finished
{ {
if ( Hyperion::_hyperion != nullptr ) if ( Hyperion::_hyperion != nullptr )
throw std::runtime_error("Hyperion::initInstance can be called only one time"); throw std::runtime_error("Hyperion::initInstance can be called only one time");
Hyperion::_hyperion = new Hyperion(jsonConfig,configFile); Hyperion::_hyperion = new Hyperion(jsonConfig, qjsonConfig, configFile);
return Hyperion::_hyperion; return Hyperion::_hyperion;
} }
@ -54,21 +54,21 @@ Hyperion* Hyperion::getInstance()
return Hyperion::_hyperion; return Hyperion::_hyperion;
} }
ColorOrder Hyperion::createColorOrder(const Json::Value &deviceConfig) ColorOrder Hyperion::createColorOrder(const QJsonObject &deviceConfig)
{ {
return stringToColorOrder( deviceConfig.get("colorOrder", "rgb").asString() ); return stringToColorOrder(deviceConfig["colorOrder"].toString("rgb"));
} }
ColorTransform * Hyperion::createColorTransform(const Json::Value & transformConfig) ColorTransform * Hyperion::createColorTransform(const QJsonObject & transformConfig)
{ {
const std::string id = transformConfig.get("id", "default").asString(); const std::string id = transformConfig["id"].toString("default").toStdString();
RgbChannelTransform * redTransform = createRgbChannelTransform(transformConfig["red"]); RgbChannelTransform * redTransform = createRgbChannelTransform(transformConfig["red"].toObject());
RgbChannelTransform * greenTransform = createRgbChannelTransform(transformConfig["green"]); RgbChannelTransform * greenTransform = createRgbChannelTransform(transformConfig["green"].toObject());
RgbChannelTransform * blueTransform = createRgbChannelTransform(transformConfig["blue"]); RgbChannelTransform * blueTransform = createRgbChannelTransform(transformConfig["blue"].toObject());
HsvTransform * hsvTransform = createHsvTransform(transformConfig["hsv"]); HsvTransform * hsvTransform = createHsvTransform(transformConfig["hsv"].toObject());
HslTransform * hslTransform = createHslTransform(transformConfig["hsl"]); HslTransform * hslTransform = createHslTransform(transformConfig["hsl"].toObject());
ColorTransform * transform = new ColorTransform(); ColorTransform * transform = new ColorTransform();
transform->_id = id; transform->_id = id;
@ -90,11 +90,11 @@ ColorTransform * Hyperion::createColorTransform(const Json::Value & transformCon
} }
ColorCorrection * Hyperion::createColorCorrection(const Json::Value & correctionConfig) ColorCorrection * Hyperion::createColorCorrection(const QJsonObject & correctionConfig)
{ {
const std::string id = correctionConfig.get("id", "default").asString(); const std::string id = correctionConfig["id"].toString("default").toStdString();
RgbChannelAdjustment * rgbCorrection = createRgbChannelCorrection(correctionConfig["correctionValues"]); RgbChannelAdjustment * rgbCorrection = createRgbChannelCorrection(correctionConfig["correctionValues"].toObject());
ColorCorrection * correction = new ColorCorrection(); ColorCorrection * correction = new ColorCorrection();
correction->_id = id; correction->_id = id;
@ -107,13 +107,13 @@ ColorCorrection * Hyperion::createColorCorrection(const Json::Value & correction
} }
ColorAdjustment * Hyperion::createColorAdjustment(const Json::Value & adjustmentConfig) ColorAdjustment * Hyperion::createColorAdjustment(const QJsonObject & adjustmentConfig)
{ {
const std::string id = adjustmentConfig.get("id", "default").asString(); const std::string id = adjustmentConfig["id"].toString("default").toStdString();
RgbChannelAdjustment * redAdjustment = createRgbChannelAdjustment(adjustmentConfig["pureRed"],RED); RgbChannelAdjustment * redAdjustment = createRgbChannelAdjustment(adjustmentConfig["pureRed"].toObject(),RED);
RgbChannelAdjustment * greenAdjustment = createRgbChannelAdjustment(adjustmentConfig["pureGreen"],GREEN); RgbChannelAdjustment * greenAdjustment = createRgbChannelAdjustment(adjustmentConfig["pureGreen"].toObject(),GREEN);
RgbChannelAdjustment * blueAdjustment = createRgbChannelAdjustment(adjustmentConfig["pureBlue"],BLUE); RgbChannelAdjustment * blueAdjustment = createRgbChannelAdjustment(adjustmentConfig["pureBlue"].toObject(),BLUE);
ColorAdjustment * adjustment = new ColorAdjustment(); ColorAdjustment * adjustment = new ColorAdjustment();
adjustment->_id = id; adjustment->_id = id;
@ -130,13 +130,13 @@ ColorAdjustment * Hyperion::createColorAdjustment(const Json::Value & adjustment
} }
MultiColorTransform * Hyperion::createLedColorsTransform(const unsigned ledCnt, const Json::Value & colorConfig) MultiColorTransform * Hyperion::createLedColorsTransform(const unsigned ledCnt, const QJsonObject & colorConfig)
{ {
// Create the result, the transforms are added to this // Create the result, the transforms are added to this
MultiColorTransform * transform = new MultiColorTransform(ledCnt); MultiColorTransform * transform = new MultiColorTransform(ledCnt);
Logger * log = Logger::getInstance("Core"); Logger * log = Logger::getInstance("Core");
const Json::Value transformConfig = colorConfig.get("transform", Json::nullValue); const QJsonValue transformConfig = colorConfig["transform"];
if (transformConfig.isNull()) if (transformConfig.isNull())
{ {
// Old style color transformation config (just one for all leds) // Old style color transformation config (just one for all leds)
@ -144,23 +144,24 @@ MultiColorTransform * Hyperion::createLedColorsTransform(const unsigned ledCnt,
transform->addTransform(colorTransform); transform->addTransform(colorTransform);
transform->setTransformForLed(colorTransform->_id, 0, ledCnt-1); transform->setTransformForLed(colorTransform->_id, 0, ledCnt-1);
} }
else if (!transformConfig.isArray()) else if (transformConfig.isObject())
{ {
ColorTransform * colorTransform = createColorTransform(transformConfig); ColorTransform * colorTransform = createColorTransform(transformConfig.toObject());
transform->addTransform(colorTransform); transform->addTransform(colorTransform);
transform->setTransformForLed(colorTransform->_id, 0, ledCnt-1); transform->setTransformForLed(colorTransform->_id, 0, ledCnt-1);
} }
else else if (transformConfig.isArray())
{ {
const QRegExp overallExp("([0-9]+(\\-[0-9]+)?)(,[ ]*([0-9]+(\\-[0-9]+)?))*"); const QRegExp overallExp("([0-9]+(\\-[0-9]+)?)(,[ ]*([0-9]+(\\-[0-9]+)?))*");
for (Json::UInt i = 0; i < transformConfig.size(); ++i) const QJsonArray & transformConfigArray = transformConfig.toArray();
for (signed i = 0; i < transformConfigArray.size(); ++i)
{ {
const Json::Value & config = transformConfig[i]; const QJsonObject & config = transformConfigArray[i].toObject();
ColorTransform * colorTransform = createColorTransform(config); ColorTransform * colorTransform = createColorTransform(config);
transform->addTransform(colorTransform); transform->addTransform(colorTransform);
const QString ledIndicesStr = QString(config.get("leds", "").asCString()).trimmed(); const QString ledIndicesStr = config["leds"].toString("").trimmed();
if (ledIndicesStr.compare("*") == 0) if (ledIndicesStr.compare("*") == 0)
{ {
// Special case for indices '*' => all leds // Special case for indices '*' => all leds
@ -204,14 +205,14 @@ MultiColorTransform * Hyperion::createLedColorsTransform(const unsigned ledCnt,
return transform; return transform;
} }
MultiColorCorrection * Hyperion::createLedColorsTemperature(const unsigned ledCnt, const Json::Value & colorConfig) MultiColorCorrection * Hyperion::createLedColorsTemperature(const unsigned ledCnt, const QJsonObject & colorConfig)
{ {
// Create the result, the corrections are added to this // Create the result, the corrections are added to this
MultiColorCorrection * correction = new MultiColorCorrection(ledCnt); MultiColorCorrection * correction = new MultiColorCorrection(ledCnt);
Logger * log = Logger::getInstance("Core"); Logger * log = Logger::getInstance("Core");
const std::string jsonKey = colorConfig.isMember("temperature") ? "temperature" : "correction"; const QString jsonKey = colorConfig.contains("temperature") ? "temperature" : "correction";
const Json::Value correctionConfig = colorConfig.get(jsonKey, Json::nullValue); const QJsonValue correctionConfig = colorConfig[jsonKey];
if (correctionConfig.isNull()) if (correctionConfig.isNull())
{ {
// Old style color correction config (just one for all leds) // Old style color correction config (just one for all leds)
@ -219,23 +220,24 @@ MultiColorCorrection * Hyperion::createLedColorsTemperature(const unsigned ledCn
correction->addCorrection(colorCorrection); correction->addCorrection(colorCorrection);
correction->setCorrectionForLed(colorCorrection->_id, 0, ledCnt-1); correction->setCorrectionForLed(colorCorrection->_id, 0, ledCnt-1);
} }
else if (!correctionConfig.isArray()) else if (correctionConfig.isObject())
{ {
ColorCorrection * colorCorrection = createColorCorrection(correctionConfig); ColorCorrection * colorCorrection = createColorCorrection(correctionConfig.toObject());
correction->addCorrection(colorCorrection); correction->addCorrection(colorCorrection);
correction->setCorrectionForLed(colorCorrection->_id, 0, ledCnt-1); correction->setCorrectionForLed(colorCorrection->_id, 0, ledCnt-1);
} }
else else if (correctionConfig.isArray())
{ {
const QRegExp overallExp("([0-9]+(\\-[0-9]+)?)(,[ ]*([0-9]+(\\-[0-9]+)?))*"); const QRegExp overallExp("([0-9]+(\\-[0-9]+)?)(,[ ]*([0-9]+(\\-[0-9]+)?))*");
for (Json::UInt i = 0; i < correctionConfig.size(); ++i) const QJsonArray & correctionConfigArray = correctionConfig.toArray();
for (signed i = 0; i < correctionConfigArray.size(); ++i)
{ {
const Json::Value & config = correctionConfig[i]; const QJsonObject & config = correctionConfigArray.at(i).toObject();
ColorCorrection * colorCorrection = createColorCorrection(config); ColorCorrection * colorCorrection = createColorCorrection(config);
correction->addCorrection(colorCorrection); correction->addCorrection(colorCorrection);
const QString ledIndicesStr = QString(config.get("leds", "").asCString()).trimmed(); const QString ledIndicesStr = config["leds"].toString("").trimmed();
if (ledIndicesStr.compare("*") == 0) if (ledIndicesStr.compare("*") == 0)
{ {
// Special case for indices '*' => all leds // Special case for indices '*' => all leds
@ -280,13 +282,13 @@ MultiColorCorrection * Hyperion::createLedColorsTemperature(const unsigned ledCn
} }
MultiColorAdjustment * Hyperion::createLedColorsAdjustment(const unsigned ledCnt, const Json::Value & colorConfig) MultiColorAdjustment * Hyperion::createLedColorsAdjustment(const unsigned ledCnt, const QJsonObject & colorConfig)
{ {
// Create the result, the transforms are added to this // Create the result, the transforms are added to this
MultiColorAdjustment * adjustment = new MultiColorAdjustment(ledCnt); MultiColorAdjustment * adjustment = new MultiColorAdjustment(ledCnt);
Logger * log = Logger::getInstance("Core"); Logger * log = Logger::getInstance("Core");
const Json::Value adjustmentConfig = colorConfig.get("channelAdjustment", Json::nullValue); const QJsonValue adjustmentConfig = colorConfig["channelAdjustment"];
if (adjustmentConfig.isNull()) if (adjustmentConfig.isNull())
{ {
// Old style color transformation config (just one for all leds) // Old style color transformation config (just one for all leds)
@ -294,23 +296,24 @@ MultiColorAdjustment * Hyperion::createLedColorsAdjustment(const unsigned ledCnt
adjustment->addAdjustment(colorAdjustment); adjustment->addAdjustment(colorAdjustment);
adjustment->setAdjustmentForLed(colorAdjustment->_id, 0, ledCnt-1); adjustment->setAdjustmentForLed(colorAdjustment->_id, 0, ledCnt-1);
} }
else if (!adjustmentConfig.isArray()) else if (adjustmentConfig.isObject())
{ {
ColorAdjustment * colorAdjustment = createColorAdjustment(adjustmentConfig); ColorAdjustment * colorAdjustment = createColorAdjustment(adjustmentConfig.toObject());
adjustment->addAdjustment(colorAdjustment); adjustment->addAdjustment(colorAdjustment);
adjustment->setAdjustmentForLed(colorAdjustment->_id, 0, ledCnt-1); adjustment->setAdjustmentForLed(colorAdjustment->_id, 0, ledCnt-1);
} }
else else if (adjustmentConfig.isArray())
{ {
const QRegExp overallExp("([0-9]+(\\-[0-9]+)?)(,[ ]*([0-9]+(\\-[0-9]+)?))*"); const QRegExp overallExp("([0-9]+(\\-[0-9]+)?)(,[ ]*([0-9]+(\\-[0-9]+)?))*");
for (Json::UInt i = 0; i < adjustmentConfig.size(); ++i) const QJsonArray & adjustmentConfigArray = adjustmentConfig.toArray();
for (signed i = 0; i < adjustmentConfigArray.size(); ++i)
{ {
const Json::Value & config = adjustmentConfig[i]; const QJsonObject & config = adjustmentConfigArray.at(i).toObject();
ColorAdjustment * colorAdjustment = createColorAdjustment(config); ColorAdjustment * colorAdjustment = createColorAdjustment(config);
adjustment->addAdjustment(colorAdjustment); adjustment->addAdjustment(colorAdjustment);
const QString ledIndicesStr = QString(config.get("leds", "").asCString()).trimmed(); const QString ledIndicesStr = config["leds"].toString("").trimmed();
if (ledIndicesStr.compare("*") == 0) if (ledIndicesStr.compare("*") == 0)
{ {
// Special case for indices '*' => all leds // Special case for indices '*' => all leds
@ -354,81 +357,84 @@ MultiColorAdjustment * Hyperion::createLedColorsAdjustment(const unsigned ledCnt
return adjustment; return adjustment;
} }
HsvTransform * Hyperion::createHsvTransform(const Json::Value & hsvConfig) HsvTransform * Hyperion::createHsvTransform(const QJsonObject & hsvConfig)
{ {
const double saturationGain = hsvConfig.get("saturationGain", 1.0).asDouble(); const double saturationGain = hsvConfig["saturationGain"].toDouble(1.0);
const double valueGain = hsvConfig.get("valueGain", 1.0).asDouble(); const double valueGain = hsvConfig["valueGain"].toDouble(1.0);
return new HsvTransform(saturationGain, valueGain); return new HsvTransform(saturationGain, valueGain);
} }
HslTransform * Hyperion::createHslTransform(const Json::Value & hslConfig) HslTransform * Hyperion::createHslTransform(const QJsonObject & hslConfig)
{ {
const double saturationGain = hslConfig.get("saturationGain", 1.0).asDouble(); const double saturationGain = hslConfig["saturationGain"].toDouble(1.0);
const double luminanceGain = hslConfig.get("luminanceGain", 1.0).asDouble(); const double luminanceGain = hslConfig["luminanceGain"].toDouble(1.0);
const double luminanceMinimum = hslConfig.get("luminanceMinimum", 0.0).asDouble(); const double luminanceMinimum = hslConfig["luminanceMinimum"].toDouble(0.0);
return new HslTransform(saturationGain, luminanceGain, luminanceMinimum); return new HslTransform(saturationGain, luminanceGain, luminanceMinimum);
} }
RgbChannelTransform* Hyperion::createRgbChannelTransform(const Json::Value& colorConfig) RgbChannelTransform* Hyperion::createRgbChannelTransform(const QJsonObject& colorConfig)
{ {
const double threshold = colorConfig.get("threshold", 0.0).asDouble(); const double threshold = colorConfig["threshold"].toDouble(0.0);
const double gamma = colorConfig.get("gamma", 1.0).asDouble(); const double gamma = colorConfig["gamma"].toDouble(1.0);
const double blacklevel = colorConfig.get("blacklevel", 0.0).asDouble(); const double blacklevel = colorConfig["blacklevel"].toDouble(0.0);
const double whitelevel = colorConfig.get("whitelevel", 1.0).asDouble(); const double whitelevel = colorConfig["whitelevel"].toDouble(1.0);
RgbChannelTransform* transform = new RgbChannelTransform(threshold, gamma, blacklevel, whitelevel); RgbChannelTransform* transform = new RgbChannelTransform(threshold, gamma, blacklevel, whitelevel);
return transform; return transform;
} }
RgbChannelAdjustment* Hyperion::createRgbChannelCorrection(const Json::Value& colorConfig) RgbChannelAdjustment* Hyperion::createRgbChannelCorrection(const QJsonObject& colorConfig)
{ {
const int varR = colorConfig.get("red", 255).asInt(); const int varR = colorConfig["red"].toInt(255);
const int varG = colorConfig.get("green", 255).asInt(); const int varG = colorConfig["green"].toInt(255);
const int varB = colorConfig.get("blue", 255).asInt(); const int varB = colorConfig["blue"].toInt(255);
RgbChannelAdjustment* correction = new RgbChannelAdjustment(varR, varG, varB); RgbChannelAdjustment* correction = new RgbChannelAdjustment(varR, varG, varB);
return correction; return correction;
} }
RgbChannelAdjustment* Hyperion::createRgbChannelAdjustment(const Json::Value& colorConfig, const RgbChannel color) RgbChannelAdjustment* Hyperion::createRgbChannelAdjustment(const QJsonObject& colorConfig, const RgbChannel color)
{ {
int varR=0, varG=0, varB=0; int varR=0, varG=0, varB=0;
if (color == RED) if (color == RED)
{ {
varR = colorConfig.get("redChannel", 255).asInt(); varR = colorConfig["redChannel"].toInt(255);
varG = colorConfig.get("greenChannel", 0).asInt(); varG = colorConfig["greenChannel"].toInt(0);
varB = colorConfig.get("blueChannel", 0).asInt(); varB = colorConfig["blueChannel"].toInt(0);
} }
else if (color == GREEN) else if (color == GREEN)
{ {
varR = colorConfig.get("redChannel", 0).asInt(); varR = colorConfig["redChannel"].toInt(0);
varG = colorConfig.get("greenChannel", 255).asInt(); varG = colorConfig["greenChannel"].toInt(255);
varB = colorConfig.get("blueChannel", 0).asInt(); varB = colorConfig["blueChannel"].toInt(0);
} }
else if (color == BLUE) else if (color == BLUE)
{ {
varR = colorConfig.get("redChannel", 0).asInt(); varR = colorConfig["redChannel"].toInt(0);
varG = colorConfig.get("greenChannel", 0).asInt(); varG = colorConfig["greenChannel"].toInt(0);
varB = colorConfig.get("blueChannel", 255).asInt(); varB = colorConfig["blueChannel"].toInt(255);
} }
RgbChannelAdjustment* adjustment = new RgbChannelAdjustment(varR, varG, varB); RgbChannelAdjustment* adjustment = new RgbChannelAdjustment(varR, varG, varB);
return adjustment; return adjustment;
} }
LedString Hyperion::createLedString(const Json::Value& ledsConfig, const ColorOrder deviceOrder) LedString Hyperion::createLedString(const QJsonValue& ledsConfig, const ColorOrder deviceOrder)
{ {
LedString ledString; LedString ledString;
const std::string deviceOrderStr = colorOrderToString(deviceOrder); const QString deviceOrderStr = colorOrderToString(deviceOrder);
int maxLedId = ledsConfig.size(); const QJsonArray & ledConfigArray = ledsConfig.toArray();
int maxLedId = ledConfigArray.size();
for (const Json::Value& ledConfig : ledsConfig) for (signed i = 0; i < ledConfigArray.size(); ++i)
{ {
const QJsonObject& index = ledConfigArray[i].toObject();
Led led; Led led;
led.index = ledConfig["index"].asInt(); led.index = index["index"].toInt();
led.clone = ledConfig.get("clone",-1).asInt(); led.clone = index["clone"].toInt(-1);
if ( led.clone < -1 || led.clone >= maxLedId ) if ( led.clone < -1 || led.clone >= maxLedId )
{ {
Warning(Logger::getInstance("Core"), "LED %d: clone index of %d is out of range, clone ignored", led.index, led.clone); Warning(Logger::getInstance("Core"), "LED %d: clone index of %d is out of range, clone ignored", led.index, led.clone);
@ -437,12 +443,12 @@ LedString Hyperion::createLedString(const Json::Value& ledsConfig, const ColorOr
if ( led.clone < 0 ) if ( led.clone < 0 )
{ {
const Json::Value& hscanConfig = ledConfig["hscan"]; const QJsonObject& hscanConfig = ledConfigArray[i].toObject()["hscan"].toObject();
const Json::Value& vscanConfig = ledConfig["vscan"]; const QJsonObject& vscanConfig = ledConfigArray[i].toObject()["vscan"].toObject();
led.minX_frac = std::max(0.0, std::min(1.0, hscanConfig["minimum"].asDouble())); led.minX_frac = std::max(0.0, std::min(1.0, hscanConfig["minimum"].toDouble()));
led.maxX_frac = std::max(0.0, std::min(1.0, hscanConfig["maximum"].asDouble())); led.maxX_frac = std::max(0.0, std::min(1.0, hscanConfig["maximum"].toDouble()));
led.minY_frac = std::max(0.0, std::min(1.0, vscanConfig["minimum"].asDouble())); led.minY_frac = std::max(0.0, std::min(1.0, vscanConfig["minimum"].toDouble()));
led.maxY_frac = std::max(0.0, std::min(1.0, vscanConfig["maximum"].asDouble())); led.maxY_frac = std::max(0.0, std::min(1.0, vscanConfig["maximum"].toDouble()));
// Fix if the user swapped min and max // Fix if the user swapped min and max
if (led.minX_frac > led.maxX_frac) if (led.minX_frac > led.maxX_frac)
{ {
@ -454,7 +460,8 @@ LedString Hyperion::createLedString(const Json::Value& ledsConfig, const ColorOr
} }
// Get the order of the rgb channels for this led (default is device order) // Get the order of the rgb channels for this led (default is device order)
led.colorOrder = stringToColorOrder(ledConfig.get("colorOrder", deviceOrderStr).asString()); const QJsonObject& colorOrder = ledConfigArray[i].toObject();
led.colorOrder = stringToColorOrder(index["colorOrder"].toString(deviceOrderStr));
ledString.leds().push_back(led); ledString.leds().push_back(led);
} }
} }
@ -464,16 +471,20 @@ LedString Hyperion::createLedString(const Json::Value& ledsConfig, const ColorOr
return ledString; return ledString;
} }
LedString Hyperion::createLedStringClone(const Json::Value& ledsConfig, const ColorOrder deviceOrder) LedString Hyperion::createLedStringClone(const QJsonValue& ledsConfig, const ColorOrder deviceOrder)
{ {
LedString ledString; LedString ledString;
const std::string deviceOrderStr = colorOrderToString(deviceOrder); const QString deviceOrderStr = colorOrderToString(deviceOrder);
int maxLedId = ledsConfig.size(); const QJsonArray & ledConfigArray = ledsConfig.toArray();
for (const Json::Value& ledConfig : ledsConfig) int maxLedId = ledConfigArray.size();
for (signed i = 0; i < ledConfigArray.size(); ++i)
{ {
const QJsonObject& index = ledConfigArray[i].toObject();
Led led; Led led;
led.index = ledConfig["index"].asInt(); led.index = index["index"].toInt();
led.clone = ledConfig.get("clone",-1).asInt(); led.clone = index["clone"].toInt(-1);
if ( led.clone < -1 || led.clone >= maxLedId ) if ( led.clone < -1 || led.clone >= maxLedId )
{ {
Warning(Logger::getInstance("Core"), "LED %d: clone index of %d is out of range, clone ignored", led.index, led.clone); Warning(Logger::getInstance("Core"), "LED %d: clone index of %d is out of range, clone ignored", led.index, led.clone);
@ -488,7 +499,7 @@ LedString Hyperion::createLedStringClone(const Json::Value& ledsConfig, const Co
led.minY_frac = 0; led.minY_frac = 0;
led.maxY_frac = 0; led.maxY_frac = 0;
// Get the order of the rgb channels for this led (default is device order) // Get the order of the rgb channels for this led (default is device order)
led.colorOrder = stringToColorOrder(ledConfig.get("colorOrder", deviceOrderStr).asString()); led.colorOrder = stringToColorOrder(index["colorOrder"].toString(deviceOrderStr));
ledString.leds().push_back(led); ledString.leds().push_back(led);
} }
@ -500,21 +511,24 @@ LedString Hyperion::createLedStringClone(const Json::Value& ledsConfig, const Co
return ledString; return ledString;
} }
QSize Hyperion::getLedLayoutGridSize(const Json::Value& ledsConfig) QSize Hyperion::getLedLayoutGridSize(const QJsonValue& ledsConfig)
{ {
std::vector<int> midPointsX; std::vector<int> midPointsX;
std::vector<int> midPointsY; std::vector<int> midPointsY;
const QJsonArray & ledConfigArray = ledsConfig.toArray();
for (const Json::Value& ledConfig : ledsConfig) for (signed i = 0; i < ledConfigArray.size(); ++i)
{ {
if ( ledConfig.get("clone",-1).asInt() < 0 ) const QJsonObject& index = ledConfigArray[i].toObject();
if (index["clone"].toInt(-1) < 0 )
{ {
const Json::Value& hscanConfig = ledConfig["hscan"]; const QJsonObject& hscanConfig = ledConfigArray[i].toObject()["hscan"].toObject();
const Json::Value& vscanConfig = ledConfig["vscan"]; const QJsonObject& vscanConfig = ledConfigArray[i].toObject()["vscan"].toObject();
double minX_frac = std::max(0.0, std::min(1.0, hscanConfig["minimum"].asDouble())); double minX_frac = std::max(0.0, std::min(1.0, hscanConfig["minimum"].toDouble()));
double maxX_frac = std::max(0.0, std::min(1.0, hscanConfig["maximum"].asDouble())); double maxX_frac = std::max(0.0, std::min(1.0, hscanConfig["maximum"].toDouble()));
double minY_frac = std::max(0.0, std::min(1.0, vscanConfig["minimum"].asDouble())); double minY_frac = std::max(0.0, std::min(1.0, vscanConfig["minimum"].toDouble()));
double maxY_frac = std::max(0.0, std::min(1.0, vscanConfig["maximum"].asDouble())); double maxY_frac = std::max(0.0, std::min(1.0, vscanConfig["maximum"].toDouble()));
// Fix if the user swapped min and max // Fix if the user swapped min and max
if (minX_frac > maxX_frac) if (minX_frac > maxX_frac)
{ {
@ -545,10 +559,10 @@ QSize Hyperion::getLedLayoutGridSize(const Json::Value& ledsConfig)
LinearColorSmoothing * Hyperion::createColorSmoothing(const Json::Value & smoothingConfig, LedDevice* leddevice) LinearColorSmoothing * Hyperion::createColorSmoothing(const QJsonObject & smoothingConfig, LedDevice* leddevice)
{ {
Logger * log = Logger::getInstance("Core"); Logger * log = Logger::getInstance("Core");
std::string type = smoothingConfig.get("type", "linear").asString(); std::string type = smoothingConfig["type"].toString("linear").toStdString();
std::transform(type.begin(), type.end(), type.begin(), ::tolower); std::transform(type.begin(), type.end(), type.begin(), ::tolower);
LinearColorSmoothing * device = nullptr; LinearColorSmoothing * device = nullptr;
type = "linear"; // TODO currently hardcoded type, delete it if we have more types type = "linear"; // TODO currently hardcoded type, delete it if we have more types
@ -558,10 +572,10 @@ LinearColorSmoothing * Hyperion::createColorSmoothing(const Json::Value & smooth
Info( log, "Creating linear smoothing"); Info( log, "Creating linear smoothing");
device = new LinearColorSmoothing( device = new LinearColorSmoothing(
leddevice, leddevice,
smoothingConfig.get("updateFrequency", 25.0).asDouble(), smoothingConfig["updateFrequency"].toDouble(25.0),
smoothingConfig.get("time_ms", 200).asInt(), smoothingConfig["time_ms"].toInt(200),
smoothingConfig.get("updateDelay", 0).asUInt(), smoothingConfig["updateDelay"].toInt(0),
smoothingConfig.get("continuousOutput", true).asBool() smoothingConfig["continuousOutput"].toBool(true)
); );
} }
else else
@ -569,33 +583,35 @@ LinearColorSmoothing * Hyperion::createColorSmoothing(const Json::Value & smooth
Error(log, "Smoothing disabled, because of unknown type '%s'.", type.c_str()); Error(log, "Smoothing disabled, because of unknown type '%s'.", type.c_str());
} }
device->setEnable(smoothingConfig.get("enable", true).asBool()); device->setEnable(smoothingConfig["enable"].toBool(true));
InfoIf(!device->enabled(), log,"Smoothing disabled"); InfoIf(!device->enabled(), log,"Smoothing disabled");
assert(device != nullptr); assert(device != nullptr);
return device; return device;
} }
MessageForwarder * Hyperion::createMessageForwarder(const Json::Value & forwarderConfig) MessageForwarder * Hyperion::createMessageForwarder(const QJsonObject & forwarderConfig)
{ {
MessageForwarder * forwarder = new MessageForwarder(); MessageForwarder * forwarder = new MessageForwarder();
if ( ( ! forwarderConfig.isNull() ) && ( forwarderConfig.get("enable", true).asBool() ) ) if ( !forwarderConfig.isEmpty() && forwarderConfig["enable"].toBool(true) )
{ {
if ( ! forwarderConfig["json"].isNull() && forwarderConfig["json"].isArray() ) if ( !forwarderConfig["json"].isNull() && forwarderConfig["json"].isArray() )
{ {
for (const Json::Value& addr : forwarderConfig["json"]) const QJsonArray & addr = forwarderConfig["json"].toArray();
for (signed i = 0; i < addr.size(); ++i)
{ {
Info(Logger::getInstance("Core"), "Json forward to %s", addr.asString().c_str()); Info(Logger::getInstance("Core"), "Json forward to %s", addr.at(i).toString().toStdString().c_str());
forwarder->addJsonSlave(addr.asString()); forwarder->addJsonSlave(addr[i].toString().toStdString());
} }
} }
if ( ! forwarderConfig["proto"].isNull() && forwarderConfig["proto"].isArray() ) if ( !forwarderConfig["proto"].isNull() && forwarderConfig["proto"].isArray() )
{ {
for (const Json::Value& addr : forwarderConfig["proto"]) const QJsonArray & addr = forwarderConfig["proto"].toArray();
for (signed i = 0; i < addr.size(); ++i)
{ {
Info(Logger::getInstance("Core"), "Proto forward to %s", addr.asString().c_str()); Info(Logger::getInstance("Core"), "Proto forward to %s", addr.at(i).toString().toStdString().c_str());
forwarder->addProtoSlave(addr.asString()); forwarder->addProtoSlave(addr[i].toString().toStdString());
} }
} }
} }
@ -608,15 +624,15 @@ MessageForwarder * Hyperion::getForwarder()
return _messageForwarder; return _messageForwarder;
} }
Hyperion::Hyperion(const Json::Value &jsonConfig, const std::string configFile) Hyperion::Hyperion(const Json::Value &jsonConfig, const QJsonObject &qjsonConfig, const std::string configFile)
: _ledString(createLedString(jsonConfig["leds"], createColorOrder(jsonConfig["device"]))) : _ledString(createLedString(qjsonConfig["leds"], createColorOrder(qjsonConfig["device"].toObject())))
, _ledStringClone(createLedStringClone(jsonConfig["leds"], createColorOrder(jsonConfig["device"]))) , _ledStringClone(createLedStringClone(qjsonConfig["leds"], createColorOrder(qjsonConfig["device"].toObject())))
, _muxer(_ledString.leds().size()) , _muxer(_ledString.leds().size())
, _raw2ledTransform(createLedColorsTransform(_ledString.leds().size(), jsonConfig["color"])) , _raw2ledTransform(createLedColorsTransform(_ledString.leds().size(), qjsonConfig["color"].toObject()))
, _raw2ledTemperature(createLedColorsTemperature(_ledString.leds().size(), jsonConfig["color"])) , _raw2ledTemperature(createLedColorsTemperature(_ledString.leds().size(), qjsonConfig["color"].toObject()))
, _raw2ledAdjustment(createLedColorsAdjustment(_ledString.leds().size(), jsonConfig["color"])) , _raw2ledAdjustment(createLedColorsAdjustment(_ledString.leds().size(), qjsonConfig["color"].toObject()))
, _effectEngine(nullptr) , _effectEngine(nullptr)
, _messageForwarder(createMessageForwarder(jsonConfig["forwarder"])) , _messageForwarder(createMessageForwarder(qjsonConfig["forwarder"].toObject()))
, _jsonConfig(jsonConfig) , _jsonConfig(jsonConfig)
, _configFile(configFile) , _configFile(configFile)
, _timer() , _timer()
@ -624,7 +640,7 @@ Hyperion::Hyperion(const Json::Value &jsonConfig, const std::string configFile)
, _hwLedCount(_ledString.leds().size()) , _hwLedCount(_ledString.leds().size())
, _sourceAutoSelectEnabled(true) , _sourceAutoSelectEnabled(true)
, _configHash() , _configHash()
, _ledGridSize(getLedLayoutGridSize(jsonConfig["leds"])) , _ledGridSize(getLedLayoutGridSize(qjsonConfig["leds"]))
{ {
registerPriority("Off", PriorityMuxer::LOWEST_PRIORITY); registerPriority("Off", PriorityMuxer::LOWEST_PRIORITY);
@ -641,9 +657,10 @@ Hyperion::Hyperion(const Json::Value &jsonConfig, const std::string configFile)
throw std::runtime_error("Color transformation incorrectly set"); throw std::runtime_error("Color transformation incorrectly set");
} }
// set color correction activity state // set color correction activity state
_transformEnabled = jsonConfig["color"].get("transform_enable",true).asBool(); const QJsonObject& color = qjsonConfig["color"].toObject();
_adjustmentEnabled = jsonConfig["color"].get("channelAdjustment_enable",true).asBool(); _transformEnabled = color["transform_enable"].toBool(true);
_temperatureEnabled = jsonConfig["color"].get("temperature_enable",true).asBool(); _adjustmentEnabled = color["channelAdjustment_enable"].toBool(true);
_temperatureEnabled = color["temperature_enable"].toBool(true);
InfoIf(!_transformEnabled , _log, "Color transformation disabled" ); InfoIf(!_transformEnabled , _log, "Color transformation disabled" );
InfoIf(!_adjustmentEnabled , _log, "Color adjustment disabled" ); InfoIf(!_adjustmentEnabled , _log, "Color adjustment disabled" );
@ -652,13 +669,13 @@ Hyperion::Hyperion(const Json::Value &jsonConfig, const std::string configFile)
// initialize the image processor factory // initialize the image processor factory
ImageProcessorFactory::getInstance().init( ImageProcessorFactory::getInstance().init(
_ledString, _ledString,
jsonConfig["blackborderdetector"] qjsonConfig["blackborderdetector"].toObject()
); );
getComponentRegister().componentStateChanged(hyperion::COMP_FORWARDER, _messageForwarder->forwardingEnabled()); getComponentRegister().componentStateChanged(hyperion::COMP_FORWARDER, _messageForwarder->forwardingEnabled());
// initialize leddevices // initialize leddevices
_device = LedDeviceFactory::construct(jsonConfig["device"]); _device = LedDeviceFactory::construct(jsonConfig["device"]);
_deviceSmooth = createColorSmoothing(jsonConfig["smoothing"], _device); _deviceSmooth = createColorSmoothing(qjsonConfig["smoothing"].toObject(), _device);
getComponentRegister().componentStateChanged(hyperion::COMP_SMOOTHING, _deviceSmooth->componentState()); getComponentRegister().componentStateChanged(hyperion::COMP_SMOOTHING, _deviceSmooth->componentState());
// setup the timer // setup the timer
@ -668,7 +685,8 @@ Hyperion::Hyperion(const Json::Value &jsonConfig, const std::string configFile)
// create the effect engine // create the effect engine
_effectEngine = new EffectEngine(this,jsonConfig["effects"]); _effectEngine = new EffectEngine(this,jsonConfig["effects"]);
unsigned int hwLedCount = jsonConfig["device"].get("ledCount",getLedCount()).asUInt(); const QJsonObject& device = qjsonConfig["device"].toObject();
unsigned int hwLedCount = device["ledCount"].toInt(getLedCount());
_hwLedCount = std::max(hwLedCount, getLedCount()); _hwLedCount = std::max(hwLedCount, getLedCount());
Debug(_log,"configured leds: %d hw leds: %d", getLedCount(), _hwLedCount); Debug(_log,"configured leds: %d hw leds: %d", getLedCount(), _hwLedCount);
WarningIf(hwLedCount < getLedCount(), _log, "more leds configured than available. check 'ledCount' in 'device' section"); WarningIf(hwLedCount < getLedCount(), _log, "more leds configured than available. check 'ledCount' in 'device' section");

View File

@ -9,7 +9,7 @@
using namespace hyperion; 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 QJsonObject & blackborderConfig) :
_ledString(ledString), _ledString(ledString),
_borderProcessor(new BlackBorderProcessor(blackborderConfig) ), _borderProcessor(new BlackBorderProcessor(blackborderConfig) ),
_imageToLeds(nullptr) _imageToLeds(nullptr)

View File

@ -9,7 +9,7 @@ ImageProcessorFactory& ImageProcessorFactory::getInstance()
return instance; return instance;
} }
void ImageProcessorFactory::init(const LedString& ledString, const Json::Value & blackborderConfig) void ImageProcessorFactory::init(const LedString& ledString, const QJsonObject & blackborderConfig)
{ {
_ledString = ledString; _ledString = ledString;
_blackborderConfig = blackborderConfig; _blackborderConfig = blackborderConfig;

View File

@ -54,7 +54,7 @@ HyperionDaemon::HyperionDaemon(QString configFile, QObject *parent)
{ {
loadConfig(configFile); loadConfig(configFile);
_hyperion = Hyperion::initInstance(_config, configFile.toStdString()); _hyperion = Hyperion::initInstance(_config, _qconfig, configFile.toStdString());
if (Logger::getLogLevel() == Logger::WARNING) if (Logger::getLogLevel() == Logger::WARNING)
{ {

View File

@ -47,7 +47,7 @@ int main()
// unsigned unknownCnt = 600; // unsigned unknownCnt = 600;
unsigned borderCnt = 50; unsigned borderCnt = 50;
// unsigned blurCnt = 0; // unsigned blurCnt = 0;
Json::Value config; QJsonObject config;
// BlackBorderProcessor processor(unknownCnt, borderCnt, blurCnt, 3, config); // BlackBorderProcessor processor(unknownCnt, borderCnt, blurCnt, 3, config);
BlackBorderProcessor processor(config); BlackBorderProcessor processor(config);

View File

@ -1,7 +1,7 @@
// Utils includes // Utils includes
#include <utils/Image.h> #include <utils/Image.h>
#include <utils/jsonschema/JsonFactory.h> #include <utils/jsonschema/QJsonFactory.h>
// Hyperion includes // Hyperion includes
#include <hyperion/Hyperion.h> #include <hyperion/Hyperion.h>
@ -11,19 +11,19 @@ using namespace hyperion;
int main() int main()
{ {
std::string homeDir = getenv("RASPILIGHT_HOME"); QString homeDir = getenv("RASPILIGHT_HOME");
const std::string schemaFile = homeDir + "/hyperion.schema.json"; const QString schemaFile = homeDir + "/hyperion.schema.json";
const std::string configFile = homeDir + "/hyperion.config.json"; const QString configFile = homeDir + "/hyperion.config.json";
Json::Value config; QJsonObject config;
if (JsonFactory::load(schemaFile, configFile, config) < 0) if (QJsonFactory::load(schemaFile, configFile, config) < 0)
{ {
std::cerr << "UNABLE TO LOAD CONFIGURATION" << std::endl; std::cerr << "UNABLE TO LOAD CONFIGURATION" << std::endl;
return -1; return -1;
} }
const LedString ledString = Hyperion::createLedString(config["leds"], Hyperion::createColorOrder(config["device"])); const LedString ledString = Hyperion::createLedString(config["leds"], Hyperion::createColorOrder(config["device"].toObject()));
const ColorRgb testColor = {64, 123, 12}; const ColorRgb testColor = {64, 123, 12};