-------------------------------------------------------------------------- */ add squares in the image at desired position/size/color
| 41 | /* -------------------------------------------------------------------------- */ |
| 42 | // add squares in the image at desired position/size/color |
| 43 | void UtilsOpenCV::DrawSquaresInPlace(cv::Mat& img, |
| 44 | const std::vector<cv::Point2f>& imagePoints, |
| 45 | const cv::Scalar& color, |
| 46 | const double msize, |
| 47 | const std::vector<int>& pointIds, |
| 48 | const int remId) { |
| 49 | cv::Point2f textOffset = cv::Point2f(-10, -5); // text offset |
| 50 | if (img.channels() < 3) cv::cvtColor(img, img, cv::COLOR_GRAY2BGR); |
| 51 | for (size_t i = 0; i < imagePoints.size(); i++) { |
| 52 | cv::Rect square = cv::Rect(imagePoints[i].x - msize / 2, imagePoints[i].y - msize / 2, msize, msize); |
| 53 | rectangle(img, square, color, 2); |
| 54 | if (pointIds.size() == imagePoints.size()) // we also have text |
| 55 | cv::putText( |
| 56 | img, std::to_string(pointIds[i] % remId), imagePoints[i] + textOffset, cv::FONT_HERSHEY_COMPLEX, 0.5, color); |
| 57 | } |
| 58 | } |
| 59 | /* -------------------------------------------------------------------------- */ |
| 60 | // add x in the image at desired position/size/color |
| 61 | void UtilsOpenCV::DrawCrossesInPlace(cv::Mat& img, |