[OpenCV] Drawing

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:

  1. img image
  2. center  Coordinates    of the center of the circle
  3. radius radius of the circle
  4. color the color of the line
  5. thickness If positive, indicates the thickness of the lines that make up the circle. Otherwise, indicates whether the circle is filled
  6. line_type The type of line.
  7. shift The number of decimal places for the coordinate point of the center of the circle and the value of the radius
2. Example:

<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:

  1. img image.
  2. pt1 The first endpoint of the line segment.
  3. pt2 The second endpoint of the line segment.
  4. color The color of the line segment.
  5. thickness The thickness of the line segment.
  6. line_type The type of line segment.
  7. The number of decimal places for shift coordinates.
2. Examples

<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>





Guess you like

Origin blog.csdn.net/Kigha/article/details/51146412