25 #ifndef INCLUDED_GenerateBlobDebugImage_h_GUID_558B5666_8637_48B9_A215_E7A1B798DDD8 
   26 #define INCLUDED_GenerateBlobDebugImage_h_GUID_558B5666_8637_48B9_A215_E7A1B798DDD8 
   33 #include <opencv2/core/core.hpp> 
   34 #include <opencv2/imgproc/imgproc.hpp> 
   44     generateBlobDebugImage(cv::Mat 
const &inputImage,
 
   45                            EdgeHoleBasedLedExtractor 
const &extractor) {
 
   49         cv::Mat highlightedContours =
 
   50             drawColoredContours(inputImage, extractor.getContours());
 
   56             static const auto FONT_FACE = cv::FONT_HERSHEY_PLAIN;
 
   57             static const auto FONT_SCALE = 0.8;
 
   58             static const int FONT_THICKNESS = 1;
 
   60             auto imageSize = highlightedContours.size();
 
   62                 cv::Point2d(imageSize.width / 2, imageSize.height / 2);
 
   63             std::random_device rd;
 
   64             std::mt19937 mt(rd());
 
   65             std::uniform_real_distribution<double> vectorScaleDistribution(1.1,
 
   67             auto computeTextLocation = [&](cv::Point2d rejectCenter,
 
   68                                            std::string 
const &text) {
 
   69                 auto centerToRejectVec = rejectCenter - imageCenter;
 
   71                     cv::Point(centerToRejectVec * vectorScaleDistribution(mt) +
 
   76                 auto textSize = cv::getTextSize(text, FONT_FACE, FONT_SCALE,
 
   77                                                 FONT_THICKNESS, 
nullptr);
 
   80                     cv::Point(textSize.width / 2, textSize.height / 2);
 
   81                 return textPoint - textOffset;
 
   85             for (
auto &reject : extractor.getRejectList()) {
 
   86                 EdgeHoleBasedLedExtractor::ContourId contourId = 0;
 
   89                 std::tie(contourId, reason, center) = reject;
 
   91                 if (osvr::vbtracker::RejectReason::Area == reason ||
 
   92                     RejectReason::CenterPointValue == reason) {
 
   96                 drawSubpixelPoint(highlightedContours, center,
 
   98                 std::ostringstream os;
 
  102                 case RejectReason::Area:
 
  105                 case RejectReason::CenterPointValue:
 
  108                 case RejectReason::Circularity:
 
  111                 case RejectReason::Convexity:
 
  118                 auto text = os.str();
 
  119                 cv::putText(highlightedContours, text,
 
  120                             computeTextLocation(center, text), FONT_FACE,
 
  121                             FONT_SCALE, 
cv::Scalar(0, 0, 255), FONT_THICKNESS);
 
  125         return highlightedContours;
 
  129 #endif // INCLUDED_GenerateBlobDebugImage_h_GUID_558B5666_8637_48B9_A215_E7A1B798DDD8 
double Scalar
Common scalar type.