mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Adjustment merge + new brightness settings (#359)
* add new rgbtransform * activate rgbtransform * integrate new transform and gamma in adjustment, disable transform * fix brighness limit * advance upper and lower thresholds * start removing color transform * adjust configs/schema * implement json for new color adjustment * finish hyperion-remote extension for new adjustment settings * fix typos * rename luminance to brightness fix jsonapi for new adjustment * fix some bugs in adjustments * fix i18n * fix gamma via json * now brighness values goes from 0-1 with 0.5 is the default for all brighness is equal between the channels. less 0.5 all channels scaled down to new brighness, above 0.5 if possible channel gets brighter - but brighness is not equal between the channels anymore brighness value curve is now exponential instead of linear - this feels more natural * hslv cleanup
This commit is contained in:
@@ -19,7 +19,6 @@ SET(Hyperion_HEADERS
|
||||
${CURRENT_HEADER_DIR}/LedString.h
|
||||
${CURRENT_HEADER_DIR}/PriorityMuxer.h
|
||||
|
||||
${CURRENT_SOURCE_DIR}/MultiColorTransform.h
|
||||
${CURRENT_SOURCE_DIR}/MultiColorAdjustment.h
|
||||
${CURRENT_HEADER_DIR}/MessageForwarder.h
|
||||
)
|
||||
@@ -32,7 +31,6 @@ SET(Hyperion_SOURCES
|
||||
${CURRENT_SOURCE_DIR}/PriorityMuxer.cpp
|
||||
|
||||
${CURRENT_SOURCE_DIR}/ImageToLedsMap.cpp
|
||||
${CURRENT_SOURCE_DIR}/MultiColorTransform.cpp
|
||||
${CURRENT_SOURCE_DIR}/MultiColorAdjustment.cpp
|
||||
${CURRENT_SOURCE_DIR}/LinearColorSmoothing.cpp
|
||||
${CURRENT_SOURCE_DIR}/MessageForwarder.cpp
|
||||
|
@@ -18,14 +18,12 @@
|
||||
#include <hyperion/Hyperion.h>
|
||||
#include <hyperion/ImageProcessorFactory.h>
|
||||
#include <hyperion/ImageProcessor.h>
|
||||
#include <hyperion/ColorTransform.h>
|
||||
#include <hyperion/ColorAdjustment.h>
|
||||
|
||||
// Leddevice includes
|
||||
#include <leddevice/LedDevice.h>
|
||||
#include <leddevice/LedDeviceFactory.h>
|
||||
|
||||
#include "MultiColorTransform.h"
|
||||
#include "MultiColorAdjustment.h"
|
||||
#include "LinearColorSmoothing.h"
|
||||
|
||||
@@ -56,37 +54,6 @@ ColorOrder Hyperion::createColorOrder(const QJsonObject &deviceConfig)
|
||||
return stringToColorOrder(deviceConfig["colorOrder"].toString("rgb"));
|
||||
}
|
||||
|
||||
ColorTransform * Hyperion::createColorTransform(const QJsonObject & transformConfig)
|
||||
{
|
||||
const std::string id = transformConfig["id"].toString("default").toStdString();
|
||||
|
||||
RgbChannelTransform * redTransform = createRgbChannelTransform(transformConfig["red"].toObject());
|
||||
RgbChannelTransform * greenTransform = createRgbChannelTransform(transformConfig["green"].toObject());
|
||||
RgbChannelTransform * blueTransform = createRgbChannelTransform(transformConfig["blue"].toObject());
|
||||
|
||||
HsvTransform * hsvTransform = createHsvTransform(transformConfig["hsv"].toObject());
|
||||
HslTransform * hslTransform = createHslTransform(transformConfig["hsl"].toObject());
|
||||
|
||||
ColorTransform * transform = new ColorTransform();
|
||||
transform->_id = id;
|
||||
transform->_rgbRedTransform = *redTransform;
|
||||
transform->_rgbGreenTransform = *greenTransform;
|
||||
transform->_rgbBlueTransform = *blueTransform;
|
||||
transform->_hsvTransform = *hsvTransform;
|
||||
transform->_hslTransform = *hslTransform;
|
||||
|
||||
|
||||
// Cleanup the allocated individual transforms
|
||||
delete redTransform;
|
||||
delete greenTransform;
|
||||
delete blueTransform;
|
||||
delete hsvTransform;
|
||||
delete hslTransform;
|
||||
|
||||
return transform;
|
||||
}
|
||||
|
||||
|
||||
ColorAdjustment * Hyperion::createColorAdjustment(const QJsonObject & adjustmentConfig)
|
||||
{
|
||||
const std::string id = adjustmentConfig["id"].toString("default").toStdString();
|
||||
@@ -109,7 +76,8 @@ ColorAdjustment * Hyperion::createColorAdjustment(const QJsonObject & adjustment
|
||||
RgbChannelAdjustment * cyanAdjustment = createRgbChannelAdjustment(adjustmentConfig["cyan"].toArray(),CYAN);
|
||||
RgbChannelAdjustment * magentaAdjustment = createRgbChannelAdjustment(adjustmentConfig["magenta"].toArray(),MAGENTA);
|
||||
RgbChannelAdjustment * yellowAdjustment = createRgbChannelAdjustment(adjustmentConfig["yellow"].toArray(),YELLOW);
|
||||
|
||||
RgbTransform * rgbTransform = createRgbTransform(adjustmentConfig);
|
||||
|
||||
ColorAdjustment * adjustment = new ColorAdjustment();
|
||||
adjustment->_id = id;
|
||||
adjustment->_rgbBlackAdjustment = *blackAdjustment;
|
||||
@@ -120,6 +88,7 @@ ColorAdjustment * Hyperion::createColorAdjustment(const QJsonObject & adjustment
|
||||
adjustment->_rgbCyanAdjustment = *cyanAdjustment;
|
||||
adjustment->_rgbMagentaAdjustment = *magentaAdjustment;
|
||||
adjustment->_rgbYellowAdjustment = *yellowAdjustment;
|
||||
adjustment->_rgbTransform = *rgbTransform;
|
||||
|
||||
// Cleanup the allocated individual adjustments
|
||||
delete blackAdjustment;
|
||||
@@ -130,86 +99,12 @@ ColorAdjustment * Hyperion::createColorAdjustment(const QJsonObject & adjustment
|
||||
delete cyanAdjustment;
|
||||
delete magentaAdjustment;
|
||||
delete yellowAdjustment;
|
||||
|
||||
delete rgbTransform;
|
||||
|
||||
return adjustment;
|
||||
}
|
||||
|
||||
|
||||
MultiColorTransform * Hyperion::createLedColorsTransform(const unsigned ledCnt, const QJsonObject & colorConfig)
|
||||
{
|
||||
// Create the result, the transforms are added to this
|
||||
MultiColorTransform * transform = new MultiColorTransform(ledCnt);
|
||||
Logger * log = Logger::getInstance("Core");
|
||||
|
||||
const QJsonValue transformConfig = colorConfig["transform"];
|
||||
if (transformConfig.isNull())
|
||||
{
|
||||
// Old style color transformation config (just one for all leds)
|
||||
ColorTransform * colorTransform = createColorTransform(colorConfig);
|
||||
transform->addTransform(colorTransform);
|
||||
transform->setTransformForLed(colorTransform->_id, 0, ledCnt-1);
|
||||
}
|
||||
else if (transformConfig.isObject())
|
||||
{
|
||||
ColorTransform * colorTransform = createColorTransform(transformConfig.toObject());
|
||||
transform->addTransform(colorTransform);
|
||||
transform->setTransformForLed(colorTransform->_id, 0, ledCnt-1);
|
||||
}
|
||||
else if (transformConfig.isArray())
|
||||
{
|
||||
const QRegExp overallExp("([0-9]+(\\-[0-9]+)?)(,[ ]*([0-9]+(\\-[0-9]+)?))*");
|
||||
|
||||
const QJsonArray & transformConfigArray = transformConfig.toArray();
|
||||
for (signed i = 0; i < transformConfigArray.size(); ++i)
|
||||
{
|
||||
const QJsonObject & config = transformConfigArray[i].toObject();
|
||||
ColorTransform * colorTransform = createColorTransform(config);
|
||||
transform->addTransform(colorTransform);
|
||||
|
||||
const QString ledIndicesStr = config["leds"].toString("").trimmed();
|
||||
if (ledIndicesStr.compare("*") == 0)
|
||||
{
|
||||
// Special case for indices '*' => all leds
|
||||
transform->setTransformForLed(colorTransform->_id, 0, ledCnt-1);
|
||||
Info(log, "ColorTransform '%s' => [0; %d]", colorTransform->_id.c_str(), ledCnt-1);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!overallExp.exactMatch(ledIndicesStr))
|
||||
{
|
||||
Error(log, "Given led indices %d not correct format: %s", i, ledIndicesStr.toStdString().c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
const QStringList ledIndexList = ledIndicesStr.split(",");
|
||||
for (int i=0; i<ledIndexList.size(); ++i) {
|
||||
if (i > 0)
|
||||
{
|
||||
ss << ", ";
|
||||
}
|
||||
if (ledIndexList[i].contains("-"))
|
||||
{
|
||||
QStringList ledIndices = ledIndexList[i].split("-");
|
||||
int startInd = ledIndices[0].toInt();
|
||||
int endInd = ledIndices[1].toInt();
|
||||
|
||||
transform->setTransformForLed(colorTransform->_id, startInd, endInd);
|
||||
ss << startInd << "-" << endInd;
|
||||
}
|
||||
else
|
||||
{
|
||||
int index = ledIndexList[i].toInt();
|
||||
transform->setTransformForLed(colorTransform->_id, index, index);
|
||||
ss << index;
|
||||
}
|
||||
}
|
||||
Info(log, "ColorTransform '%s' => [%s]", colorTransform->_id.c_str(), ss.str().c_str());
|
||||
}
|
||||
}
|
||||
return transform;
|
||||
}
|
||||
|
||||
MultiColorAdjustment * Hyperion::createLedColorsAdjustment(const unsigned ledCnt, const QJsonObject & colorConfig)
|
||||
{
|
||||
// Create the result, the transforms are added to this
|
||||
@@ -285,31 +180,15 @@ MultiColorAdjustment * Hyperion::createLedColorsAdjustment(const unsigned ledCnt
|
||||
return adjustment;
|
||||
}
|
||||
|
||||
HsvTransform * Hyperion::createHsvTransform(const QJsonObject & hsvConfig)
|
||||
RgbTransform* Hyperion::createRgbTransform(const QJsonObject& colorConfig)
|
||||
{
|
||||
const double saturationGain = hsvConfig["saturationGain"].toDouble(1.0);
|
||||
const double valueGain = hsvConfig["valueGain"].toDouble(1.0);
|
||||
const double brightnessMin = colorConfig["brightnessMin"].toDouble(0.0);
|
||||
const double brightness = colorConfig["brightness"].toDouble(0.5);
|
||||
const double gammaR = colorConfig["gammaRed"].toDouble(1.0);
|
||||
const double gammaG = colorConfig["gammaGreen"].toDouble(1.0);
|
||||
const double gammaB = colorConfig["gammaBlue"].toDouble(1.0);
|
||||
|
||||
return new HsvTransform(saturationGain, valueGain);
|
||||
}
|
||||
|
||||
HslTransform * Hyperion::createHslTransform(const QJsonObject & hslConfig)
|
||||
{
|
||||
const double saturationGain = hslConfig["saturationGain"].toDouble(1.0);
|
||||
const double luminanceGain = hslConfig["luminanceGain"].toDouble(1.0);
|
||||
const double luminanceMinimum = hslConfig["luminanceMinimum"].toDouble(0.0);
|
||||
|
||||
return new HslTransform(saturationGain, luminanceGain, luminanceMinimum);
|
||||
}
|
||||
|
||||
RgbChannelTransform* Hyperion::createRgbChannelTransform(const QJsonObject& colorConfig)
|
||||
{
|
||||
const double threshold = colorConfig["threshold"].toDouble(0.0);
|
||||
const double gamma = colorConfig["gamma"].toDouble(1.0);
|
||||
const double blacklevel = colorConfig["blacklevel"].toDouble(0.0);
|
||||
const double whitelevel = colorConfig["whitelevel"].toDouble(1.0);
|
||||
|
||||
RgbChannelTransform* transform = new RgbChannelTransform(threshold, gamma, blacklevel, whitelevel);
|
||||
RgbTransform* transform = new RgbTransform(gammaR, gammaG, gammaB, brightnessMin, brightness);
|
||||
return transform;
|
||||
}
|
||||
|
||||
@@ -575,7 +454,6 @@ Hyperion::Hyperion(const QJsonObject &qjsonConfig, const QString configFile)
|
||||
: _ledString(createLedString(qjsonConfig["leds"], createColorOrder(qjsonConfig["device"].toObject())))
|
||||
, _ledStringClone(createLedStringClone(qjsonConfig["leds"], createColorOrder(qjsonConfig["device"].toObject())))
|
||||
, _muxer(_ledString.leds().size())
|
||||
, _raw2ledTransform(createLedColorsTransform(_ledString.leds().size(), qjsonConfig["color"].toObject()))
|
||||
, _raw2ledAdjustment(createLedColorsAdjustment(_ledString.leds().size(), qjsonConfig["color"].toObject()))
|
||||
, _effectEngine(nullptr)
|
||||
, _messageForwarder(createMessageForwarder(qjsonConfig["forwarder"].toObject()))
|
||||
@@ -585,33 +463,22 @@ Hyperion::Hyperion(const QJsonObject &qjsonConfig, const QString configFile)
|
||||
, _log(Logger::getInstance("Core"))
|
||||
, _hwLedCount(_ledString.leds().size())
|
||||
, _colorAdjustmentV4Lonly(false)
|
||||
, _colorTransformV4Lonly(false)
|
||||
, _sourceAutoSelectEnabled(true)
|
||||
, _configHash()
|
||||
, _ledGridSize(getLedLayoutGridSize(qjsonConfig["leds"]))
|
||||
{
|
||||
registerPriority("Off", PriorityMuxer::LOWEST_PRIORITY);
|
||||
|
||||
|
||||
if (!_raw2ledAdjustment->verifyAdjustments())
|
||||
{
|
||||
throw std::runtime_error("Color adjustment incorrectly set");
|
||||
}
|
||||
if (!_raw2ledTransform->verifyTransforms())
|
||||
{
|
||||
throw std::runtime_error("Color transformation incorrectly set");
|
||||
}
|
||||
// set color correction activity state
|
||||
const QJsonObject& color = qjsonConfig["color"].toObject();
|
||||
_transformEnabled = color["transform_enable"].toBool(true);
|
||||
_adjustmentEnabled = color["channelAdjustment_enable"].toBool(true);
|
||||
|
||||
_colorTransformV4Lonly = color["transform_v4l_only"].toBool(false);
|
||||
_colorAdjustmentV4Lonly = color["channelAdjustment_v4l_only"].toBool(false);
|
||||
|
||||
InfoIf(!_transformEnabled , _log, "Color transformation disabled" );
|
||||
InfoIf(!_adjustmentEnabled , _log, "Color adjustment disabled" );
|
||||
|
||||
InfoIf(_colorTransformV4Lonly , _log, "Color transformation for v4l inputs only" );
|
||||
InfoIf(_colorAdjustmentV4Lonly , _log, "Color adjustment for v4l inputs only" );
|
||||
|
||||
// initialize the image processor factory
|
||||
@@ -659,7 +526,6 @@ void Hyperion::freeObjects()
|
||||
// delete components on exit of hyperion core
|
||||
delete _effectEngine;
|
||||
delete _device;
|
||||
delete _raw2ledTransform;
|
||||
delete _raw2ledAdjustment;
|
||||
delete _messageForwarder;
|
||||
}
|
||||
@@ -805,31 +671,16 @@ void Hyperion::setImage(int priority, const Image<ColorRgb> & image, int duratio
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<std::string> & Hyperion::getTransformIds() const
|
||||
{
|
||||
return _raw2ledTransform->getTransformIds();
|
||||
}
|
||||
|
||||
const std::vector<std::string> & Hyperion::getAdjustmentIds() const
|
||||
{
|
||||
return _raw2ledAdjustment->getAdjustmentIds();
|
||||
}
|
||||
|
||||
ColorTransform * Hyperion::getTransform(const std::string& id)
|
||||
{
|
||||
return _raw2ledTransform->getTransform(id);
|
||||
}
|
||||
|
||||
ColorAdjustment * Hyperion::getAdjustment(const std::string& id)
|
||||
{
|
||||
return _raw2ledAdjustment->getAdjustment(id);
|
||||
}
|
||||
|
||||
void Hyperion::transformsUpdated()
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
void Hyperion::adjustmentsUpdated()
|
||||
{
|
||||
update();
|
||||
@@ -929,11 +780,7 @@ void Hyperion::update()
|
||||
_ledBuffer.reserve(_hwLedCount);
|
||||
_ledBuffer = priorityInfo.ledColors;
|
||||
|
||||
if ( _transformEnabled && (!_colorTransformV4Lonly || priorityInfo.componentId == hyperion::COMP_V4L) )
|
||||
{
|
||||
_raw2ledTransform->applyTransform(_ledBuffer);
|
||||
}
|
||||
if ( _adjustmentEnabled && (!_colorAdjustmentV4Lonly || priorityInfo.componentId == hyperion::COMP_V4L) )
|
||||
if ( _adjustmentEnabled && priority < PriorityMuxer::LOWEST_PRIORITY && (!_colorAdjustmentV4Lonly || priorityInfo.componentId == hyperion::COMP_V4L) )
|
||||
{
|
||||
_raw2ledAdjustment->applyAdjustment(_ledBuffer);
|
||||
}
|
||||
|
@@ -43,11 +43,19 @@ bool MultiColorAdjustment::verifyAdjustments() const
|
||||
{
|
||||
for (unsigned iLed=0; iLed<_ledAdjustments.size(); ++iLed)
|
||||
{
|
||||
if (_ledAdjustments[iLed] == nullptr)
|
||||
ColorAdjustment * adjustment = _ledAdjustments[iLed];
|
||||
|
||||
if (adjustment == nullptr)
|
||||
{
|
||||
Warning(Logger::getInstance("ColorAdjust"), "No adjustment set for %d", iLed);
|
||||
Error(Logger::getInstance("ColorAdjust"), "No adjustment set for %d", iLed);
|
||||
return false;
|
||||
}
|
||||
if (adjustment->_rgbTransform.getBrightness() <= adjustment->_rgbTransform.getBrightnessMin() )
|
||||
{
|
||||
adjustment->_rgbTransform.setBrightnessMin(0);
|
||||
adjustment->_rgbTransform.setBrightness(0.5);
|
||||
Warning(Logger::getInstance("ColorAdjust"), "Adjustment for %d has invalid Brightness values, values set to default. (brightnessMin is bigger then brightness)", iLed);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -84,20 +92,26 @@ void MultiColorAdjustment::applyAdjustment(std::vector<ColorRgb>& ledColors)
|
||||
continue;
|
||||
}
|
||||
ColorRgb& color = ledColors[i];
|
||||
|
||||
uint8_t ored = color.red;
|
||||
uint8_t ogreen = color.green;
|
||||
uint8_t oblue = color.blue;
|
||||
|
||||
uint32_t nrng = (uint32_t) (255-color.red)*(255-color.green);
|
||||
uint32_t rng = (uint32_t) (color.red) *(255-color.green);
|
||||
uint32_t nrg = (uint32_t) (255-color.red)*(color.green);
|
||||
uint32_t rg = (uint32_t) (color.red) *(color.green);
|
||||
adjustment->_rgbTransform.transform(ored,ogreen,oblue);
|
||||
|
||||
uint32_t nrng = (uint32_t) (255-ored)*(255-ogreen);
|
||||
uint32_t rng = (uint32_t) (ored) *(255-ogreen);
|
||||
uint32_t nrg = (uint32_t) (255-ored)*(ogreen);
|
||||
uint32_t rg = (uint32_t) (ored) *(ogreen);
|
||||
|
||||
uint8_t black = nrng*(255-color.blue)/65025;
|
||||
uint8_t red = rng *(255-color.blue)/65025;
|
||||
uint8_t green = nrg *(255-color.blue)/65025;
|
||||
uint8_t blue = nrng*(color.blue) /65025;
|
||||
uint8_t cyan = nrg *(color.blue) /65025;
|
||||
uint8_t magenta = rng *(color.blue) /65025;
|
||||
uint8_t yellow = rg *(255-color.blue)/65025;
|
||||
uint8_t white = rg *(color.blue) /65025;
|
||||
uint8_t black = nrng*(255-oblue)/65025;
|
||||
uint8_t red = rng *(255-oblue)/65025;
|
||||
uint8_t green = nrg *(255-oblue)/65025;
|
||||
uint8_t blue = nrng*(oblue) /65025;
|
||||
uint8_t cyan = nrg *(oblue) /65025;
|
||||
uint8_t magenta = rng *(oblue) /65025;
|
||||
uint8_t yellow = rg *(255-oblue)/65025;
|
||||
uint8_t white = rg *(oblue) /65025;
|
||||
|
||||
uint8_t OR = adjustment->_rgbBlackAdjustment.getAdjustmentR(black);
|
||||
uint8_t OG = adjustment->_rgbBlackAdjustment.getAdjustmentG(black);
|
||||
|
@@ -1,94 +0,0 @@
|
||||
|
||||
// STL includes
|
||||
#include <cassert>
|
||||
|
||||
// Hyperion includes
|
||||
#include <utils/Logger.h>
|
||||
#include "MultiColorTransform.h"
|
||||
|
||||
MultiColorTransform::MultiColorTransform(const unsigned ledCnt) :
|
||||
_ledTransforms(ledCnt, nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
MultiColorTransform::~MultiColorTransform()
|
||||
{
|
||||
// Clean up all the transforms
|
||||
for (ColorTransform * transform : _transform)
|
||||
{
|
||||
delete transform;
|
||||
}
|
||||
}
|
||||
|
||||
void MultiColorTransform::addTransform(ColorTransform * transform)
|
||||
{
|
||||
_transformIds.push_back(transform->_id);
|
||||
_transform.push_back(transform);
|
||||
}
|
||||
|
||||
void MultiColorTransform::setTransformForLed(const std::string& id, const unsigned startLed, const unsigned endLed)
|
||||
{
|
||||
assert(startLed <= endLed);
|
||||
assert(endLed < _ledTransforms.size());
|
||||
|
||||
// Get the identified transform (don't care if is nullptr)
|
||||
ColorTransform * transform = getTransform(id);
|
||||
for (unsigned iLed=startLed; iLed<=endLed; ++iLed)
|
||||
{
|
||||
_ledTransforms[iLed] = transform;
|
||||
}
|
||||
}
|
||||
|
||||
bool MultiColorTransform::verifyTransforms() const
|
||||
{
|
||||
for (unsigned iLed=0; iLed<_ledTransforms.size(); ++iLed)
|
||||
{
|
||||
if (_ledTransforms[iLed] == nullptr)
|
||||
{
|
||||
Warning(Logger::getInstance("ColorTransform"), "No adjustment set for %d", iLed);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const std::vector<std::string> & MultiColorTransform::getTransformIds()
|
||||
{
|
||||
return _transformIds;
|
||||
}
|
||||
|
||||
ColorTransform* MultiColorTransform::getTransform(const std::string& id)
|
||||
{
|
||||
// Iterate through the unique transforms until we find the one with the given id
|
||||
for (ColorTransform* transform : _transform)
|
||||
{
|
||||
if (transform->_id == id)
|
||||
{
|
||||
return transform;
|
||||
}
|
||||
}
|
||||
|
||||
// The ColorTransform was not found
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void MultiColorTransform::applyTransform(std::vector<ColorRgb>& ledColors)
|
||||
{
|
||||
const size_t itCnt = std::min(_ledTransforms.size(), ledColors.size());
|
||||
for (size_t i=0; i<itCnt; ++i)
|
||||
{
|
||||
ColorTransform* transform = _ledTransforms[i];
|
||||
if (transform == nullptr)
|
||||
{
|
||||
// No transform set for this led (do nothing)
|
||||
continue;
|
||||
}
|
||||
ColorRgb& color = ledColors[i];
|
||||
|
||||
transform->_hsvTransform.transform(color.red, color.green, color.blue);
|
||||
transform->_hslTransform.transform(color.red, color.green, color.blue);
|
||||
color.red = transform->_rgbRedTransform.transform(color.red);
|
||||
color.green = transform->_rgbGreenTransform.transform(color.green);
|
||||
color.blue = transform->_rgbBlueTransform.transform(color.blue);
|
||||
}
|
||||
}
|
@@ -1,64 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// STL includes
|
||||
#include <vector>
|
||||
|
||||
// Utils includes
|
||||
#include <utils/ColorRgb.h>
|
||||
|
||||
// Hyperion includes
|
||||
#include <hyperion/ColorTransform.h>
|
||||
|
||||
///
|
||||
/// The LedColorTransform is responsible for performing color transformation from 'raw' colors
|
||||
/// received as input to colors mapped to match the color-properties of the leds.
|
||||
///
|
||||
class MultiColorTransform
|
||||
{
|
||||
public:
|
||||
MultiColorTransform(const unsigned ledCnt);
|
||||
~MultiColorTransform();
|
||||
|
||||
/**
|
||||
* Adds a new ColorTransform to this MultiColorTransform
|
||||
*
|
||||
* @param transform The new ColorTransform (ownership is transfered)
|
||||
*/
|
||||
void addTransform(ColorTransform * transform);
|
||||
|
||||
void setTransformForLed(const std::string& id, const unsigned startLed, const unsigned endLed);
|
||||
|
||||
bool verifyTransforms() const;
|
||||
|
||||
///
|
||||
/// Returns the identifier of all the unique ColorTransform
|
||||
///
|
||||
/// @return The list with unique id's of the ColorTransforms
|
||||
const std::vector<std::string> & getTransformIds();
|
||||
|
||||
///
|
||||
/// Returns the pointer to the ColorTransform with the given id
|
||||
///
|
||||
/// @param id The identifier of the ColorTransform
|
||||
///
|
||||
/// @return The ColorTransform with the given id (or nullptr if it does not exist)
|
||||
///
|
||||
ColorTransform* getTransform(const std::string& id);
|
||||
|
||||
///
|
||||
/// Performs the color transoformation from raw-color to led-color
|
||||
///
|
||||
/// @param ledColors The list with raw colors
|
||||
///
|
||||
void applyTransform(std::vector<ColorRgb>& ledColors);
|
||||
|
||||
private:
|
||||
/// List with transform ids
|
||||
std::vector<std::string> _transformIds;
|
||||
|
||||
/// List with unique ColorTransforms
|
||||
std::vector<ColorTransform*> _transform;
|
||||
|
||||
/// List with a pointer to the ColorTransform for each individual led
|
||||
std::vector<ColorTransform*> _ledTransforms;
|
||||
};
|
@@ -90,7 +90,7 @@
|
||||
"append" : "edt_append_ms",
|
||||
"minimum": 0,
|
||||
"access" : "expert",
|
||||
"propertOrder" : 4
|
||||
"propertyOrder" : 4
|
||||
}
|
||||
},
|
||||
"additionalProperties" : true
|
||||
@@ -100,7 +100,7 @@
|
||||
"type":"object",
|
||||
"title" : "edt_conf_color_heading_title",
|
||||
"required" : true,
|
||||
"defaultProperties": ["imageToLedMappingType","channelAdjustment_enable","channelAdjustment","transform_enable","transform"],
|
||||
"defaultProperties": ["imageToLedMappingType","channelAdjustment_enable","channelAdjustment"],
|
||||
"properties":
|
||||
{
|
||||
"imageToLedMappingType" :
|
||||
@@ -283,153 +283,61 @@
|
||||
"minItems" : 3,
|
||||
"maxItems" : 3,
|
||||
"propertyOrder" : 10
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
}
|
||||
},
|
||||
"transform_enable" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"default" : true,
|
||||
"propertyOrder" : 5
|
||||
},
|
||||
"transform_v4l_only" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"default" : false,
|
||||
"propertyOrder" : 6
|
||||
},
|
||||
"transform" :
|
||||
{
|
||||
"type" : "array",
|
||||
"required" : true,
|
||||
"propertyOrder" : 7,
|
||||
"items" :
|
||||
{
|
||||
"type" : "object",
|
||||
"required" : true,
|
||||
"properties" :
|
||||
{
|
||||
"id" :
|
||||
{
|
||||
"type" : "string",
|
||||
"required" : true
|
||||
},
|
||||
"leds" :
|
||||
"brightnessMin" :
|
||||
{
|
||||
"type" : "string",
|
||||
"required" : true
|
||||
},
|
||||
"hsv" : {
|
||||
"type" : "object",
|
||||
"properties" : {
|
||||
"saturationGain" : {
|
||||
"type" : "number",
|
||||
"minimum" : 0.0
|
||||
},
|
||||
"valueGain" : {
|
||||
"type" : "number",
|
||||
"minimum" : 0.0
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
},
|
||||
"hsl" :
|
||||
{
|
||||
"type":"object",
|
||||
"type" : "number",
|
||||
"title" : "edt_conf_color_brightness_min",
|
||||
"required" : true,
|
||||
"properties":
|
||||
{
|
||||
"saturationGain" :
|
||||
{
|
||||
"type" : "number",
|
||||
"required" : true,
|
||||
"minimum" : 0.0
|
||||
},
|
||||
"luminanceGain" :
|
||||
{
|
||||
"type" : "number",
|
||||
"required" : true,
|
||||
"minimum" : 0.0
|
||||
},
|
||||
"luminanceMinimum" :
|
||||
{
|
||||
"type" : "number",
|
||||
"required" : true,
|
||||
"minimum" : 0.0
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
"minimum" : 0.0,
|
||||
"maximum": 1.0,
|
||||
"default" : 0.0,
|
||||
"step" : 0.05,
|
||||
"propertyOrder" : 11
|
||||
},
|
||||
"red" :
|
||||
"brightness" :
|
||||
{
|
||||
"type":"object",
|
||||
"type" : "number",
|
||||
"title" : "edt_conf_color_brightness",
|
||||
"required" : true,
|
||||
"properties":
|
||||
{
|
||||
"threshold" :
|
||||
{
|
||||
"type" : "number",
|
||||
"required" : true,
|
||||
"minimum" : 0.0,
|
||||
"maximum": 1.0
|
||||
},
|
||||
"gamma" :
|
||||
{
|
||||
"type" : "number",
|
||||
"required" : true,
|
||||
"minimum" : 0.0,
|
||||
"maximum": 100.0
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
"minimum" : 0.0,
|
||||
"maximum": 1.0,
|
||||
"default" : 1.0,
|
||||
"step" : 0.05,
|
||||
"propertyOrder" : 12
|
||||
},
|
||||
"green" :
|
||||
"gammaRed" :
|
||||
{
|
||||
"type":"object",
|
||||
"type" : "number",
|
||||
"title" : "edt_conf_color_gamma_red",
|
||||
"required" : true,
|
||||
"properties":
|
||||
{
|
||||
"threshold" :
|
||||
{
|
||||
"type" : "number",
|
||||
"required" : true,
|
||||
"minimum" : 0.0,
|
||||
"maximum": 1.0
|
||||
},
|
||||
"gamma" :
|
||||
{
|
||||
"type" : "number",
|
||||
"required" : true,
|
||||
"minimum" : 0.0,
|
||||
"maximum": 100.0
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
"minimum" : 0.0,
|
||||
"maximum": 100.0,
|
||||
"default" : 1.0,
|
||||
"step" : 0.1,
|
||||
"propertyOrder" : 13
|
||||
},
|
||||
"blue" :
|
||||
"gammaGreen" :
|
||||
{
|
||||
"type":"object",
|
||||
"type" : "number",
|
||||
"title" : "edt_conf_color_gamma_green",
|
||||
"required" : true,
|
||||
"properties":
|
||||
{
|
||||
"threshold" :
|
||||
{
|
||||
"type" : "number",
|
||||
"required" : true,
|
||||
"minimum" : 0.0,
|
||||
"maximum": 1.0
|
||||
},
|
||||
"gamma" :
|
||||
{
|
||||
"type" : "number",
|
||||
"required" : true,
|
||||
"minimum" : 0.0,
|
||||
"maximum": 100.0
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
"minimum" : 0.0,
|
||||
"maximum": 100.0,
|
||||
"default" : 1.0,
|
||||
"step" : 0.1,
|
||||
"propertyOrder" : 14
|
||||
},
|
||||
"gammaBlue" :
|
||||
{
|
||||
"type" : "number",
|
||||
"title" : "edt_conf_color_gamma_blue",
|
||||
"required" : true,
|
||||
"minimum" : 0.0,
|
||||
"maximum": 100.0,
|
||||
"default" : 1.0,
|
||||
"step" : 0.1,
|
||||
"propertyOrder" : 15
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
|
Reference in New Issue
Block a user