DEV Community

Divyanshu Shekhar
Divyanshu Shekhar

Posted on • Edited on

Circle Detection OpenCV Python

Circle Detection OpenCV Algorithm

The first step is common in every OpenCV Detection program, i.e to load the image on which the algorithm is to be applied.

The image is the resized and a colorful copy of that image is stored in another variable. The Image is then converted to the grayscale image as the HoughCircles() function is applied only to the grayscale images.

Then the HoughCircle() function is applied on the grayscale image.

Gray scaled image is then blurred using medianBlur() function.

The HoughCircles() function in the OpenCV library takes many parameters.

  1. The grayscale image on which the circle detection is to be implemented.
  2. Gradient function – cv.HOUGH_GRADIENT
  3. DP value i.e the resolution of the accumulator
  4. minimum distance
  5. Number of circles
  6. parameter 1
  7. parameter 2
  8. Minimum Radius
  9. Maximum Radius ## The formula of Circle:

(x-xc)2 + (y-yc)2 = r2 – HoughCircles() function present in the OpenCV library uses this mathematical formula to detect circles.

Read more and get the source code from the original blog post Circle Detection OpenCV Python.

Top comments (0)