2013-08-15 21:11:02 +02:00
|
|
|
|
|
|
|
// Utils includes
|
2013-11-11 10:00:37 +01:00
|
|
|
#include <utils/Image.h>
|
2016-09-25 21:59:31 +02:00
|
|
|
#include <utils/jsonschema/QJsonFactory.h>
|
2013-08-15 21:11:02 +02:00
|
|
|
|
|
|
|
// Hyperion includes
|
|
|
|
#include <hyperion/Hyperion.h>
|
|
|
|
#include <hyperion/ImageToLedsMap.h>
|
|
|
|
|
|
|
|
using namespace hyperion;
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2016-09-25 21:59:31 +02:00
|
|
|
QString homeDir = getenv("RASPILIGHT_HOME");
|
2013-08-15 21:11:02 +02:00
|
|
|
|
2016-09-25 21:59:31 +02:00
|
|
|
const QString schemaFile = homeDir + "/hyperion.schema.json";
|
|
|
|
const QString configFile = homeDir + "/hyperion.config.json";
|
2013-08-15 21:11:02 +02:00
|
|
|
|
2016-09-25 21:59:31 +02:00
|
|
|
QJsonObject config;
|
|
|
|
if (QJsonFactory::load(schemaFile, configFile, config) < 0)
|
2013-08-15 21:11:02 +02:00
|
|
|
{
|
|
|
|
std::cerr << "UNABLE TO LOAD CONFIGURATION" << std::endl;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-09-25 21:59:31 +02:00
|
|
|
const LedString ledString = Hyperion::createLedString(config["leds"], Hyperion::createColorOrder(config["device"].toObject()));
|
2013-08-15 21:11:02 +02:00
|
|
|
|
2013-11-11 10:00:37 +01:00
|
|
|
const ColorRgb testColor = {64, 123, 12};
|
2013-08-15 21:11:02 +02:00
|
|
|
|
2013-11-11 10:00:37 +01:00
|
|
|
Image<ColorRgb> image(64, 64, testColor);
|
2013-08-21 17:24:42 +02:00
|
|
|
ImageToLedsMap map(64, 64, 0, 0, ledString.leds());
|
2013-08-15 21:11:02 +02:00
|
|
|
|
2013-11-11 10:00:37 +01:00
|
|
|
std::vector<ColorRgb> ledColors(ledString.leds().size());
|
2013-08-15 21:11:02 +02:00
|
|
|
map.getMeanLedColor(image, ledColors);
|
|
|
|
|
|
|
|
std::cout << "[";
|
2013-11-11 10:00:37 +01:00
|
|
|
for (const ColorRgb & color : ledColors)
|
2013-08-15 21:11:02 +02:00
|
|
|
{
|
|
|
|
std::cout << color;
|
|
|
|
}
|
|
|
|
std::cout << "]" << std::endl;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|