gpt4 book ai didi

c++ - 使用 drawContours 绘制点序列

转载 作者:行者123 更新时间:2023-11-28 03:27:36 25 4
gpt4 key购买 nike

我想用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com