OpenCV——简易画图之画小猪

#include
#include
using namespace cv;
using namespace std;

int main(void)
{
	Mat img = Mat(1000, 1000, CV_8UC3, Scalar(255, 255, 255));

	circle(img, Point(450, 250), 200, Scalar(0, 0, 0), 3, 4);
	circle(img, Point(335, 200), 30, Scalar(0, 0, 0), 3, 4);
	circle(img, Point(545, 200), 30, Scalar(0, 0, 0), 3, 4);
	ellipse(img, Point(230, 100), Size(100, 50), 90, 0, 360, Scalar(0, 0, 0), 4, 4);
	                          //size.width  size.height    
	ellipse(img, Point(670, 100), Size(100, 50), 90, 0, 360, Scalar(0, 0, 0), 4, 4);
	rectangle(img, Point(325, 190), Point(345, 210), Scalar(0, 0, 0), 3, 4);
	rectangle(img, Point(535, 190), Point(555, 210), Scalar(0, 0, 0), 3, 4);

	ellipse(img, Point(445, 300), Size(80, 50), 180, 0, 360, Scalar(0, 0, 0), 4, 4);
	circle(img, Point(410, 300), 15, Scalar(0, 0, 0), 3, 4);
	circle(img, Point(480, 300), 15, Scalar(0, 0, 0), 3, 4);

	imshow("绘制图", img);
	waitKey(0);
	return 0;
}

运行结果如下:

 

OpenCV——简易画图之画小猪_第1张图片

 

三个函数的用法如下:

ellipse ( img , center , axes , angle , start_angle , end_angle , color , thickness , lineType)

circle ( img , center_point , radius , color , thickness , lineType)

rectangle ( img , point1 , point2 , color , thickness , lineType )
 

你可能感兴趣的:(OpenCV)