원에는 중심과 반지름이 있습니다. OpenCV를 사용하여 원을 그리려면 중심과 반지름을 정의해야 합니다. OpenCV에서는
이 방법의 기본 구문은 다음과 같습니다 -
구문
circle(whiteMatrix, center,radius, line_Color, thickness);
다음 프로그램은 OpenCV에서 원을 그리는 방법을 나타냅니다.
예
#include<iostream>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
using namespace cv;
using namespace std;
int main() {
Mat whiteMatrix(200, 200, CV_8UC3, Scalar(255, 255, 255));//Declaring a white matrix
Point center(100, 100);//Declaring the center point
int radius = 50; //Declaring the radius
Scalar line_Color(0, 0, 0);//Color of the circle
int thickness = 2;//thickens of the line
namedWindow("whiteMatrix");//Declaring a window to show the circle
circle(whiteMatrix, center,radius, line_Color, thickness);//Using circle()function to draw the line//
imshow("WhiteMatrix", whiteMatrix);//Showing the circle//
waitKey(0);//Waiting for Keystroke//
return 0;
} 출력
