hyperion.ng/libsrc/blackborder/BlackBorderDetector.cpp
Danimal4326 0661ad74f6 Fx compile issue for missing ceil function
Former-commit-id: f5a6ac2c19b73aa48b5f4292cfa912dc2936701b
2016-02-10 12:22:19 -06:00

28 lines
689 B
C++

#include <iostream>
// BlackBorders includes
#include <blackborder/BlackBorderDetector.h>
#include <cmath>
using namespace hyperion;
BlackBorderDetector::BlackBorderDetector(double threshold) :
_blackborderThreshold(calculateThreshold(threshold))
{
// empty
}
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;
}