-------------------------------------------------------------------------- */ add text (vector of doubles) in the image at desired position/size/color
| 77 | /* -------------------------------------------------------------------------- */ |
| 78 | // add text (vector of doubles) in the image at desired position/size/color |
| 79 | void UtilsOpenCV::DrawTextInPlace(cv::Mat& img, |
| 80 | const std::vector<cv::Point2f>& imagePoints, |
| 81 | const cv::Scalar& color, |
| 82 | const double msize, |
| 83 | const std::vector<double>& textDoubles) { |
| 84 | cv::Point2f textOffset = cv::Point2f(-12, -5); // text offset |
| 85 | if (img.channels() < 3) cv::cvtColor(img, img, cv::COLOR_GRAY2BGR); |
| 86 | for (size_t i = 0; i < imagePoints.size(); i++) { |
| 87 | if (imagePoints.size() == textDoubles.size()) // write text |
| 88 | cv::putText(img, |
| 89 | Utils::To_string_with_precision(textDoubles.at(i), 3), |
| 90 | imagePoints[i] + textOffset, |
| 91 | cv::FONT_HERSHEY_COMPLEX, |
| 92 | msize, |
| 93 | color); |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | /* -------------------------------------------------------------------------- */ |
| 98 | // Concatenate two images and return results as a new mat. |