2013-08-13 11:10:45 +02:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
// Utils includes
|
|
|
|
#include <utils/RgbImage.h>
|
|
|
|
|
2013-08-23 07:09:09 +02:00
|
|
|
// Hyperion includes
|
2013-08-13 11:10:45 +02:00
|
|
|
#include <hyperion/ImageProcessorFactory.h>
|
2013-08-23 07:09:09 +02:00
|
|
|
#include <hyperion/LedString.h>
|
2013-08-13 11:10:45 +02:00
|
|
|
|
|
|
|
// Forward class declaration
|
2013-08-23 07:09:09 +02:00
|
|
|
namespace hyperion {
|
|
|
|
class ImageToLedsMap;
|
|
|
|
class BlackBorderProcessor;
|
|
|
|
}
|
2013-08-13 11:10:45 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The ImageProcessor translates an RGB-image to RGB-values for the leds. The processing is
|
|
|
|
* performed in two steps. First the average color per led-region is computed. Second a
|
|
|
|
* color-tranform is applied based on a gamma-correction.
|
|
|
|
*/
|
|
|
|
class ImageProcessor
|
|
|
|
{
|
|
|
|
public:
|
2013-08-13 12:03:00 +02:00
|
|
|
~ImageProcessor();
|
|
|
|
|
2013-08-13 11:10:45 +02:00
|
|
|
/**
|
|
|
|
* Specifies the width and height of 'incomming' images. This will resize the buffer-image to
|
|
|
|
* match the given size.
|
|
|
|
* NB All earlier obtained references will be invalid.
|
|
|
|
*
|
|
|
|
* @param[in] width The new width of the buffer-image
|
|
|
|
* @param[in] height The new height of the buffer-image
|
|
|
|
*/
|
|
|
|
void setSize(const unsigned width, const unsigned height);
|
|
|
|
|
|
|
|
/**
|
2013-08-14 17:02:09 +02:00
|
|
|
* Processes the image to a list of led colors. This will update the size of the buffer-image
|
|
|
|
* if required and call the image-to-leds mapping to determine the mean color per led.
|
2013-08-13 11:10:45 +02:00
|
|
|
*
|
2013-08-14 17:02:09 +02:00
|
|
|
* @param[in] image The image to translate to led values
|
|
|
|
*
|
|
|
|
* @return The color value per led
|
2013-08-13 11:10:45 +02:00
|
|
|
*/
|
2013-08-14 17:02:09 +02:00
|
|
|
std::vector<RgbColor> process(const RgbImage& image);
|
2013-08-13 11:10:45 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines the led colors of the image in the buffer.
|
|
|
|
*
|
|
|
|
* @param[out] ledColors The color value per led
|
|
|
|
*/
|
2013-08-14 17:02:09 +02:00
|
|
|
void process(const RgbImage& image, std::vector<RgbColor>& ledColors);
|
2013-08-13 11:10:45 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class ImageProcessorFactory;
|
|
|
|
|
|
|
|
ImageProcessor(const LedString &ledString);
|
|
|
|
|
2013-08-23 07:09:09 +02:00
|
|
|
void verifyBorder(const RgbImage& image);
|
2013-08-13 11:10:45 +02:00
|
|
|
private:
|
|
|
|
const LedString mLedString;
|
|
|
|
|
2013-08-23 07:09:09 +02:00
|
|
|
bool _enableBlackBorderRemoval;
|
|
|
|
|
|
|
|
/// The processor for black border detection
|
|
|
|
hyperion::BlackBorderProcessor* _borderProcessor;
|
|
|
|
|
2013-08-13 11:10:45 +02:00
|
|
|
hyperion::ImageToLedsMap* mImageToLeds;
|
|
|
|
};
|
|
|
|
|