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:
T. van der Zwan
2013-08-15 19:11:02 +00:00
parent 2c6b48a54d
commit 4031a33f04
21 changed files with 504 additions and 5921 deletions

View File

@@ -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
)

View File

@@ -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

View File

@@ -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()));

View File

@@ -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;

View 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;
}

View 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;
};