TestImage2LedsMap.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Utils includes
  2. #include <utils/Image.h>
  3. #include <utils/jsonschema/QJsonFactory.h>
  4. #include <utils/Logger.h>
  5. // Hyperion includes
  6. #include <utils/hyperion.h>
  7. #include <hyperion/ImageToLedsMap.h>
  8. int main()
  9. {
  10. Logger* log = Logger::getInstance("TestImageLedsMap");
  11. Logger::setLogLevel(Logger::DEBUG);
  12. const QString schemaFile = ":/hyperion-schema";
  13. const QString configFile = ":/hyperion_default.config";
  14. QJsonObject config;
  15. if (QJsonFactory::load(schemaFile, configFile, config) < 0)
  16. {
  17. std::cerr << "UNABLE TO LOAD CONFIGURATION" << std::endl;
  18. return -1;
  19. }
  20. const LedString ledString = LedString::createLedString(config["leds"].toArray(), hyperion::createColorOrder(config["device"].toObject()));
  21. const ColorRgb testColor = {64, 123, 12};
  22. Image<ColorRgb> image(64, 64, testColor);
  23. hyperion::ImageToLedsMap map(log, 64, 64, 0, 0, ledString.leds());
  24. std::vector<ColorRgb> ledColors(ledString.leds().size());
  25. map.getMeanLedColor(image, ledColors);
  26. std::cout << "[";
  27. for (const ColorRgb & color : ledColors)
  28. {
  29. std::cout << color;
  30. }
  31. std::cout << "]" << std::endl;
  32. return 0;
  33. }