码迷,mamicode.com
首页 > 其他好文 > 详细

opencv画直线圆椭圆矩形

时间:2015-04-12 09:15:07      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:

今天看到以前写的简单的小程序,突然想整理一下,希望对大家有用

#include <cv.h>

#include <highgui.h>

#pragma comment(lib, "cv.lib")  
#pragma comment(lib, "cxcore.lib")  
#pragma comment(lib, "highgui.lib") 

int main()
{
CvMat* srcMat1;
CvMat* srcMat2;
CvMat* srcMat3;
CvMat* srcMat4;
int radius;
double angle,start_angle,end_angle;
CvPoint cirPoint1,cirPoint2;
CvSize axes;
CvScalar cirColor;


srcMat1 = cvCreateMat(500, 500, CV_8UC3); //100*100 3通道字节型
srcMat2 = cvCreateMat(500, 500, CV_8UC3); //100*100 3通道字节型
srcMat3 = cvCreateMat(500, 500, CV_8UC3); //100*100 3通道字节型
srcMat4 = cvCreateMat(500, 500, CV_8UC3); //100*100 3通道字节型


cvSetZero(srcMat1); //清零
cvSetZero(srcMat2); //清零
cvSetZero(srcMat3); //清零
cvSetZero(srcMat3); //清零
    cirPoint1 = cvPoint(150, 150); //坐标一
cirPoint2 = cvPoint(400, 400); //坐标二
axes=cvSize(140,60);
radius = 40;//半径
angle=0;
start_angle=0;
end_angle=360;
cirColor = cvScalar(255, 255,255,0 );//蓝色

cvLine(srcMat1, cirPoint1, cirPoint2, cirColor,1,8,0); //画圆
cvCircle(srcMat2,cirPoint1,radius,cirColor,1,8,0);
cvRectangle(srcMat3,cirPoint1,cirPoint2,cirColor,1,8,0);
cvEllipse(srcMat4,cirPoint1,axes,angle,start_angle,end_angle,cirColor,1,8,0);


cvNamedWindow("Exam301",CV_WINDOW_AUTOSIZE);
cvShowImage("Exam301", (IplImage*)srcMat1);

cvNamedWindow("Exam302",CV_WINDOW_AUTOSIZE);
cvShowImage("Exam302", (IplImage*)srcMat2);

cvNamedWindow("Exam303",CV_WINDOW_AUTOSIZE);
cvShowImage("Exam303", (IplImage*)srcMat3);

cvNamedWindow("Exam304",CV_WINDOW_AUTOSIZE);
cvShowImage("Exam304", (IplImage*)srcMat4);

cvWaitKey(0);

cvReleaseMat(&srcMat1);
cvReleaseMat(&srcMat2);
cvReleaseMat(&srcMat3);
cvReleaseMat(&srcMat4);

cvDestroyWindow("Exam301");
cvDestroyWindow("Exam302");
cvDestroyWindow("Exam303");
cvDestroyWindow("Exam304");
    return 0;
}

opencv画直线圆椭圆矩形

标签:

原文地址:http://blog.csdn.net/lihuajie1003/article/details/45001031

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!