Draw an ellipse using OpenCV in C++
ellipse(image, centerCoordinates, axesLength, angle, startAngle, endAngle, color, thickness, lineType, shift)
- image: It is the image on which ellipse is to be drawn.
- centerCoordinates: Coordinates of the center of the ellipse. (Tuple of two coordinates (X-coordinate, Y-coordinate))
- axesLength:Tuple containing the major and minor axis of the ellipse (major axis length, minor axis length).
- angle: Ellipse rotation angle in degrees.
- startAngle: Starting angle of the elliptic arc(degrees).
- endAngle: Ending angle of the elliptic arc(degrees).
- color: It is the color of the borderline of the ellipse to be drawn. A tuple representing 3 colors (B, G, R) i.e., (Blue, Green, Red).
- thickness: It is the thickness of the ellipse borderline in px. The thickness of -1 px will fill the ellipse shape by the specified color.
- lineType: Type of the line. There are 3 types of line:
- LINE_4: Line was drawn using 4 connected Bresenham algorithm.
- LINE_8: Line was drawn using 8 connected Bresenham algorithm.
- LINE_AA: It draws Anti-aliased lines formed by using a Gaussian filter.
- shift: Number of fractional bits in the point coordinates.
Return Value: It returns an image.
Below is the C++ program demonstrating how to draw an ellipse over a self-formed background image:
Explanation: In the above program, an ellipse is drawn at an angle of 0 degrees i.e., horizontal ellipse.
Below is the C++ program illustrate rectangle over a loaded image with an ellipse around the GFG logo: