1、测试代码
void test2() {
Mat src = imread("D:/1.jpg");
// 线
line(src, Point(50, 50), Point(200, 200), Scalar(0, 255, 0), 2, CV_AA);
// 椭圆
ellipse(src, Point(src.size().width / 2, src.size().height / 2), Size(src.size().width / 4, src.size().height / 16),-30, 0, 360, Scalar(255, 0, 0), 2, CV_AA);
// 圆
circle(src, Point(200, 200), 30, Scalar(0, 0, 255), 2, CV_AA);
// 多边形
Point rookPoint[1][5];
rookPoint[0][0] = Point(50, 300);
rookPoint[0][1] = Point(80, 300);
rookPoint[0][2] = Point(100, 325);
rookPoint[0][3] = Point(80, 350);
rookPoint[0][4] = Point(50, 350);
const Point *ppt[1] = { rookPoint[0] };
int npt[] = {5};
fillPoly(src, ppt, npt,1,Scalar(255, 255, 0), CV_AA);
imshow("212", src);
imwrite("D:/result.jpg", src);
}