mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Added simple test for image2led map.
Added test executable for creating png from frame grabber. Added test-device for exporting color values of leds to text file. Updated configuration to match new color transform. Finished first version of the Hyperion structure (IT WORKS [1% CPU]!)
This commit is contained in:
@@ -23,6 +23,7 @@ SET(Hyperion_HEADERS
|
||||
${CURRENT_SOURCE_DIR}/DispmanxFrameGrabber.h
|
||||
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceWs2801.h
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceTest.h
|
||||
${CURRENT_SOURCE_DIR}/ImageToLedsMap.h
|
||||
${CURRENT_SOURCE_DIR}/ColorTransform.h
|
||||
)
|
||||
@@ -38,6 +39,7 @@ SET(Hyperion_SOURCES
|
||||
${CURRENT_SOURCE_DIR}/DispmanxFrameGrabber.cpp
|
||||
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceWs2801.cpp
|
||||
${CURRENT_SOURCE_DIR}/LedDeviceTest.cpp
|
||||
${CURRENT_SOURCE_DIR}/ImageToLedsMap.cpp
|
||||
${CURRENT_SOURCE_DIR}/ColorTransform.cpp
|
||||
)
|
||||
|
@@ -10,7 +10,7 @@ DispmanxFrameGrabber::DispmanxFrameGrabber(const unsigned width, const unsigned
|
||||
// Initiase BCM
|
||||
bcm_host_init();
|
||||
|
||||
// Open the connection to the displaydisplay
|
||||
// Open the connection to the display
|
||||
_display = vc_dispmanx_display_open(0);
|
||||
int ret = vc_dispmanx_display_get_info(_display, &_info);
|
||||
// Make the compiler (in release mode) happy by 'using' ret
|
||||
|
@@ -10,8 +10,10 @@
|
||||
// hyperion include
|
||||
#include <hyperion/Hyperion.h>
|
||||
#include <hyperion/LedDevice.h>
|
||||
#include <hyperion/ImageProcessorFactory.h>
|
||||
|
||||
#include "LedDeviceWs2801.h"
|
||||
#include "LedDeviceTest.h"
|
||||
#include "ColorTransform.h"
|
||||
|
||||
using namespace hyperion;
|
||||
@@ -32,6 +34,10 @@ LedDevice* constructDevice(const Json::Value& deviceConfig)
|
||||
|
||||
device = deviceWs2801;
|
||||
}
|
||||
else if (deviceConfig["type"].asString() == "test")
|
||||
{
|
||||
device = new LedDeviceTest();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Unknown / Unimplemented device
|
||||
@@ -49,7 +55,7 @@ ColorTransform* createColorTransform(const Json::Value& colorConfig)
|
||||
ColorTransform* transform = new ColorTransform(threshold, gamma, blacklevel, whitelevel);
|
||||
return transform;
|
||||
}
|
||||
LedString createLedString(const Json::Value& ledsConfig)
|
||||
LedString Hyperion::createLedString(const Json::Value& ledsConfig)
|
||||
{
|
||||
LedString ledString;
|
||||
|
||||
@@ -77,6 +83,8 @@ Hyperion::Hyperion(const Json::Value &jsonConfig) :
|
||||
mDevice(constructDevice(jsonConfig["device"])),
|
||||
_timer()
|
||||
{
|
||||
ImageProcessorFactory::getInstance().init(mLedString);
|
||||
|
||||
_timer.setSingleShot(true);
|
||||
QObject::connect(&_timer, SIGNAL(timeout()), this, SLOT(update()));
|
||||
|
||||
|
@@ -1,6 +1,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
// STL includes
|
||||
#include <sstream>
|
||||
|
||||
// hyperion-utils includes
|
||||
#include <utils/RgbImage.h>
|
||||
|
||||
@@ -44,6 +47,23 @@ public:
|
||||
*/
|
||||
void getMeanLedColor(const RgbImage & image, std::vector<RgbColor> & ledColors) const;
|
||||
|
||||
std::string toString() const
|
||||
{
|
||||
std::stringstream sstream;
|
||||
sstream << "ImageToLedsMap(" << _width << "x" << _height << ") [";
|
||||
for (const std::vector<unsigned> imageIndices : mColorsMap)
|
||||
{
|
||||
sstream << "{";
|
||||
for (unsigned imageIndex : imageIndices)
|
||||
{
|
||||
sstream << imageIndex << ";";
|
||||
}
|
||||
sstream << "}";
|
||||
}
|
||||
sstream << "]" << std::endl;
|
||||
|
||||
return sstream.str();
|
||||
}
|
||||
private:
|
||||
const unsigned _width;
|
||||
const unsigned _height;
|
||||
|
26
libsrc/hyperion/LedDeviceTest.cpp
Normal file
26
libsrc/hyperion/LedDeviceTest.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
// Local-Hyperion includes
|
||||
#include "LedDeviceTest.h"
|
||||
|
||||
LedDeviceTest::LedDeviceTest() :
|
||||
_ofs("/home/pi/LedDevice.out")
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
LedDeviceTest::~LedDeviceTest()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
int LedDeviceTest::write(const std::vector<RgbColor> & ledValues)
|
||||
{
|
||||
_ofs << "[";
|
||||
for (const RgbColor& color : ledValues)
|
||||
{
|
||||
_ofs << color;
|
||||
}
|
||||
_ofs << "]" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
19
libsrc/hyperion/LedDeviceTest.h
Normal file
19
libsrc/hyperion/LedDeviceTest.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
// STL includes0
|
||||
#include <fstream>
|
||||
|
||||
// Hyperion includes
|
||||
#include <hyperion/LedDevice.h>
|
||||
|
||||
class LedDeviceTest : public LedDevice
|
||||
{
|
||||
public:
|
||||
LedDeviceTest();
|
||||
virtual ~LedDeviceTest();
|
||||
|
||||
virtual int write(const std::vector<RgbColor> & ledValues);
|
||||
|
||||
private:
|
||||
std::ofstream _ofs;
|
||||
};
|
Reference in New Issue
Block a user