opencv入门学习16

多边形的填充与绘制

1.定义画布图像与点

Mat canvas = Mat::zeros(Size(512, 512), CV_8UC3);
	Point p1(100, 100);
	Point p2(350, 100);
	Point p3(450, 280);
	Point p4(320, 480);
	Point p5(80, 400);
  1. 绘制封闭多边形
vector<Point>pts;
pts.push_back(p1);
pts.push_back(p2);
pts.push_back(p3);	
pts.push_back(p4);
pts.push_back(p5);
polylines(canvas, pts, true, Scalar(0, 0, 255), 2, 8, 0);
fillPoly(canvas, pts, Scalar(255, 255, 0), 8, 0);

3.快速绘制多幅

contours.push_back(pts);
drawContours(canvas, contours, -1, Scalar(255, 0, 0), -1);
上一篇:python 图片(pil库)文字的添加


下一篇:一文教会你OpenCV图像处理!OPenCV教程/OPenCV物体识别/OPenCV图像处理