2016-02-07 13:26:40 +01:00
|
|
|
#include <iostream>
|
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-02-07 13:26:40 +01: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);
|
|
|
|
|
2016-03-23 17:40:34 +01:00
|
|
|
std::cout << "BLACKBORDER INFO: threshold set to " << threshold << " (" << int(blackborderThreshold) << ")" << std::endl;
|
2016-02-07 13:26:40 +01:00
|
|
|
|
|
|
|
return blackborderThreshold;
|
|
|
|
}
|