# Draw a circle on an image using OpenCV Python

In this tutorial, we will learn how to draw a circle on an image using OpenCV Python. This can be useful when we want to detect an object in an image. We will discuss the techniques used to draw a circle. So let’s begin the tutorial.

For using the following methods, make sure that you have installed all the libraries for OpenCV.

## Using cv2.circle()

This method is majorly used to draw circles. This method takes 7 arguments. Five of them are used.

image: The input image on which the circle should be drawn.

center_coordinates: Values for x and y must be specified in a tuple notation.

radius: Radius of the circle to be drawn.

color: Color of the circle to be drawn. Values are specified in the form of a three-tuple notation in the form of BGR.

thickness: Thickness of the circle. Negative values are used to fill the circle.

lineType: Type of circle boundary.

shift: Count of fractional bits in coordinates and radius value.

My file name is `1.jpeg`

### Example 1

Use the given code to draw a circle

import cv2 img = cv2.imread('1.jpeg') circleim = cv2.circle(img,(250,200),110,(0,0,0),5) cv2.imshow('image',circleim) cv2.waitKey()

Here, img is the input image.

The coordinate values are (250,200).

Radius is 110.

The color is black.

The thickness is 5.

## Using cv2.ellipse()

We can draw a circle using this method also. It has 11 arguments. Eight of them are used.

image: The input image on which the circle should be drawn.

center_coordinates: Values for x and y must be specified in a tuple notation.

axes: Values for major and minor axes.

angle: Rotation angle value in degrees.

startAngle: Value of start angle in degrees.

endAngle: Value of end angle in degrees.

box: Draws ellipse inscribed in a rotated rectangle.

color: Color of the circle to be drawn. Values are specified in the form of a three tuple notation in the form of BGR.

thickness: Thickness of the circle. Negative values are used to fill the circle.

lineType: Type of circle boundary.

shift: Count of fractional bits in coordinates and radius value.

### Example 2

Consider the same image as above.

Use the given code to draw a circle.

import cv2 img = cv2.imread('1.jpeg') imgg = cv2.ellipse(img,(245,200),(110,110),0,0,360,(0,0,0),5) cv2.imshow('image',imgg) cv2.waitKey()

Here, img is the input image.

The center_coordinates are (245,200).

Axes length are (110,110).

The angle of rotation is 0.

The start angle is 0.

The end angle is 360.

The color is black.

The thickness is 5.

## Leave a Reply