我想用 OpenCV drawContours
函数绘制自定义点序列。
我的代码:
std::vector<std::vector<cv::Point> > contours;
std::vector<cv::Point> contour1;
contour1.push_back(cv::Point(100,100));
contour1.push_back(cv::Point(500,500));
contour1.push_back(cv::Point(500,100));
contours.push_back(contour1);
cv::drawContours(testDrawingImage,contours,-1,cv::Scalar(0,0,255),5);
cv::imshow("test",testDrawingImage);
为什么在这种情况下绘制三角形而不是 L 形?
当然我知道我可以用线来做到这一点。但也许有人想出了如何将它传递给 drawContours
函数。
最佳答案
drawContours()
完全按照它所说的去做,它绘制了一个由您给它的点包围的轮廓。等高线是闭合形状的轮廓,因此 drawContours()
函数会根据您提供的点为您提供闭合形状。
关于c++ - 使用 drawContours 绘制点序列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13530297/