OpenCV  3.4.19
Open Source Computer Vision
Hough Circle Transform

Prev Tutorial: Hough Line Transform

Next Tutorial: Object detection with Generalized Ballard and Guil Hough Transform

Goal

In this tutorial you will learn how to:

Theory

Hough Circle Transform

What does this program do?

Code

Explanation

The image we used can be found here

Load an image:

Convert it to grayscale:

Apply a Median blur to reduce noise and avoid false circle detection:

Proceed to apply Hough Circle Transform:

Draw the detected circles:

You can see that we will draw the circle(s) on red and the center(s) with a small green dot

Display the detected circle(s) and wait for the user to exit the program:

Result

The result of running the code above with a test image is shown below:

Hough_Circle_Tutorial_Result.png