타원을 그리려면 중심, 장축 및 단축이 필요합니다. 즉, 타원에 세 개의 매개변수가 필요합니다. 타원을 그릴 행렬이 필요하고 선 두께와 선 색상을 선언해야 합니다.
OpenCV를 사용하여 타원을 그리려면 회전 각도를 언급해야 하며 두 개의 추가 매개변수 시작점과 끝점이 있습니다. 'ellipse()' 함수를 호출하려면
이 방법의 기본 구문은 다음과 같습니다 -
구문
ellipse(whiteMatrix, center, xy,angle, starting_point, ending_point, 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
Size xy(100, 50);//Declaring the major and minor axis of the ellipse//
int angle = 50;//angle of rotation//
int starting_point = 0;//Starting point of the ellipse//
int ending_point = 360;//Ending point of the ellipse//
Scalar line_Color(0, 0, 0);//Color of the Ellipse//
int thickness = 2;//thickens of the line//
namedWindow("whiteMatrix");//Declaring a window to show the ellipse//
ellipse(whiteMatrix, center, xy,angle, starting_point, ending_point, line_Color,thickness);//Drawing the ellipse
imshow("WhiteMatrix", whiteMatrix);//Showing the ellipse
waitKey(0);//Waiting for Keystroke
return 0;
} 출력
