2013-08-15 21:11:02 +02:00
|
|
|
|
|
|
|
// Utils includes
|
2013-11-11 10:00:37 +01:00
|
|
|
#include <utils/Image.h>
|
2013-08-15 21:11:02 +02:00
|
|
|
#include <utils/jsonschema/JsonFactory.h>
|
|
|
|
|
|
|
|
// Hyperion includes
|
|
|
|
#include <hyperion/Hyperion.h>
|
|
|
|
#include <hyperion/ImageToLedsMap.h>
|
|
|
|
|
|
|
|
using namespace hyperion;
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
std::string homeDir = getenv("RASPILIGHT_HOME");
|
|
|
|
|
|
|
|
const std::string schemaFile = homeDir + "/hyperion.schema.json";
|
|
|
|
const std::string configFile = homeDir + "/hyperion.config.json";
|
|
|
|
|
|
|
|
Json::Value config;
|
|
|
|
if (JsonFactory::load(schemaFile, configFile, config) < 0)
|
|
|
|
{
|
|
|
|
std::cerr << "UNABLE TO LOAD CONFIGURATION" << std::endl;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2015-02-23 16:11:33 +01:00
|
|
|
const LedString ledString = Hyperion::createLedString(config["leds"], Hyperion::createColorOrder(config["device"]));
|
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;
|
|
|
|
}
|