绘制线段
bool opencvTool::drawLines(std::string image_p, std::vector<cv::Point> points)
{
cv::Mat ima = cv::imread(image_p.c_str());
cv::Scalar red = cv::Scalar(0, 0, 255);
int thickness = 2;
for (size_t i = 0; i < points.size() - 1; i++)
{
cv::Point2f start = points[i];
cv::Point2f end = points[i + 1];
cv::line(ima, start, end, red, thickness);
}
cv::imwrite(image_p.c_str(), ima);
return true;
}
bool opencvTool::drawLines(cv::Mat& image, std::vector<cv::Point> points, int lineWidth)
{
cv::Scalar red = cv::Scalar(0, 0, 255);
for (size_t i = 0; i < points.size() - 1; i++)
{
cv::Point2f start = points[i];
cv::Point2f end = points[i + 1];
cv::line(image, start, end, red, lineWidth);
}
return true;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33