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;
|
|
|
|
|
2014-01-20 20:46:38 +01:00
|
|
|
ImageProcessor::ImageProcessor(const LedString& ledString, bool enableBlackBorderDetector, uint8_t blackborderThreshold) :
|
|
|
|
_ledString(ledString),
|
2013-10-20 22:27:05 +02:00
|
|
|
_enableBlackBorderRemoval(enableBlackBorderDetector),
|
2014-01-20 20:46:38 +01:00
|
|
|
_borderProcessor(new BlackBorderProcessor(600, 50, 1, blackborderThreshold)),
|
|
|
|
_imageToLeds(nullptr)
|
2013-08-13 11:10:45 +02:00
|
|
|
{
|
|
|
|
// empty
|
|
|
|
}
|
|
|
|
|
|
|
|
ImageProcessor::~ImageProcessor()
|
|
|
|
{
|
2014-01-20 20:46:38 +01:00
|
|
|
delete _imageToLeds;
|
2013-08-23 07:09:09 +02:00
|
|
|
delete _borderProcessor;
|
2013-08-13 11:10:45 +02:00
|
|
|
}
|
|
|
|
|
2013-11-28 14:38:07 +01:00
|
|
|
unsigned ImageProcessor::getLedCount() const
|
|
|
|
{
|
2014-01-20 20:46:38 +01:00
|
|
|
return _ledString.leds().size();
|
2013-11-28 14:38:07 +01:00
|
|
|
}
|
|
|
|
|
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
|
2014-01-20 20:46:38 +01:00
|
|
|
if (_imageToLeds && _imageToLeds->width() == width && _imageToLeds->height() == height)
|
2013-08-13 11:10:45 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clean up the old buffer and mapping
|
2014-01-20 20:46:38 +01:00
|
|
|
delete _imageToLeds;
|
2013-08-13 11:10:45 +02:00
|
|
|
|
|
|
|
// Construct a new buffer and mapping
|
2014-01-20 20:46:38 +01:00
|
|
|
_imageToLeds = new ImageToLedsMap(width, height, 0, 0, _ledString.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
|
|
|
|
{
|
2014-01-20 20:46:38 +01:00
|
|
|
if (led < _ledString.leds().size())
|
2013-11-08 22:18:10 +01:00
|
|
|
{
|
2014-01-20 20:46:38 +01:00
|
|
|
const Led & l = _ledString.leds()[led];
|
2013-11-08 22:18:10 +01:00
|
|
|
hscanBegin = l.minX_frac;
|
|
|
|
hscanEnd = l.maxX_frac;
|
|
|
|
vscanBegin = l.minY_frac;
|
|
|
|
vscanEnd = l.maxY_frac;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|