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);