OpenCV多边形填充与绘制

  Mat bg = Mat::zeros(Size(512, 512), CV_8UC3);
  Point p1(100, 100);
  Point p2(350, 100);
  Point p3(450, 280);
  Point p4(320, 450);
  Point p5(80, 400);
  std::vector<Point> pts;
  pts.push_back(p1);
  pts.push_back(p2);
  pts.push_back(p3);
  pts.push_back(p4);
  pts.push_back(p5);

  polylines(bg, pts, true, Scalar(0, 0, 255), 2, 8, 0);
  fillPoly(bg, pts, Scalar(0, 255, 255),8, 0);

  std::vector<std::vector<Point>> contours;
  contours.push_back(pts);
  drawContours(bg, contours, -1, Scalar(255, 0, 255), 2);

  imshow("Draw_polygon", bg);

推荐一个零声学院项目课,个人觉得老师讲得不错,分享给大家:
零声白金学习卡(含基础架构/高性能存储/golang云原生/音视频/Linux内核)
https://xxetb.xet.tech/s/3Zqhgt

相关推荐

  1. OpenCV多边形填充绘制

    2024-03-26 05:36:07       20 阅读
  2. OPenCV绘制多条多边形曲线函数polylines的使用

    2024-03-26 05:36:07       7 阅读
  3. OpenCV技巧: 图像孔洞填充的方法实现

    2024-03-26 05:36:07       35 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-03-26 05:36:07       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-03-26 05:36:07       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-03-26 05:36:07       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-03-26 05:36:07       18 阅读

热门阅读

  1. Ubuntu下采用VSCode进行C/C++开发(2)

    2024-03-26 05:36:07       19 阅读
  2. Node.js及node.js常用命令

    2024-03-26 05:36:07       19 阅读
  3. npm install jsencrypt爆错

    2024-03-26 05:36:07       16 阅读
  4. 神经网络深度学习梯度下降算法优化

    2024-03-26 05:36:07       22 阅读
  5. 云安全与云计算的关系

    2024-03-26 05:36:07       19 阅读
  6. 04、Lua 数据类型

    2024-03-26 05:36:07       18 阅读
  7. 【C语言】文件读写

    2024-03-26 05:36:07       23 阅读