opencv绘制点集c++
时间: 2023-09-20 07:09:49 浏览: 266
可以使用cv::Mat对象来表示点集,并使用cv::circle函数绘制每个点。
示例代码:
```
#include <opencv2/opencv.hpp>
#include <vector>
int main()
{
// 构造点集
std::vector<cv::Point> points;
points.push_back(cv::Point(50, 50));
points.push_back(cv::Point(100, 100));
points.push_back(cv::Point(150, 50));
points.push_back(cv::Point(200, 100));
// 创建画布
cv::Mat canvas(300, 300, CV_8UC3, cv::Scalar(255, 255, 255));
// 绘制点集
for (int i = 0; i < points.size(); i++)
{
cv::circle(canvas, points[i], 3, cv::Scalar(0, 0, 255), -1);
}
// 显示画布
cv::imshow("Points", canvas);
cv::waitKey();
return 0;
}
```
运行结果:
![points](https://user-images.githubusercontent.com/6814254/121291688-4dca7f00-c92c-11eb-8d95-6f6e7c6a3e6d.png)
阅读全文