How to Draw Circle in OpenCV Python

You can draw a circle in OpenCV Python by following the given steps. I highly recommend you get the “Computer Vision: Models, Learning, and Inference Book” to learn Computer Vision.

How to draw a circle in OpenCV Python
How to draw a circle in OpenCV Python

Step 1

Import the OpenCV library. If OpenCV is not installed in your system then first install it using This Method.

Python

Step 2

Now read the image from the location. In my case “C:\\AiHints” is the location and “AI.jpg” is the name of the image. Change it according to your image location and name.

Python

Step 3

Now I will draw a circle on the image using the following code. In the code, (70,70) is the center point, and 60 is the diameter of the circle. After that, I will specify a color for the circle (0,255,0) that is green color. In the end, 6 is the thickness of the circumference. You can change any value according to your requirement.

Python

Step 4

To display the image in a specified window use ”imshow” function.

Python

Step 5

“waitKey(0)” will display a window until any key is pressed. “destroyAllWindows()” will destroy all the windows that we created.

Python

Output

Green Circle on Image using OpenCV
Green Circle on Image using OpenCV

Leave a Comment

Your email address will not be published.