Opencv绘图操作

来源:互联网 发布:如何在淘宝上找店铺 编辑:程序博客网 时间:2024/06/06 01:17

程序运行结果:


程序代码:

#include <opencv2/core/core.hpp>#include <opencv2/highgui/highgui.hpp>#include <opencv2/imgproc/imgproc.hpp>using namespace cv;#define WINDOW_NAME1 "【绘制图】"        //为窗口标题定义的宏 #define WINDOW_WIDTH 600//定义窗口大小的宏void DrawEllipse( Mat img, double angle );//绘制椭圆void DrawFilledCircle( Mat img, Point center );//绘制圆int main( void ){// 创建空白的Mat图像Mat atomImage = Mat::zeros( WINDOW_WIDTH, WINDOW_WIDTH, CV_8UC3 );//先绘制出椭圆DrawEllipse( atomImage, 90 );DrawEllipse( atomImage, 0 );//再绘制圆心DrawFilledCircle( atomImage, Point( WINDOW_WIDTH/2, WINDOW_WIDTH/2) );imshow( WINDOW_NAME1, atomImage );moveWindow( WINDOW_NAME1, 0, 200 );waitKey( 0 );return(0);}void DrawEllipse( Mat img, double angle ){int thickness = 2;int lineType = 8;ellipse( img,Point( WINDOW_WIDTH/2, WINDOW_WIDTH/2 ),Size( WINDOW_WIDTH/4, WINDOW_WIDTH/16 ),angle,0,360,Scalar( 255, 129, 0 ),thickness,lineType );}//自定义的绘制函数,实现了实心圆的绘制void DrawFilledCircle( Mat img, Point center ){int thickness = -1;int lineType = 8;circle( img,center,WINDOW_WIDTH/32,Scalar( 0, 0, 255 ),thickness,lineType );}