绘制线段
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;
}