- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to draw an Ellipse in OpenCV using C++?
To draw an ellipse, we need a center, major axis and minor axis. That means we need three parameters for the ellipse. We need a matrix where we will draw the ellipse, and we need to declare line thickness and line color.
When we want to draw an ellipse using OpenCV, we have to mention the angle of rotation, and there are two additional parameter starting point and ending point. To call 'ellipse()' function, we need to include<imgproc.hpp> header file.
The basic syntax of this method is as follows −
Syntax
ellipse(whiteMatrix, center, xy,angle, starting_point, ending_point, line_Color,thickness);
The following program shows how to draw an ellipse in OpenCV.
Example
#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; }
Output
- Related Articles
- How to draw an ellipse in OpenCV using Java?
- Draw an ellipse on an image using OpenCV
- How to draw a filled ellipse in OpenCV using Java?
- How to draw an ellipse using imageellipse() function in PHP?
- How to fit the ellipse to an object in an image using OpenCV Python?
- How to draw an arrowed line in OpenCV using Java?
- Draw an ellipse in C#
- How to draw polylines on an image in OpenCV using Python?
- How to draw polylines in OpenCV using Java?
- How to draw markers on an image using Java OpenCV library?
- Draw rectangle on an image using OpenCV
- OpenCV Python – How to detect and draw keypoints in an image using SIFT?
- How to draw a line in OpenCV using Java?
- How to draw a rectangle in OpenCV using Java?
- How to draw a circle in OpenCV using Java?

Advertisements