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);
|
|
|
|
|
|
|
|
std::cout << "Black border threshold set to " << threshold << " (" << int(blackborderThreshold) << ")" << std::endl;
|
|
|
|
|
|
|
|
return blackborderThreshold;
|
|
|
|
}
|