-------------------------------------------------------------------------- */ add x in the image at desired position/size/color
| 59 | /* -------------------------------------------------------------------------- */ |
| 60 | // add x in the image at desired position/size/color |
| 61 | void UtilsOpenCV::DrawCrossesInPlace(cv::Mat& img, |
| 62 | const std::vector<cv::Point2f>& imagePoints, |
| 63 | const cv::Scalar& color, |
| 64 | const double msize, |
| 65 | const std::vector<int>& pointIds, |
| 66 | const int remId) { |
| 67 | cv::Point2f textOffset = cv::Point2f(-10, -5); // text offset |
| 68 | cv::Point2f textOffsetToCenter = cv::Point2f(-3, +3); // text offset |
| 69 | if (img.channels() < 3) cv::cvtColor(img, img, cv::COLOR_GRAY2BGR); |
| 70 | for (size_t i = 0; i < imagePoints.size(); i++) { |
| 71 | cv::putText(img, "X", imagePoints[i] + textOffsetToCenter, cv::FONT_HERSHEY_COMPLEX, msize, color, 2); |
| 72 | if (pointIds.size() == imagePoints.size()) // we also have text |
| 73 | cv::putText( |
| 74 | img, std::to_string(pointIds[i] % remId), imagePoints[i] + textOffset, cv::FONT_HERSHEY_COMPLEX, 0.5, color); |
| 75 | } |
| 76 | } |
| 77 | /* -------------------------------------------------------------------------- */ |
| 78 | // add text (vector of doubles) in the image at desired position/size/color |
| 79 | void UtilsOpenCV::DrawTextInPlace(cv::Mat& img, |