1. Draw a circle
1. CvCircle() function
<span style="font-size:18px;">void cvCircle(
CvArr* img,
CvPoint center,
int radius,
CvScalar color,
int thickness=1,
int line_type=8,
int shift=0
);</span>
parameter:
- img image
- center Coordinates of the center of the circle
- radius radius of the circle
- color the color of the line
- thickness If positive, indicates the thickness of the lines that make up the circle. Otherwise, indicates whether the circle is filled
- line_type The type of line.
- shift The number of decimal places for the coordinate point of the center of the circle and the value of the radius
<span style="font-size:18px;">#include<cv.h>
#include<highgui.h>
using namespace cv;
int main()
{
Point center = Point(100, 100); //圆心
int r = 100; //半径
Scalar Color = CV_RGB(1, 1,1); //线条的颜色
int thickness = 5; //如果是正数,表示组成圆的线条的粗细,否则,表示圆是否被填充。
int line_type = 8; //线条类型
int shift = 0; //圆心坐标点和半径值的小数点位数
Mat picture(200, 200, CV_8UC3, Scalar(255, 255, 255));
circle(picture, center, r, Color,thickness,line_type,shift);
imshow("【底板】", picture);
waitKey(0);
return 0;
}</span>
2. Draw a straight line
1. CvLine() function
<span style="font-size:18px;">void cvLine(
CvArr* img,
CvPoint pt1,
CvPoint pt2,
CvScalar color,
int thickness=1,
int line_type=8,
int shift=0
);</span>
parameter:
- img image.
- pt1 The first endpoint of the line segment.
- pt2 The second endpoint of the line segment.
- color The color of the line segment.
- thickness The thickness of the line segment.
- line_type The type of line segment.
- The number of decimal places for shift coordinates.
<span style="font-size:18px;">#include<cv.h>
#include<highgui.h>
using namespace cv;
int main()
{
Point pst1 = Point(150, 150);
Point pst2 = Point(10, 30);
Scalar color = CV_RGB(255, 0, 0);
int thinkness = 4;
int line_type = 4;
int shift = 0;
Mat img(200, 200, CV_8UC3, Scalar(255, 255, 255));
line(img, pst1, pst2, color, thinkness, CV_AA
, shift);
imshow("【效果图】", img);
waitKey(0);
return 0;
}</span>