adjustable image2led mode for grabbers (#341)

* implement most points for a adjustable image2leds mapping

* implement new adjustable led mapping type
This commit is contained in:
redPanther 2016-12-19 23:59:50 +01:00 committed by GitHub
parent 53924c4fca
commit c5e0299c55
21 changed files with 258 additions and 47 deletions

View File

@ -30,6 +30,8 @@
/// Color manipulation configuration used to tune the output colors to specific surroundings. /// Color manipulation configuration used to tune the output colors to specific surroundings.
/// The configuration contains a list of color-transforms. Each transform contains the /// The configuration contains a list of color-transforms. Each transform contains the
/// following fields: /// following fields:
/// * 'imageToLedMappingType' : multicolor_mean - every led has it's own calculatedmean color
/// unicolor_mean - every led has same color, color is the mean of whole image
/// * 'channelAdjustment_enable' : true/false enables/disables this channelAdjustment section /// * 'channelAdjustment_enable' : true/false enables/disables this channelAdjustment section
/// * 'channelAdjustment_v4l_only' : if enabled and set to true, then channelAdjustment is only for v4l devices /// * 'channelAdjustment_v4l_only' : if enabled and set to true, then channelAdjustment is only for v4l devices
/// * 'channelAdjustment' /// * 'channelAdjustment'
@ -56,6 +58,7 @@
/// - 'gamma' The gamma-curve correction factor /// - 'gamma' The gamma-curve correction factor
"color" : "color" :
{ {
"imageToLedMappingType" : "multicolor_mean",
"channelAdjustment_enable" : true, "channelAdjustment_enable" : true,
"channelAdjustment_v4l_only" : true, "channelAdjustment_v4l_only" : true,
"channelAdjustment" : "channelAdjustment" :

View File

@ -16,6 +16,7 @@
"color" : "color" :
{ {
"imageToLedMappingType" : "multicolor_mean",
"channelAdjustment_enable" : true, "channelAdjustment_enable" : true,
"channelAdjustment_v4l_only" : true, "channelAdjustment_v4l_only" : true,
"channelAdjustment" : "channelAdjustment" :

View File

@ -93,7 +93,7 @@ public:
/// ///
unsigned getLedCount() const; unsigned getLedCount() const;
QSize getLedGridSize() const { return _ledGridSize; } QSize getLedGridSize() const { return _ledGridSize; };
/// ///
/// Returns the current priority /// Returns the current priority
@ -273,6 +273,9 @@ public slots:
/// @param timeout The timeout of the effect (after the timout, the effect will be cleared) /// @param timeout The timeout of the effect (after the timout, the effect will be cleared)
int setEffect(const QString & effectName, const QJsonObject & args, int priority, int timeout = -1, QString pythonScript = ""); int setEffect(const QString & effectName, const QJsonObject & args, int priority, int timeout = -1, QString pythonScript = "");
/// sets the methode how image is maped to leds
void setLedMappingType(int mappingType);
public: public:
static Hyperion *_hyperion; static Hyperion *_hyperion;
@ -312,6 +315,7 @@ signals:
void componentStateChanged(const hyperion::Components component, bool enabled); void componentStateChanged(const hyperion::Components component, bool enabled);
void imageToLedsMappingChanged(int mappingType);
void emitImage(int priority, const Image<ColorRgb> & image, const int timeout_ms); void emitImage(int priority, const Image<ColorRgb> & image, const int timeout_ms);
private slots: private slots:

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
#include <QString>
// Utils includes // Utils includes
#include <utils/Image.h> #include <utils/Image.h>
@ -18,9 +19,12 @@
/// performed in two steps. First the average color per led-region is computed. Second a /// performed in two steps. First the average color per led-region is computed. Second a
/// color-tranform is applied based on a gamma-correction. /// color-tranform is applied based on a gamma-correction.
/// ///
class ImageProcessor class ImageProcessor : public QObject
{ {
Q_OBJECT
public: public:
~ImageProcessor(); ~ImageProcessor();
/// ///
@ -38,12 +42,23 @@ public:
/// ///
void setSize(const unsigned width, const unsigned height); void setSize(const unsigned width, const unsigned height);
/// Enable or disable the black border detector
void enableBlackBorderDetector(bool enable);
/// Returns starte of black border detector /// Returns starte of black border detector
bool blackBorderDetectorEnabled(); bool blackBorderDetectorEnabled();
/// Returns starte of black border detector
int ledMappingType();
static int mappingTypeToInt(QString mappingType);
public slots:
/// Enable or disable the black border detector
void enableBlackBorderDetector(bool enable);
/// Enable or disable the black border detector
void setLedMappingType(int mapType);
public:
/// ///
/// 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
/// if required and call the image-to-leds mapping to determine the mean color per led. /// if required and call the image-to-leds mapping to determine the mean color per led.
@ -62,7 +77,12 @@ public:
verifyBorder(image); verifyBorder(image);
// Create a result vector and call the 'in place' functionl // Create a result vector and call the 'in place' functionl
std::vector<ColorRgb> colors = _imageToLeds->getMeanLedColor(image); std::vector<ColorRgb> colors;
switch (_mappingType)
{
case 1: colors = _imageToLeds->getUniLedColor(image); break;
default: colors = _imageToLeds->getMeanLedColor(image);
}
// return the computed colors // return the computed colors
return colors; return colors;
@ -84,7 +104,12 @@ public:
verifyBorder(image); verifyBorder(image);
// Determine the mean-colors of each led (using the existing mapping) // Determine the mean-colors of each led (using the existing mapping)
_imageToLeds->getMeanLedColor(image, ledColors); switch (_mappingType)
{
case 1: _imageToLeds->getUniLedColor(image, ledColors); break;
default: _imageToLeds->getMeanLedColor(image, ledColors);
}
} }
/// ///
@ -153,6 +178,7 @@ private:
} }
private: private:
Logger * _log;
/// The Led-string specification /// The Led-string specification
const LedString _ledString; const LedString _ledString;
@ -161,4 +187,7 @@ private:
/// The mapping of image-pixels to leds /// The mapping of image-pixels to leds
hyperion::ImageToLedsMap* _imageToLeds; hyperion::ImageToLedsMap* _imageToLeds;
/// Type of image 2 led mapping
int _mappingType;
}; };

View File

@ -32,7 +32,7 @@ public:
/// @param[in] ledString The led configuration /// @param[in] ledString The led configuration
/// @param[in] blackborderConfig Contains the blackborder configuration /// @param[in] blackborderConfig Contains the blackborder configuration
/// ///
void init(const LedString& ledString, const QJsonObject &blackborderConfig); void init(const LedString& ledString, const QJsonObject &blackborderConfig, int mappingType);
/// ///
/// 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.
@ -45,6 +45,9 @@ private:
/// The Led-string specification /// The Led-string specification
LedString _ledString; LedString _ledString;
// Reference to the blackborder json configuration values /// Reference to the blackborder json configuration values
QJsonObject _blackborderConfig; QJsonObject _blackborderConfig;
// image 2 led mapping type
int _mappingType;
}; };

View File

@ -70,7 +70,7 @@ namespace hyperion
template <typename Pixel_T> template <typename Pixel_T>
std::vector<ColorRgb> getMeanLedColor(const Image<Pixel_T> & image) const std::vector<ColorRgb> getMeanLedColor(const Image<Pixel_T> & image) const
{ {
std::vector<ColorRgb> colors(mColorsMap.size(), ColorRgb{0,0,0}); std::vector<ColorRgb> colors(_colorsMap.size(), ColorRgb{0,0,0});
getMeanLedColor(image, colors); getMeanLedColor(image, colors);
return colors; return colors;
} }
@ -86,17 +86,51 @@ namespace hyperion
void getMeanLedColor(const Image<Pixel_T> & image, std::vector<ColorRgb> & ledColors) const void getMeanLedColor(const Image<Pixel_T> & image, std::vector<ColorRgb> & ledColors) const
{ {
// Sanity check for the number of leds // Sanity check for the number of leds
assert(mColorsMap.size() == ledColors.size()); assert(_colorsMap.size() == ledColors.size());
// Iterate each led and compute the mean // Iterate each led and compute the mean
auto led = ledColors.begin(); auto led = ledColors.begin();
for (auto ledColors = mColorsMap.begin(); ledColors != mColorsMap.end(); ++ledColors, ++led) for (auto ledColors = _colorsMap.begin(); ledColors != _colorsMap.end(); ++ledColors, ++led)
{ {
const ColorRgb color = calcMeanColor(image, *ledColors); const ColorRgb color = calcMeanColor(image, *ledColors);
*led = color; *led = color;
} }
} }
///
/// Determines the mean-color for each led using the mapping the image given
/// at construction.
///
/// @param[in] image The image from which to extract the led colors
///
/// @return ledColors The vector containing the output
///
template <typename Pixel_T>
std::vector<ColorRgb> getUniLedColor(const Image<Pixel_T> & image) const
{
std::vector<ColorRgb> colors(_colorsMap.size(), ColorRgb{0,0,0});
getUniLedColor(image, colors);
return colors;
}
///
/// Determines the mean color for each led using the mapping the image given
/// at construction.
///
/// @param[in] image The image from which to extract the led colors
/// @param[out] ledColors The vector containing the output
///
template <typename Pixel_T>
void getUniLedColor(const Image<Pixel_T> & image, std::vector<ColorRgb> & ledColors) const
{
// Sanity check for the number of leds
assert(_colorsMap.size() == ledColors.size());
// calculate uni color
const ColorRgb color = calcMeanColor(image);
std::fill(ledColors.begin(),ledColors.end(), color);
}
private: private:
/// The width of the indexed image /// The width of the indexed image
const unsigned _width; const unsigned _width;
@ -108,7 +142,7 @@ namespace hyperion
const unsigned _verticalBorder; const unsigned _verticalBorder;
/// The absolute indices into the image for each led /// The absolute indices into the image for each led
std::vector<std::vector<unsigned>> mColorsMap; std::vector<std::vector<unsigned>> _colorsMap;
/// ///
/// Calculates the 'mean color' of the given list. This is the mean over each color-channel /// Calculates the 'mean color' of the given list. This is the mean over each color-channel
@ -147,6 +181,40 @@ namespace hyperion
// Return the computed color // Return the computed color
return {avgRed, avgGreen, avgBlue}; return {avgRed, avgGreen, avgBlue};
} }
///
/// Calculates the 'mean color' over the given image. This is the mean over each color-channel
/// (red, green, blue)
///
/// @param[in] image The image a section from which an average color must be computed
///
/// @return The mean of the given list of colors (or black when empty)
///
template <typename Pixel_T>
ColorRgb calcMeanColor(const Image<Pixel_T> & image) const
{
// Accumulate the sum of each seperate color channel
uint_fast16_t cummRed = 0;
uint_fast16_t cummGreen = 0;
uint_fast16_t cummBlue = 0;
const unsigned imageSize = image.width() * image.height();
for (unsigned idx=0; idx<imageSize; idx++)
{
const Pixel_T& pixel = image.memptr()[idx];
cummRed += pixel.red;
cummGreen += pixel.green;
cummBlue += pixel.blue;
}
// Compute the average of each color channel
const uint8_t avgRed = uint8_t(cummRed/imageSize);
const uint8_t avgGreen = uint8_t(cummGreen/imageSize);
const uint8_t avgBlue = uint8_t(cummBlue/imageSize);
// Return the computed color
return {avgRed, avgGreen, avgBlue};
}
}; };
} // end namespace hyperion } // end namespace hyperion

View File

@ -6,6 +6,7 @@ SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/hyperion)
# Group the headers that go through the MOC compiler # Group the headers that go through the MOC compiler
SET(Hyperion_QT_HEADERS SET(Hyperion_QT_HEADERS
${CURRENT_HEADER_DIR}/Hyperion.h ${CURRENT_HEADER_DIR}/Hyperion.h
${CURRENT_HEADER_DIR}/ImageProcessor.h
${CURRENT_SOURCE_DIR}/LinearColorSmoothing.h ${CURRENT_SOURCE_DIR}/LinearColorSmoothing.h
${CURRENT_HEADER_DIR}/GrabberWrapper.h ${CURRENT_HEADER_DIR}/GrabberWrapper.h
@ -13,7 +14,6 @@ SET(Hyperion_QT_HEADERS
) )
SET(Hyperion_HEADERS SET(Hyperion_HEADERS
${CURRENT_HEADER_DIR}/ImageProcessor.h
${CURRENT_HEADER_DIR}/ImageProcessorFactory.h ${CURRENT_HEADER_DIR}/ImageProcessorFactory.h
${CURRENT_HEADER_DIR}/ImageToLedsMap.h ${CURRENT_HEADER_DIR}/ImageToLedsMap.h
${CURRENT_HEADER_DIR}/LedString.h ${CURRENT_HEADER_DIR}/LedString.h

View File

@ -20,6 +20,7 @@ GrabberWrapper::GrabberWrapper(std::string grabberName, const int priority, hype
_hyperion->getComponentRegister().componentStateChanged(hyperion::COMP_BLACKBORDER, _processor->blackBorderDetectorEnabled()); _hyperion->getComponentRegister().componentStateChanged(hyperion::COMP_BLACKBORDER, _processor->blackBorderDetectorEnabled());
qRegisterMetaType<hyperion::Components>("hyperion::Components"); qRegisterMetaType<hyperion::Components>("hyperion::Components");
connect(_hyperion, SIGNAL(imageToLedsMappingChanged(int)), _processor, SLOT(setLedMappingType(int)));
connect(_hyperion, SIGNAL(componentStateChanged(hyperion::Components,bool)), this, SLOT(componentStateChanged(hyperion::Components,bool))); connect(_hyperion, SIGNAL(componentStateChanged(hyperion::Components,bool)), this, SLOT(componentStateChanged(hyperion::Components,bool)));
connect(&_timer, SIGNAL(timeout()), this, SLOT(action())); connect(&_timer, SIGNAL(timeout()), this, SLOT(action()));
} }
@ -120,4 +121,3 @@ void GrabberWrapper::setColors(const std::vector<ColorRgb> &ledColors, const int
{ {
_hyperion->setColors(_priority, ledColors, timeout_ms, true, _grabberComponentId); _hyperion->setColors(_priority, ledColors, timeout_ms, true, _grabberComponentId);
} }

View File

@ -17,6 +17,7 @@
// hyperion include // hyperion include
#include <hyperion/Hyperion.h> #include <hyperion/Hyperion.h>
#include <hyperion/ImageProcessorFactory.h> #include <hyperion/ImageProcessorFactory.h>
#include <hyperion/ImageProcessor.h>
#include <hyperion/ColorTransform.h> #include <hyperion/ColorTransform.h>
#include <hyperion/ColorAdjustment.h> #include <hyperion/ColorAdjustment.h>
@ -561,7 +562,8 @@ Hyperion::Hyperion(const QJsonObject &qjsonConfig, const QString configFile)
// initialize the image processor factory // initialize the image processor factory
ImageProcessorFactory::getInstance().init( ImageProcessorFactory::getInstance().init(
_ledString, _ledString,
qjsonConfig["blackborderdetector"].toObject() qjsonConfig["blackborderdetector"].toObject(),
ImageProcessor::mappingTypeToInt(color["imageToLedMappingType"].toString())
); );
getComponentRegister().componentStateChanged(hyperion::COMP_FORWARDER, _messageForwarder->forwardingEnabled()); getComponentRegister().componentStateChanged(hyperion::COMP_FORWARDER, _messageForwarder->forwardingEnabled());
@ -852,6 +854,11 @@ int Hyperion::setEffect(const QString &effectName, const QJsonObject &args, int
return _effectEngine->runEffect(effectName, args, priority, timeout, pythonScript); return _effectEngine->runEffect(effectName, args, priority, timeout, pythonScript);
} }
void Hyperion::setLedMappingType(int mappingType)
{
emit imageToLedsMappingChanged(mappingType);
}
void Hyperion::update() void Hyperion::update()
{ {
// Update the muxer, cleaning obsolete priorities // Update the muxer, cleaning obsolete priorities

View File

@ -1,5 +1,6 @@
// Hyperion includes // Hyperion includes
#include <hyperion/Hyperion.h>
#include <hyperion/ImageProcessor.h> #include <hyperion/ImageProcessor.h>
#include <hyperion/ImageToLedsMap.h> #include <hyperion/ImageToLedsMap.h>
@ -8,13 +9,16 @@
using namespace hyperion; using namespace hyperion;
//ImageProcessor::ImageProcessor(const LedString& ledString, bool enableBlackBorderDetector, uint8_t blackborderThreshold) : ImageProcessor::ImageProcessor(const LedString& ledString, const QJsonObject & blackborderConfig)
ImageProcessor::ImageProcessor(const LedString& ledString, const QJsonObject & blackborderConfig) : : QObject()
_ledString(ledString), , _log(Logger::getInstance("BLACKBORDER"))
_borderProcessor(new BlackBorderProcessor(blackborderConfig) ), , _ledString(ledString)
_imageToLeds(nullptr) , _borderProcessor(new BlackBorderProcessor(blackborderConfig) )
, _imageToLeds(nullptr)
, _mappingType(0)
{ {
// empty // this is when we want to change the mapping for all input sources
// connect(Hyperion::getInstance(), SIGNAL(imageToLedsMappingChanged(int)), this, SLOT(setLedMappingType(int)));
} }
ImageProcessor::~ImageProcessor() ImageProcessor::~ImageProcessor()
@ -53,6 +57,25 @@ bool ImageProcessor::blackBorderDetectorEnabled()
return _borderProcessor->enabled(); return _borderProcessor->enabled();
} }
void ImageProcessor::setLedMappingType(int mapType)
{
Debug(_log, "set led mapping to type %d", mapType);
_mappingType = mapType;
}
int ImageProcessor::ledMappingType()
{
return _mappingType;
}
int ImageProcessor::mappingTypeToInt(QString mappingType)
{
if (mappingType == "unicolor_mean" )
return 1;
return 0;
}
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
{ {
if (led < _ledString.leds().size()) if (led < _ledString.leds().size())

View File

@ -9,13 +9,17 @@ ImageProcessorFactory& ImageProcessorFactory::getInstance()
return instance; return instance;
} }
void ImageProcessorFactory::init(const LedString& ledString, const QJsonObject & blackborderConfig) void ImageProcessorFactory::init(const LedString& ledString, const QJsonObject & blackborderConfig, int mappingType)
{ {
_ledString = ledString; _ledString = ledString;
_blackborderConfig = blackborderConfig; _blackborderConfig = blackborderConfig;
_mappingType = mappingType;
} }
ImageProcessor* ImageProcessorFactory::newImageProcessor() const ImageProcessor* ImageProcessorFactory::newImageProcessor() const
{ {
return new ImageProcessor(_ledString, _blackborderConfig); ImageProcessor* ip = new ImageProcessor(_ledString, _blackborderConfig);
ip->setLedMappingType(_mappingType);
return ip;
} }

View File

@ -18,26 +18,26 @@ ImageToLedsMap::ImageToLedsMap(
, _height(height) , _height(height)
, _horizontalBorder(horizontalBorder) , _horizontalBorder(horizontalBorder)
, _verticalBorder(verticalBorder) , _verticalBorder(verticalBorder)
, mColorsMap() , _colorsMap()
{ {
// Sanity check of the size of the borders (and width and height) // Sanity check of the size of the borders (and width and height)
assert(width > 2*verticalBorder); assert(_width > 2*_verticalBorder);
assert(height > 2*horizontalBorder); assert(_height > 2*_horizontalBorder);
// Reserve enough space in the map for the leds // Reserve enough space in the map for the leds
mColorsMap.reserve(leds.size()); _colorsMap.reserve(leds.size());
const unsigned xOffset = verticalBorder; const unsigned xOffset = _verticalBorder;
const unsigned actualWidth = width - 2 * verticalBorder; const unsigned actualWidth = _width - 2 * _verticalBorder;
const unsigned yOffset = horizontalBorder; const unsigned yOffset = _horizontalBorder;
const unsigned actualHeight = height - 2 * horizontalBorder; const unsigned actualHeight = _height - 2 * _horizontalBorder;
for (const Led& led : leds) for (const Led& led : leds)
{ {
// skip leds without area // skip leds without area
if ((led.maxX_frac-led.minX_frac) < 1e-6 || (led.maxY_frac-led.minY_frac) < 1e-6) if ((led.maxX_frac-led.minX_frac) < 1e-6 || (led.maxY_frac-led.minY_frac) < 1e-6)
{ {
mColorsMap.emplace_back(); _colorsMap.emplace_back();
continue; continue;
} }
@ -70,7 +70,7 @@ ImageToLedsMap::ImageToLedsMap(
} }
// Add the constructed vector to the map // Add the constructed vector to the map
mColorsMap.push_back(ledColors); _colorsMap.push_back(ledColors);
} }
} }

View File

@ -51,6 +51,7 @@
"type" : "string", "type" : "string",
"title" : "edt_dev_general_colorOrder_title", "title" : "edt_dev_general_colorOrder_title",
"enum" : ["rgb", "bgr", "rbg", "brg", "gbr", "grb"], "enum" : ["rgb", "bgr", "rbg", "brg", "gbr", "grb"],
"default" : "rgb",
"propertyOrder" : 3 "propertyOrder" : 3
}, },
"rewriteTime": { "rewriteTime": {
@ -70,26 +71,33 @@
"type":"object", "type":"object",
"title" : "edt_conf_color_heading_title", "title" : "edt_conf_color_heading_title",
"required" : true, "required" : true,
"defaultProperties": ["channelAdjustment_enable","channelAdjustment","transform_enable","transform"], "defaultProperties": ["imageToLedMappingType","channelAdjustment_enable","channelAdjustment","transform_enable","transform"],
"properties": "properties":
{ {
"imageToLedMappingType" :
{
"type" : "string",
"enum" : ["multicolor_mean", "unicolor_mean"],
"default" : "multicolor_mean",
"propertyOrder" : 1
},
"channelAdjustment_enable" : "channelAdjustment_enable" :
{ {
"type" : "boolean", "type" : "boolean",
"default" : true, "default" : true,
"propertyOrder" : 1 "propertyOrder" : 2
}, },
"channelAdjustment_v4l_only" : "channelAdjustment_v4l_only" :
{ {
"type" : "boolean", "type" : "boolean",
"default" : false, "default" : false,
"propertyOrder" : 2 "propertyOrder" : 3
}, },
"channelAdjustment" : "channelAdjustment" :
{ {
"type" : "array", "type" : "array",
"required" : true, "required" : true,
"propertyOrder" : 3, "propertyOrder" : 4,
"items" : "items" :
{ {
"type" : "object", "type" : "object",
@ -204,19 +212,19 @@
{ {
"type" : "boolean", "type" : "boolean",
"default" : true, "default" : true,
"propertyOrder" : 4 "propertyOrder" : 5
}, },
"transform_v4l_only" : "transform_v4l_only" :
{ {
"type" : "boolean", "type" : "boolean",
"default" : false, "default" : false,
"propertyOrder" : 5 "propertyOrder" : 6
}, },
"transform" : "transform" :
{ {
"type" : "array", "type" : "array",
"required" : true, "required" : true,
"propertyOrder" : 6, "propertyOrder" : 7,
"items" : "items" :
{ {
"type" : "object", "type" : "object",

View File

@ -319,6 +319,8 @@ void JsonClientConnection::handleMessage(const QString& messageString)
handleLedColorsCommand(message, command, tan); handleLedColorsCommand(message, command, tan);
else if (command == "logging") else if (command == "logging")
handleLoggingCommand(message, command, tan); handleLoggingCommand(message, command, tan);
else if (command == "processing")
handleProcessingCommand(message, command, tan);
else else
handleNotImplemented(); handleNotImplemented();
} }
@ -1272,6 +1274,13 @@ void JsonClientConnection::handleLoggingCommand(const QJsonObject& message, cons
sendSuccessReply(command+"-"+subcommand,tan); sendSuccessReply(command+"-"+subcommand,tan);
} }
void JsonClientConnection::handleProcessingCommand(const QJsonObject& message, const QString &command, const int tan)
{
_hyperion->setLedMappingType(ImageProcessor::mappingTypeToInt( message["mappingType"].toString("multicolor_mean")) );
sendSuccessReply(command, tan);
}
void JsonClientConnection::incommingLogMessage(Logger::T_LOG_MESSAGE msg) void JsonClientConnection::incommingLogMessage(Logger::T_LOG_MESSAGE msg)
{ {
QJsonObject result, message; QJsonObject result, message;

View File

@ -265,6 +265,12 @@ private:
/// ///
void handleLoggingCommand(const QJsonObject & message, const QString &command, const int tan); void handleLoggingCommand(const QJsonObject & message, const QString &command, const int tan);
/// Handle an incoming JSON Proccessing message
///
/// @param message the incoming message
///
void handleProcessingCommand(const QJsonObject & message, const QString &command, const int tan);
/// ///
/// Handle an incoming JSON message of unknown type /// Handle an incoming JSON message of unknown type
/// ///

View File

@ -16,5 +16,6 @@
<file alias="schema-componentstate">schema/schema-componentstate.json</file> <file alias="schema-componentstate">schema/schema-componentstate.json</file>
<file alias="schema-ledcolors">schema/schema-ledcolors.json</file> <file alias="schema-ledcolors">schema/schema-ledcolors.json</file>
<file alias="schema-logging">schema/schema-logging.json</file> <file alias="schema-logging">schema/schema-logging.json</file>
<file alias="schema-processing">schema/schema-processing.json</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -0,0 +1,19 @@
{
"type":"object",
"required":true,
"properties":{
"command": {
"type" : "string",
"required" : true,
"enum" : ["processing"]
},
"tan" : {
"type" : "integer"
},
"mappingType": {
"type" : "string",
"enum" : ["multicolor_mean", "unicolor_mean"]
}
},
"additionalProperties": false
}

View File

@ -5,7 +5,7 @@
"command": { "command": {
"type" : "string", "type" : "string",
"required" : true, "required" : true,
"enum" : ["color", "image", "effect", "create-effect", "delete-effect", "serverinfo", "clear", "clearall", "transform", "adjustment", "sourceselect", "config", "componentstate", "ledcolors", "logging"] "enum" : ["color", "image", "effect", "create-effect", "delete-effect", "serverinfo", "clear", "clearall", "transform", "adjustment", "sourceselect", "config", "componentstate", "ledcolors", "logging", "processing"]
} }
} }
} }

View File

@ -545,6 +545,17 @@ void JsonConnection::setAdjustment(const QString &adjustmentId,
parseReply(reply); parseReply(reply);
} }
void JsonConnection::setLedMapping(QString mappingType)
{
QJsonObject command;
command["command"] = QString("processing");
command["mappingType"] = mappingType;
QJsonObject reply = sendMessage(command);
parseReply(reply);
}
QJsonObject JsonConnection::sendMessage(const QJsonObject & message) QJsonObject JsonConnection::sendMessage(const QJsonObject & message)
{ {
// serialize message // serialize message

View File

@ -167,6 +167,12 @@ public:
const QColor & greenAdjustment, const QColor & greenAdjustment,
const QColor & blueAdjustment); const QColor & blueAdjustment);
///
/// sets the image to leds mapping type
///
/// @param mappingType led mapping type
void setLedMapping(QString mappingType);
private: private:
/// ///
/// Send a json command message and receive its reply /// Send a json command message and receive its reply

View File

@ -87,6 +87,7 @@ int main(int argc, char * argv[])
ColorOption & argRAdjust = parser.add<ColorOption> ('R', "redAdjustment" , "Set the adjustment of the red color (requires colors in hex format as RRGGBB)"); ColorOption & argRAdjust = parser.add<ColorOption> ('R', "redAdjustment" , "Set the adjustment of the red color (requires colors in hex format as RRGGBB)");
ColorOption & argGAdjust = parser.add<ColorOption> ('G', "greenAdjustment", "Set the adjustment of the green color (requires colors in hex format as RRGGBB)"); ColorOption & argGAdjust = parser.add<ColorOption> ('G', "greenAdjustment", "Set the adjustment of the green color (requires colors in hex format as RRGGBB)");
ColorOption & argBAdjust = parser.add<ColorOption> ('B', "blueAdjustment", "Set the adjustment of the blue color (requires colors in hex format as RRGGBB)"); ColorOption & argBAdjust = parser.add<ColorOption> ('B', "blueAdjustment", "Set the adjustment of the blue color (requires colors in hex format as RRGGBB)");
Option & argMapping = parser.add<Option> ('M', "ledMapping" , "Set the methode for image to led mapping valif values: multicolor:mean, unicolor_mean");
IntOption & argSource = parser.add<IntOption> (0x0, "sourceSelect" , "Set current active priority channel and deactivate auto source switching"); IntOption & argSource = parser.add<IntOption> (0x0, "sourceSelect" , "Set current active priority channel and deactivate auto source switching");
BooleanOption & argSourceAuto = parser.add<BooleanOption>(0x0, "sourceAutoSelect", "Enables auto source, if disabled prio by manual selecting input source"); BooleanOption & argSourceAuto = parser.add<BooleanOption>(0x0, "sourceAutoSelect", "Enables auto source, if disabled prio by manual selecting input source");
BooleanOption & argSourceOff = parser.add<BooleanOption>(0x0, "sourceOff", "select no source, this results in leds activly set to black (=off)"); BooleanOption & argSourceOff = parser.add<BooleanOption>(0x0, "sourceOff", "select no source, this results in leds activly set to black (=off)");
@ -104,12 +105,16 @@ int main(int argc, char * argv[])
} }
// check if at least one of the available color transforms is set // check if at least one of the available color transforms is set
bool colorTransform = parser.isSet(argSaturation) || parser.isSet(argValue) || parser.isSet(argSaturationL) || parser.isSet(argLuminance) || parser.isSet(argLuminanceMin) || parser.isSet(argThreshold) || parser.isSet(argGamma) || parser.isSet(argBlacklevel) || parser.isSet(argWhitelevel); bool colorTransform = parser.isSet(argSaturation) || parser.isSet(argValue) || parser.isSet(argSaturationL) || parser.isSet(argLuminance)
|| parser.isSet(argLuminanceMin) || parser.isSet(argThreshold) || parser.isSet(argGamma) || parser.isSet(argBlacklevel) || parser.isSet(argWhitelevel);
bool colorAdjust = parser.isSet(argRAdjust) || parser.isSet(argGAdjust) || parser.isSet(argBAdjust); bool colorAdjust = parser.isSet(argRAdjust) || parser.isSet(argGAdjust) || parser.isSet(argBAdjust);
bool colorModding = colorTransform || colorAdjust; bool colorModding = colorTransform || colorAdjust;
// check that exactly one command was given // check that exactly one command was given
int commandCount = count({parser.isSet(argColor), parser.isSet(argImage), parser.isSet(argEffect), parser.isSet(argCreateEffect), parser.isSet(argDeleteEffect), parser.isSet(argServerInfo), parser.isSet(argClear), parser.isSet(argClearAll), parser.isSet(argEnableComponent), parser.isSet(argDisableComponent), colorModding, parser.isSet(argSource), parser.isSet(argSourceAuto), parser.isSet(argSourceOff), parser.isSet(argConfigGet), parser.isSet(argSchemaGet), parser.isSet(argConfigSet)}); int commandCount = count({ parser.isSet(argColor), parser.isSet(argImage), parser.isSet(argEffect), parser.isSet(argCreateEffect), parser.isSet(argDeleteEffect),
parser.isSet(argServerInfo), parser.isSet(argClear), parser.isSet(argClearAll), parser.isSet(argEnableComponent), parser.isSet(argDisableComponent), colorModding,
parser.isSet(argSource), parser.isSet(argSourceAuto), parser.isSet(argSourceOff), parser.isSet(argConfigGet), parser.isSet(argSchemaGet), parser.isSet(argConfigSet),
parser.isSet(argMapping) });
if (commandCount != 1) if (commandCount != 1)
{ {
qWarning() << (commandCount == 0 ? "No command found." : "Multiple commands found.") << " Provide exactly one of the following options:"; qWarning() << (commandCount == 0 ? "No command found." : "Multiple commands found.") << " Provide exactly one of the following options:";
@ -216,6 +221,10 @@ int main(int argc, char * argv[])
{ {
connection.setConfig(argConfigSet.value(parser)); connection.setConfig(argConfigSet.value(parser));
} }
else if (parser.isSet(argMapping))
{
connection.setLedMapping(argMapping.value(parser));
}
else if (colorModding) else if (colorModding)
{ {
if (colorAdjust) if (colorAdjust)