mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Added simple QT-based grabber.
Moved ImageToLedsMap from include to libsrc. Moved instantiation of objects to Hyperion (no JSON required outside this class).
This commit is contained in:
@@ -1,93 +1,96 @@
|
||||
// STL includes
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
|
||||
#include <hyperion/ColorTransform.h>
|
||||
#include <../../libsrc/hyperion/ColorTransform.h>
|
||||
|
||||
using namespace hyperion;
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::cout << "Testing linear transform" << std::endl;
|
||||
ColorTransform t;
|
||||
for (int i = 0; i < 256; ++i)
|
||||
{
|
||||
uint8_t input = i;
|
||||
uint8_t output = t.transform(input);
|
||||
uint8_t expected = input;
|
||||
{
|
||||
std::cout << "Testing linear transform" << std::endl;
|
||||
ColorTransform t;
|
||||
for (int i = 0; i < 256; ++i)
|
||||
{
|
||||
uint8_t input = i;
|
||||
uint8_t output = t.transform(input);
|
||||
uint8_t expected = input;
|
||||
|
||||
if (output != expected)
|
||||
{
|
||||
std::cerr << "ERROR: input (" << (int)input << ") => output (" << (int)output << ") : expected (" << (int) expected << ")" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "OK: input (" << (int)input << ") => output (" << (int)output << ")" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (output != expected)
|
||||
{
|
||||
std::cerr << "ERROR: input (" << (int)input << ") => output (" << (int)output << ") : expected (" << (int) expected << ")" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "OK: input (" << (int)input << ") => output (" << (int)output << ")" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << "Testing threshold" << std::endl;
|
||||
ColorTransform t(.10, 1.0, 0.0, 1.0);
|
||||
for (int i = 0; i < 256; ++i)
|
||||
{
|
||||
uint8_t input = i;
|
||||
uint8_t output = t.transform(input);
|
||||
uint8_t expected = ((i/255.0) < t.getThreshold() ? 0 : output);
|
||||
{
|
||||
std::cout << "Testing threshold" << std::endl;
|
||||
ColorTransform t(.10, 1.0, 0.0, 1.0);
|
||||
for (int i = 0; i < 256; ++i)
|
||||
{
|
||||
uint8_t input = i;
|
||||
uint8_t output = t.transform(input);
|
||||
uint8_t expected = ((i/255.0) < t.getThreshold() ? 0 : output);
|
||||
|
||||
if (output != expected)
|
||||
{
|
||||
std::cerr << "ERROR: input (" << (int)input << ") => output (" << (int)output << ") : expected (" << (int) expected << ")" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "OK: input (" << (int)input << ") => output (" << (int)output << ")" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (output != expected)
|
||||
{
|
||||
std::cerr << "ERROR: input (" << (int)input << ") => output (" << (int)output << ") : expected (" << (int) expected << ")" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "OK: input (" << (int)input << ") => output (" << (int)output << ")" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << "Testing blacklevel and whitelevel" << std::endl;
|
||||
ColorTransform t(0, 1.0, 0.2, 0.8);
|
||||
for (int i = 0; i < 256; ++i)
|
||||
{
|
||||
uint8_t input = i;
|
||||
uint8_t output = t.transform(input);
|
||||
uint8_t expected = (uint8_t)(input * (t.getWhitelevel()-t.getBlacklevel()) + 255 * t.getBlacklevel());
|
||||
{
|
||||
std::cout << "Testing blacklevel and whitelevel" << std::endl;
|
||||
ColorTransform t(0, 1.0, 0.2, 0.8);
|
||||
for (int i = 0; i < 256; ++i)
|
||||
{
|
||||
uint8_t input = i;
|
||||
uint8_t output = t.transform(input);
|
||||
uint8_t expected = (uint8_t)(input * (t.getWhitelevel()-t.getBlacklevel()) + 255 * t.getBlacklevel());
|
||||
|
||||
if (output != expected)
|
||||
{
|
||||
std::cerr << "ERROR: input (" << (int)input << ") => output (" << (int)output << ") : expected (" << (int) expected << ")" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "OK: input (" << (int)input << ") => output (" << (int)output << ")" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (output != expected)
|
||||
{
|
||||
std::cerr << "ERROR: input (" << (int)input << ") => output (" << (int)output << ") : expected (" << (int) expected << ")" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "OK: input (" << (int)input << ") => output (" << (int)output << ")" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << "Testing gamma" << std::endl;
|
||||
ColorTransform t(0, 2.0, 0.0, 1.0);
|
||||
for (int i = 0; i < 256; ++i)
|
||||
{
|
||||
uint8_t input = i;
|
||||
uint8_t output = t.transform(input);
|
||||
uint8_t expected = (uint8_t)(255 * std::pow(i / 255.0, 2));
|
||||
{
|
||||
std::cout << "Testing gamma" << std::endl;
|
||||
ColorTransform t(0, 2.0, 0.0, 1.0);
|
||||
for (int i = 0; i < 256; ++i)
|
||||
{
|
||||
uint8_t input = i;
|
||||
uint8_t output = t.transform(input);
|
||||
uint8_t expected = (uint8_t)(255 * std::pow(i / 255.0, 2));
|
||||
|
||||
if (output != expected)
|
||||
{
|
||||
std::cerr << "ERROR: input (" << (int)input << ") => output (" << (int)output << ") : expected (" << (int) expected << ")" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "OK: input (" << (int)input << ") => output (" << (int)output << ")" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (output != expected)
|
||||
{
|
||||
std::cerr << "ERROR: input (" << (int)input << ") => output (" << (int)output << ") : expected (" << (int) expected << ")" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "OK: input (" << (int)input << ") => output (" << (int)output << ")" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
@@ -32,7 +32,7 @@ int main()
|
||||
double redGamma = redConfig["gamma"].asDouble();
|
||||
std::cout << "RED GAMMA = " << redGamma << std::endl;
|
||||
std::cout << "RED GAMMA = " << colorConfig["red.gamma"].asDouble() << std::endl;
|
||||
LedString ledString = LedString::construct(ledConfig, colorConfig);
|
||||
// LedString ledString = LedString::construct(ledConfig, colorConfig);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user