(1) Circle
CvSize ImageSize1 = cvSize(1000,700);
IplImage* Image1 = cvCreateImage(ImageSize1,IPL_DEPTH_8U,1);
cvNot(Image1,Image1);
CvPoint CircleCenter = cvPoint(500,350);
int Radius = 300;
CvScalar Color = CV_RGB(0,0,0);
int Thickness = CV_FILLED;
int Shift;
cvCircle(Image1,CircleCenter,Radius,Color,Thickness,CV_AA,Shift);
cvNamedWindow("Circle",1);
cvShowImage("Circle",Image1);
cvWaitKey(0);
//-------------------------------------------------------------------------------
(2) Ellipse
IplImage *Image1;
IplImage *Image2;
CvPoint CircleCenter;
CvSize EllipseAxes;
double RotateAngle;
double StartDrawingAngle;
double StopDrawingAngle;
CvScalar Color;
int Thickness = CV_FILLED;
int Shift;
CvSize ImageSize1 = cvSize(640, 480);
Image1 = cvCreateImage(ImageSize1,IPL_DEPTH_8U,3);
Image2 = cvCreateImage(ImageSize1,IPL_DEPTH_8U,1);
CircleCenter=cvPoint((gl_rect.left+gl_rect.right)/2, (gl_rect.top+gl_rect.Bottom)/2);
EllipseAxes=cvSize((gl_rect.right-gl_rect.left)/2, (gl_rect.Bottom-gl_rect.top)/2);
RotateAngle=0;
StartDrawingAngle=0;
StopDrawingAngle=360;
Color=CV_RGB(255,255,255);
Shift=0;
cvEllipse(Image1,CircleCenter,EllipseAxes,RotateAngle,
StartDrawingAngle,StopDrawingAngle,Color,Thickness,CV_AA,Shift);
cvCvtColor( Image1, Image2, CV_BGR2GRAY);
cvNamedWindow("Ellipse",1);
cvShowImage("Ellipse",Image2);
cvReleaseImage( &Image1);
cvReleaseImage( &Image2);
留言列表