2013-08-13 11:10:45 +02:00
|
|
|
|
2013-08-23 07:09:09 +02:00
|
|
|
// Hyperion includes
|
|
|
|
#include <hyperion/ImageProcessor.h>
|
2013-11-11 10:00:37 +01:00
|
|
|
#include <hyperion/ImageToLedsMap.h>
|
|
|
|
#include <hyperion/BlackBorderProcessor.h>
|
2013-08-13 11:10:45 +02:00
|
|
|
|
|
|
|
using namespace hyperion;
|
|
|
|
|
2013-10-20 22:27:05 +02:00
|
|
|
ImageProcessor::ImageProcessor(const LedString& ledString, bool enableBlackBorderDetector) :
|
2013-08-13 11:10:45 +02:00
|
|
|
mLedString(ledString),
|
2013-10-20 22:27:05 +02:00
|
|
|
_enableBlackBorderRemoval(enableBlackBorderDetector),
|
2013-08-23 07:09:09 +02:00
|
|
|
_borderProcessor(new BlackBorderProcessor(600, 50, 1)),
|
2013-08-13 11:10:45 +02:00
|
|
|
mImageToLeds(nullptr)
|
|
|
|
{
|
|
|
|
// empty
|
|
|
|
}
|
|
|
|
|
|
|
|
ImageProcessor::~ImageProcessor()
|
|
|
|
{
|
|
|
|
delete mImageToLeds;
|
2013-08-23 07:09:09 +02:00
|
|
|
delete _borderProcessor;
|
2013-08-13 11:10:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ImageProcessor::setSize(const unsigned width, const unsigned height)
|
|
|
|
{
|
|
|
|
// Check if the existing buffer-image is already the correct dimensions
|
2013-08-14 17:02:09 +02:00
|
|
|
if (mImageToLeds && mImageToLeds->width() == width && mImageToLeds->height() == height)
|
2013-08-13 11:10:45 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clean up the old buffer and mapping
|
|
|
|
delete mImageToLeds;
|
|
|
|
|
|
|
|
// Construct a new buffer and mapping
|
2013-08-21 17:24:42 +02:00
|
|
|
mImageToLeds = new ImageToLedsMap(width, height, 0, 0, mLedString.leds());
|
2013-08-13 11:10:45 +02:00
|
|
|
}
|
|
|
|
|
2013-11-08 22:18:10 +01:00
|
|
|
bool ImageProcessor::getScanParameters(size_t led, double &hscanBegin, double &hscanEnd, double &vscanBegin, double &vscanEnd) const
|
|
|
|
{
|
|
|
|
if (led < mLedString.leds().size())
|
|
|
|
{
|
|
|
|
const Led & l = mLedString.leds()[led];
|
|
|
|
hscanBegin = l.minX_frac;
|
|
|
|
hscanEnd = l.maxX_frac;
|
|
|
|
vscanBegin = l.minY_frac;
|
|
|
|
vscanEnd = l.maxY_frac;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|