BlackBorderDetector.cpp 603 B

12345678910111213141516171819202122232425262728
  1. #include <iostream>
  2. #include <utils/Logger.h>
  3. // BlackBorders includes
  4. #include <blackborder/BlackBorderDetector.h>
  5. #include <cmath>
  6. using namespace hyperion;
  7. BlackBorderDetector::BlackBorderDetector(double threshold)
  8. : _blackborderThreshold(calculateThreshold(threshold))
  9. {
  10. // empty
  11. }
  12. uint8_t BlackBorderDetector::calculateThreshold(double threshold) const
  13. {
  14. int rgbThreshold = int(std::ceil(threshold * 255));
  15. if (rgbThreshold < 0)
  16. rgbThreshold = 0;
  17. else if (rgbThreshold > 255)
  18. rgbThreshold = 255;
  19. uint8_t blackborderThreshold = uint8_t(rgbThreshold);
  20. return blackborderThreshold;
  21. }