rm_vision/tools/img_tools.cpp
2025-12-15 02:33:20 +08:00

31 lines
924 B
C++

#include "img_tools.hpp"
namespace tools
{
void draw_point(cv::Mat & img, const cv::Point & point, const cv::Scalar & color, int radius)
{
cv::circle(img, point, radius, color, -1);
}
void draw_points(
cv::Mat & img, const std::vector<cv::Point> & points, const cv::Scalar & color, int thickness)
{
std::vector<std::vector<cv::Point>> contours = {points};
cv::drawContours(img, contours, -1, color, thickness);
}
void draw_points(
cv::Mat & img, const std::vector<cv::Point2f> & points, const cv::Scalar & color, int thickness)
{
std::vector<cv::Point> int_points(points.begin(), points.end());
draw_points(img, int_points, color, thickness);
}
void draw_text(
cv::Mat & img, const std::string & text, const cv::Point & point, const cv::Scalar & color,
double font_scale, int thickness)
{
cv::putText(img, text, point, cv::FONT_HERSHEY_SIMPLEX, font_scale, color, thickness);
}
} // namespace tools