Skip to content

Commit f146894

Browse files
Paulchen PantherredPanther
Paulchen Panther
authored andcommitted
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
1 parent d6a34ed commit f146894

12 files changed

+214
-182
lines changed

include/blackborder/BlackBorderProcessor.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

22
#pragma once
33

4-
// Jsoncpp includes
5-
#include <json/json.h>
4+
// QT includes
5+
#include <QJsonObject>
66

77
// Local Hyperion includes
88
#include "BlackBorderDetector.h"
@@ -26,7 +26,7 @@ namespace hyperion
2626
/// outer pixels is blurred (black and color combined due to image scaling))
2727
/// @param[in] blackborderThreshold The threshold which the blackborder detector should use
2828
///
29-
BlackBorderProcessor(const Json::Value &blackborderConfig);
29+
BlackBorderProcessor(const QJsonObject &blackborderConfig);
3030

3131
///
3232
/// Return the current (detected) border

include/hyperion/Hyperion.h

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
#include <QObject>
99
#include <QTimer>
1010
#include <QSize>
11+
#include <QJsonObject>
12+
#include <QJsonValue>
13+
#include <QJsonArray>
1114

1215
// hyperion-utils includes
1316
#include <utils/Image.h>
@@ -79,7 +82,7 @@ class Hyperion : public QObject
7982
~Hyperion();
8083

8184

82-
static Hyperion* initInstance(const Json::Value& jsonConfig, const std::string configFile);
85+
static Hyperion* initInstance(const Json::Value& jsonConfig, const QJsonObject& qjsonConfig, const std::string configFile);
8386
static Hyperion* getInstance();
8487

8588
///
@@ -270,32 +273,32 @@ public slots:
270273
public:
271274
static Hyperion *_hyperion;
272275

273-
static ColorOrder createColorOrder(const Json::Value & deviceConfig);
276+
static ColorOrder createColorOrder(const QJsonObject & deviceConfig);
274277
/**
275278
* Construct the 'led-string' with the integration area definition per led and the color
276279
* ordering of the RGB channels
277280
* @param ledsConfig The configuration of the led areas
278281
* @param deviceOrder The default RGB channel ordering
279282
* @return The constructed ledstring
280283
*/
281-
static LedString createLedString(const Json::Value & ledsConfig, const ColorOrder deviceOrder);
282-
static LedString createLedStringClone(const Json::Value & ledsConfig, const ColorOrder deviceOrder);
283-
284-
static MultiColorTransform * createLedColorsTransform(const unsigned ledCnt, const Json::Value & colorTransformConfig);
285-
static MultiColorCorrection * createLedColorsTemperature(const unsigned ledCnt, const Json::Value & colorTemperatureConfig);
286-
static MultiColorAdjustment * createLedColorsAdjustment(const unsigned ledCnt, const Json::Value & colorAdjustmentConfig);
287-
static ColorTransform * createColorTransform(const Json::Value & transformConfig);
288-
static ColorCorrection * createColorCorrection(const Json::Value & correctionConfig);
289-
static ColorAdjustment * createColorAdjustment(const Json::Value & adjustmentConfig);
290-
static HsvTransform * createHsvTransform(const Json::Value & hsvConfig);
291-
static HslTransform * createHslTransform(const Json::Value & hslConfig);
292-
static RgbChannelTransform * createRgbChannelTransform(const Json::Value& colorConfig);
293-
static RgbChannelAdjustment * createRgbChannelCorrection(const Json::Value& colorConfig);
294-
static RgbChannelAdjustment * createRgbChannelAdjustment(const Json::Value& colorConfig, const RgbChannel color);
295-
296-
static LinearColorSmoothing * createColorSmoothing(const Json::Value & smoothingConfig, LedDevice* leddevice);
297-
static MessageForwarder * createMessageForwarder(const Json::Value & forwarderConfig);
298-
static QSize getLedLayoutGridSize(const Json::Value& ledsConfig);
284+
static LedString createLedString(const QJsonValue & ledsConfig, const ColorOrder deviceOrder);
285+
static LedString createLedStringClone(const QJsonValue & ledsConfig, const ColorOrder deviceOrder);
286+
287+
static MultiColorTransform * createLedColorsTransform(const unsigned ledCnt, const QJsonObject & colorTransformConfig);
288+
static MultiColorCorrection * createLedColorsTemperature(const unsigned ledCnt, const QJsonObject & colorTemperatureConfig);
289+
static MultiColorAdjustment * createLedColorsAdjustment(const unsigned ledCnt, const QJsonObject & colorAdjustmentConfig);
290+
static ColorTransform * createColorTransform(const QJsonObject & transformConfig);
291+
static ColorCorrection * createColorCorrection(const QJsonObject & correctionConfig);
292+
static ColorAdjustment * createColorAdjustment(const QJsonObject & adjustmentConfig);
293+
static HsvTransform * createHsvTransform(const QJsonObject & hsvConfig);
294+
static HslTransform * createHslTransform(const QJsonObject & hslConfig);
295+
static RgbChannelTransform * createRgbChannelTransform(const QJsonObject& colorConfig);
296+
static RgbChannelAdjustment * createRgbChannelCorrection(const QJsonObject& colorConfig);
297+
static RgbChannelAdjustment * createRgbChannelAdjustment(const QJsonObject& colorConfig, const RgbChannel color);
298+
299+
static LinearColorSmoothing * createColorSmoothing(const QJsonObject & smoothingConfig, LedDevice* leddevice);
300+
static MessageForwarder * createMessageForwarder(const QJsonObject & forwarderConfig);
301+
static QSize getLedLayoutGridSize(const QJsonValue& ledsConfig);
299302

300303
signals:
301304
/// Signal which is emitted when a priority channel is actively cleared
@@ -322,7 +325,7 @@ private slots:
322325
///
323326
/// @param[in] jsonConfig The Json configuration
324327
///
325-
Hyperion(const Json::Value& jsonConfig, const std::string configFile);
328+
Hyperion(const Json::Value& jsonConfig, const QJsonObject& qjsonConfig, const std::string configFile);
326329

327330
/// The specifiation of the led frame construction and picture integration
328331
LedString _ledString;

include/hyperion/ImageProcessor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class ImageProcessor
109109
/// @param[in] ledString The led-string specification
110110
/// @param[in] blackborderThreshold The threshold which the blackborder detector should use
111111
///
112-
ImageProcessor(const LedString &ledString, const Json::Value &blackborderConfig);
112+
ImageProcessor(const LedString &ledString, const QJsonObject &blackborderConfig);
113113

114114
///
115115
/// Performs black-border detection (if enabled) on the given image

include/hyperion/ImageProcessorFactory.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
// STL includes
44
#include <memory>
55

6+
// QT includes
7+
#include <QJsonObject>
8+
9+
// if (jsoncpp_converted_to_QtJSON)
10+
// {
11+
// remove("#include <json/json.h>");
12+
// }
13+
614
// Jsoncpp includes
715
#include <json/json.h>
816

@@ -33,7 +41,7 @@ class ImageProcessorFactory
3341
/// @param[in] enableBlackBorderDetector Flag indicating if the blacborder detector should be enabled
3442
/// @param[in] blackborderThreshold The threshold which the blackborder detector should use
3543
///
36-
void init(const LedString& ledString, const Json::Value &blackborderConfig);
44+
void init(const LedString& ledString, const QJsonObject &blackborderConfig);
3745

3846
///
3947
/// Creates a new ImageProcessor. The onwership of the processor is transferred to the caller.
@@ -47,5 +55,5 @@ class ImageProcessorFactory
4755
LedString _ledString;
4856

4957
// Reference to the blackborder json configuration values
50-
Json::Value _blackborderConfig;
58+
QJsonObject _blackborderConfig;
5159
};

include/hyperion/LedString.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
// Local includes
1010
#include <utils/ColorRgb.h>
1111

12+
// QT includes
13+
#include <QString>
14+
1215
// Forward class declarations
1316
namespace Json { class Value; }
1417

@@ -18,7 +21,7 @@ enum ColorOrder
1821
ORDER_RGB, ORDER_RBG, ORDER_GRB, ORDER_BRG, ORDER_GBR, ORDER_BGR
1922
};
2023

21-
inline std::string colorOrderToString(const ColorOrder colorOrder)
24+
inline QString colorOrderToString(const ColorOrder colorOrder)
2225
{
2326
switch (colorOrder)
2427
{
@@ -38,7 +41,7 @@ inline std::string colorOrderToString(const ColorOrder colorOrder)
3841
return "not-a-colororder";
3942
}
4043
}
41-
inline ColorOrder stringToColorOrder(const std::string & order)
44+
inline ColorOrder stringToColorOrder(const QString & order)
4245
{
4346
if (order == "rgb")
4447
{
@@ -65,7 +68,7 @@ inline ColorOrder stringToColorOrder(const std::string & order)
6568
return ORDER_GRB;
6669
}
6770

68-
std::cout << "Unknown color order defined (" << order << "). Using RGB." << std::endl;
71+
std::cout << "Unknown color order defined (" << order.toStdString() << "). Using RGB." << std::endl;
6972
return ORDER_RGB;
7073
}
7174

libsrc/blackborder/BlackBorderProcessor.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88

99
using namespace hyperion;
1010

11-
BlackBorderProcessor::BlackBorderProcessor(const Json::Value &blackborderConfig)
12-
: _enabled(blackborderConfig.get("enable", true).asBool())
13-
, _unknownSwitchCnt(blackborderConfig.get("unknownFrameCnt", 600).asUInt())
14-
, _borderSwitchCnt(blackborderConfig.get("borderFrameCnt", 50).asUInt())
15-
, _maxInconsistentCnt(blackborderConfig.get("maxInconsistentCnt", 10).asUInt())
16-
, _blurRemoveCnt(blackborderConfig.get("blurRemoveCnt", 1).asUInt())
17-
, _detectionMode(blackborderConfig.get("mode", "default").asString())
18-
, _detector(blackborderConfig.get("threshold", 0.01).asDouble())
11+
BlackBorderProcessor::BlackBorderProcessor(const QJsonObject &blackborderConfig)
12+
: _enabled(blackborderConfig["enable"].toBool(true))
13+
, _unknownSwitchCnt(blackborderConfig["unknownFrameCnt"].toInt(600))
14+
, _borderSwitchCnt(blackborderConfig["borderFrameCnt"].toInt(50))
15+
, _maxInconsistentCnt(blackborderConfig["maxInconsistentCnt"].toInt(10))
16+
, _blurRemoveCnt(blackborderConfig["blurRemoveCnt"].toInt(1))
17+
, _detectionMode(blackborderConfig["mode"].toString("default").toStdString())
18+
, _detector(blackborderConfig["threshold"].toDouble(0.01))
1919
, _currentBorder({true, -1, -1})
2020
, _previousDetectedBorder({true, -1, -1})
2121
, _consistentCnt(0)

0 commit comments

Comments
 (0)