2016-02-07 13:26:40 +01:00
|
|
|
#include <iostream>
|
2016-07-10 23:14:23 +02:00
|
|
|
#include <utils/Logger.h>
|
|
|
|
|
2014-01-26 14:23:08 +01:00
|
|
|
// BlackBorders includes
|
|
|
|
#include <blackborder/BlackBorderDetector.h>
|
2016-02-10 19:22:19 +01:00
|
|
|
#include <cmath>
|
2013-08-21 16:25:27 +02:00
|
|
|
|
2013-08-23 07:08:44 +02:00
|
|
|
using namespace hyperion;
|
|
|
|
|
2016-07-10 23:14:23 +02:00
|
|
|
BlackBorderDetector::BlackBorderDetector(double threshold)
|
|
|
|
: _blackborderThreshold(calculateThreshold(threshold))
|
2013-08-21 16:25:27 +02:00
|
|
|
{
|
2013-08-21 16:52:03 +02:00
|
|
|
// empty
|
2013-08-21 16:25:27 +02:00
|
|
|
}
|
2016-02-07 13:26:40 +01:00
|
|
|
|
|
|
|
uint8_t BlackBorderDetector::calculateThreshold(double threshold)
|
|
|
|
{
|
|
|
|
int rgbThreshold = int(std::ceil(threshold * 255));
|
|
|
|
if (rgbThreshold < 0)
|
|
|
|
rgbThreshold = 0;
|
|
|
|
else if (rgbThreshold > 255)
|
|
|
|
rgbThreshold = 255;
|
|
|
|
|
|
|
|
uint8_t blackborderThreshold = uint8_t(rgbThreshold);
|
|
|
|
|
2018-12-27 23:11:32 +01:00
|
|
|
//Debug(Logger::getInstance("BLACKBORDER"), "threshold set to %f (%d)", threshold , int(blackborderThreshold));
|
2016-02-07 13:26:40 +01:00
|
|
|
|
|
|
|
return blackborderThreshold;
|
|
|
|
}
|