OpenCV | polylines绘制多边形
1、四边形
Mat image(300, 300, CV_8UC3, Scalar(255, 255, 255));
Point pnt[1][4] =
{
Point(100, 100),
Point(200, 100),
Point(200, 200),
Point(100, 200),
};
const Point* pt[1] = {pnt[0]};
int npt = 4;
polylines(image, pt, &npt, 1, true, Scalar(0, 0, 255), 2);
imshow("polylines", image);
2、五边形
Mat image(300, 300, CV_8UC3, Scalar(255, 255, 255));
Point pnt[1][5] =
{
Point(100, 100),
Point(200, 100),
Point(200, 200),
Point(100, 200),
Point(80, 80),
};
const Point* pt[1] = {pnt[0]};
int npt = 5;
polylines(image, pt, &npt, 1, true, Scalar(0, 0, 255), 2);
imshow("polylines", image);
ends…
|