mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
v4l: make suggestions for all no signal values (#339)
* on v4l screenshot, print out nosignal threshold values * separate fractional parameters for no signal detection * fully implement handling for "rainbow grabber" * hyperion-v4l2 --screenshot can also evaluate best reagion and color for no signal detection * tune output of no signal detection * v4l outputs warninsg only, todo: make it adyustable * typo * v4l signal detection, now with validation checks * remove obsolete schema files * fix code style * fix text typos * code style
This commit is contained in:
@@ -7,8 +7,6 @@
|
||||
<file alias="schema-clear">schema/schema-clear.json</file>
|
||||
<file alias="schema-clearall">schema/schema-clearall.json</file>
|
||||
<file alias="schema-transform">schema/schema-transform.json</file>
|
||||
<file alias="schema-correction">schema/schema-correction.json</file>
|
||||
<file alias="schema-temperature">schema/schema-temperature.json</file>
|
||||
<file alias="schema-adjustment">schema/schema-adjustment.json</file>
|
||||
<file alias="schema-effect">schema/schema-effect.json</file>
|
||||
<file alias="schema-create-effect">schema/schema-create-effect.json</file>
|
||||
|
@@ -1,37 +0,0 @@
|
||||
{
|
||||
"type":"object",
|
||||
"required":true,
|
||||
"properties":{
|
||||
"command": {
|
||||
"type" : "string",
|
||||
"required" : true,
|
||||
"enum" : ["correction"]
|
||||
},
|
||||
"tan" : {
|
||||
"type" : "integer"
|
||||
},
|
||||
"correction": {
|
||||
"type": "object",
|
||||
"required": true,
|
||||
"properties": {
|
||||
"id" : {
|
||||
"type" : "string",
|
||||
"required" : false
|
||||
},
|
||||
"correctionValues" : {
|
||||
"type": "array",
|
||||
"required": false,
|
||||
"items" : {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
},
|
||||
"minItems": 3,
|
||||
"maxItems": 3
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
{
|
||||
"type":"object",
|
||||
"required":true,
|
||||
"properties":{
|
||||
"command": {
|
||||
"type" : "string",
|
||||
"required" : true,
|
||||
"enum" : ["temperature"]
|
||||
},
|
||||
"tan" : {
|
||||
"type" : "integer"
|
||||
},
|
||||
"temperature": {
|
||||
"type": "object",
|
||||
"required": true,
|
||||
"properties": {
|
||||
"id" : {
|
||||
"type" : "string",
|
||||
"required" : false
|
||||
},
|
||||
"correctionValues" : {
|
||||
"type": "array",
|
||||
"required": false,
|
||||
"items" : {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
},
|
||||
"minItems": 3,
|
||||
"maxItems": 3
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
@@ -5,7 +5,7 @@
|
||||
"command": {
|
||||
"type" : "string",
|
||||
"required" : true,
|
||||
"enum" : ["color", "image", "effect", "create-effect", "delete-effect", "serverinfo", "clear", "clearall", "transform", "correction", "temperature", "adjustment", "sourceselect", "config", "componentstate", "ledcolors", "logging"]
|
||||
"enum" : ["color", "image", "effect", "create-effect", "delete-effect", "serverinfo", "clear", "clearall", "transform", "adjustment", "sourceselect", "config", "componentstate", "ledcolors", "logging"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -2,10 +2,10 @@
|
||||
#include <cmath>
|
||||
#include <utils/HslTransform.h>
|
||||
|
||||
HslTransform::HslTransform() :
|
||||
_saturationGain(1.0),
|
||||
_luminanceGain(1.0),
|
||||
_luminanceMinimum(0.0)
|
||||
HslTransform::HslTransform()
|
||||
: _saturationGain(1.0)
|
||||
, _luminanceGain(1.0)
|
||||
, _luminanceMinimum(0.0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -57,12 +57,9 @@ void HslTransform::transform(uint8_t & red, uint8_t & green, uint8_t & blue) con
|
||||
uint16_t hue;
|
||||
float saturation, luminance;
|
||||
rgb2hsl(red, green, blue, hue, saturation, luminance);
|
||||
|
||||
|
||||
float s = saturation * _saturationGain;
|
||||
if (s > 1.0f)
|
||||
saturation = 1.0f;
|
||||
else
|
||||
saturation = s;
|
||||
saturation = std::min(s, 1.0f);
|
||||
|
||||
float l = luminance * _luminanceGain;
|
||||
if (l < _luminanceMinimum)
|
||||
@@ -70,39 +67,36 @@ void HslTransform::transform(uint8_t & red, uint8_t & green, uint8_t & blue) con
|
||||
saturation = 0;
|
||||
l = _luminanceMinimum;
|
||||
}
|
||||
if (l > 1.0f)
|
||||
luminance = 1.0f;
|
||||
else
|
||||
luminance = l;
|
||||
|
||||
luminance = std::min(l, 1.0f);
|
||||
|
||||
hsl2rgb(hue, saturation, luminance, red, green, blue);
|
||||
}
|
||||
}
|
||||
|
||||
void HslTransform::rgb2hsl(uint8_t red, uint8_t green, uint8_t blue, uint16_t & hue, float & saturation, float & luminance)
|
||||
{
|
||||
float r = red / 255.0f;
|
||||
float g = green / 255.0f;
|
||||
float b = blue / 255.0f;
|
||||
float r = (float)red / 255.0f;
|
||||
float g = (float)green / 255.0f;
|
||||
float b = (float)blue / 255.0f;
|
||||
|
||||
float rgbMin = r < g ? (r < b ? r : b) : (g < b ? g : b);
|
||||
float rgbMax = r > g ? (r > b ? r : b) : (g > b ? g : b);
|
||||
float rgbMin = std::min(r,std::min(g,b));
|
||||
float rgbMax = std::max(r,std::max(g,b));
|
||||
float diff = rgbMax - rgbMin;
|
||||
|
||||
//luminance
|
||||
luminance = (rgbMin + rgbMax) / 2.0f;
|
||||
|
||||
if (diff == 0.0f) {
|
||||
if (diff == 0.0f)
|
||||
{
|
||||
saturation = 0.0f;
|
||||
hue = 0;
|
||||
hue = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//saturation
|
||||
if (luminance < 0.5f)
|
||||
saturation = diff / (rgbMin + rgbMax);
|
||||
else
|
||||
saturation = diff / (2.0f - rgbMin - rgbMax);
|
||||
saturation = (luminance < 0.5f)
|
||||
? (diff / (rgbMin + rgbMax))
|
||||
: (diff / (2.0f - rgbMin - rgbMax));
|
||||
|
||||
if (rgbMax == r)
|
||||
{
|
||||
@@ -125,30 +119,29 @@ void HslTransform::rgb2hsl(uint8_t red, uint8_t green, uint8_t blue, uint16_t &
|
||||
|
||||
void HslTransform::hsl2rgb(uint16_t hue, float saturation, float luminance, uint8_t & red, uint8_t & green, uint8_t & blue)
|
||||
{
|
||||
if (saturation == 0.0f){
|
||||
red = (uint8_t)(luminance * 255.0f);
|
||||
if (saturation == 0.0f)
|
||||
{
|
||||
red = (uint8_t)(luminance * 255.0f);
|
||||
green = (uint8_t)(luminance * 255.0f);
|
||||
blue = (uint8_t)(luminance * 255.0f);
|
||||
blue = (uint8_t)(luminance * 255.0f);
|
||||
return;
|
||||
}
|
||||
|
||||
float q;
|
||||
|
||||
if (luminance < 0.5f)
|
||||
q = luminance * (1.0f + saturation);
|
||||
else
|
||||
q = (luminance + saturation) - (luminance * saturation);
|
||||
|
||||
|
||||
float q = (luminance < 0.5f)
|
||||
? luminance * (1.0f + saturation)
|
||||
: (luminance + saturation) - (luminance * saturation);
|
||||
|
||||
float p = (2.0f * luminance) - q;
|
||||
float h = hue / 360.0f;
|
||||
|
||||
|
||||
float t[3];
|
||||
|
||||
t[0] = h + (1.0f / 3.0f);
|
||||
t[1] = h;
|
||||
t[2] = h - (1.0f / 3.0f);
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (t[i] < 0.0f)
|
||||
t[i] += 1.0f;
|
||||
if (t[i] > 1.0f)
|
||||
@@ -157,7 +150,8 @@ void HslTransform::hsl2rgb(uint16_t hue, float saturation, float luminance, uint
|
||||
|
||||
float out[3];
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (t[i] * 6.0f < 1.0f)
|
||||
out[i] = p + (q - p) * 6.0f * t[i];
|
||||
else if (t[i] * 2.0f < 1.0f)
|
||||
@@ -168,8 +162,8 @@ void HslTransform::hsl2rgb(uint16_t hue, float saturation, float luminance, uint
|
||||
}
|
||||
|
||||
//convert back to 0...255 range
|
||||
red = (uint8_t)(out[0] * 255.0f);
|
||||
red = (uint8_t)(out[0] * 255.0f);
|
||||
green = (uint8_t)(out[1] * 255.0f);
|
||||
blue = (uint8_t)(out[2] * 255.0f);
|
||||
blue = (uint8_t)(out[2] * 255.0f);
|
||||
|
||||
}
|
||||
|
@@ -1,9 +1,9 @@
|
||||
#include <iostream>
|
||||
#include <utils/HsvTransform.h>
|
||||
|
||||
HsvTransform::HsvTransform() :
|
||||
_saturationGain(1.0),
|
||||
_valueGain(1.0)
|
||||
HsvTransform::HsvTransform()
|
||||
: _saturationGain(1.0)
|
||||
, _valueGain(1.0)
|
||||
{
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user