एक दीर्घवृत्त खींचने के लिए, हमें एक केंद्र, दीर्घ अक्ष और लघु अक्ष की आवश्यकता होती है। इसका मतलब है कि हमें अंडाकार के लिए तीन पैरामीटर चाहिए। हमें एक मैट्रिक्स की आवश्यकता है जहां हम दीर्घवृत्त खींचेंगे, और हमें रेखा की मोटाई और रेखा का रंग घोषित करने की आवश्यकता है।
जब हम 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;
} आउटपुट
