Changed the image-to-leds map by using offset-pointing.

Moved the image-buffer from processor to dispmanx-wrapper.
Added timeout handling to Hyperion.
This commit is contained in:
T. van der Zwan
2013-08-14 15:02:09 +00:00
parent e8b97dcb01
commit b457c444f6
11 changed files with 136 additions and 94 deletions

View File

@@ -8,7 +8,6 @@ using namespace hyperion;
ImageProcessor::ImageProcessor(const LedString& ledString) :
mLedString(ledString),
mBuffer(nullptr),
mImageToLeds(nullptr)
{
// empty
@@ -17,7 +16,21 @@ ImageProcessor::ImageProcessor(const LedString& ledString) :
ImageProcessor::~ImageProcessor()
{
delete mImageToLeds;
delete mBuffer;
}
void ImageProcessor::setSize(const unsigned width, const unsigned height)
{
// Check if the existing buffer-image is already the correct dimensions
if (mImageToLeds && mImageToLeds->width() == width && mImageToLeds->height() == height)
{
return;
}
// Clean up the old buffer and mapping
delete mImageToLeds;
// Construct a new buffer and mapping
mImageToLeds = new ImageToLedsMap(width, height, mLedString.leds());
}
std::vector<RgbColor> ImageProcessor::process(const RgbImage& image)
@@ -25,41 +38,15 @@ std::vector<RgbColor> ImageProcessor::process(const RgbImage& image)
// Ensure that the buffer-image is the proper size
setSize(image.width(), image.height());
// Copy the data of the given image into the mapped-image
mBuffer->copy(image);
// Create a result vector and call the 'in place' functionl
std::vector<RgbColor> colors(mLedString.leds().size(), RgbColor::BLACK);
inplace_process(colors);
std::vector<RgbColor> colors = mImageToLeds->getMeanLedColor(image);
// return the computed colors
return colors;
}
void ImageProcessor::setSize(const unsigned width, const unsigned height)
{
// Check if the existing buffer-image is already the correct dimensions
if (mBuffer && mBuffer->width() == width && mBuffer->height() == height)
{
return;
}
// Clean up the old buffer and mapping
delete mImageToLeds;
delete mBuffer;
// Construct a new buffer and mapping
mBuffer = new RgbImage(width, height);
mImageToLeds = new ImageToLedsMap(*mBuffer, mLedString.leds());
}
RgbImage& ImageProcessor::image()
{
return *mBuffer;
}
void ImageProcessor::inplace_process(std::vector<RgbColor>& ledColors)
void ImageProcessor::process(const RgbImage& image, std::vector<RgbColor>& ledColors)
{
// Determine the mean-colors of each led (using the existing mapping)
mImageToLeds->getMeanLedColor(ledColors);
mImageToLeds->getMeanLedColor(image, ledColors);
}