Ask Your Question

How to detect small circle using Hough Circle Transform?

asked 2018-02-19 21:36:51 -0500

syazwan0913 gravatar image

I want to detect small circle like the shape of golf ball which is about 150 cm from the camera. What parameter in hough circle transform should I change?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2018-02-20 00:36:27 -0500

phillity gravatar image

Here are the HoughCircles parameters and default arguments:

void cv::HoughCircles(

  • InputArray image, //8-bit, single-channel, grayscale input image.
  • OutputArray circles, // Output vector of found circles. Each vector is encoded as a 3-element floating-point vector (x,y,radius)
  • int method, //Detection method, see cv::HoughModes. Currently, the only implemented method is HOUGH_GRADIENT
  • double dp, //Inverse ratio of the accumulator resolution to the image resolution. For example, if dp=1 , the accumulator has the same resolution as the input image. If dp=2 , the accumulator has half as big width and height.
  • double minDist, //Minimum distance between the centers of the detected circles. If the parameter is too small, multiple neighbor circles may be falsely detected in addition to a true one. If it is too large, some circles may be missed.
  • double param1 = 100, // First method-specific parameter. In case of CV_HOUGH_GRADIENT , it is the higher threshold of the two passed to the Canny edge detector (the lower one is twice smaller).
  • double param2 = 100, //Second method-specific parameter. In case of CV_HOUGH_GRADIENT , it is the accumulator threshold for the circle centers at the detection stage. The smaller it is, the more false circles may be detected. Circles, corresponding to the larger accumulator values, will be returned first.
  • int minRadius = 0, //Minimum circle radius.
  • int maxRadius = 0 //Maximum circle radius.


Note: Usually the function detects the centers of circles well. However, it may fail to find correct radii. You can assist to the function by specifying the radius range ( minRadius and maxRadius ) if you know it. Or, you may ignore the returned radius, use only the center, and find the correct radius using an additional procedure.

Also, here is a tutorial with a sample code and explination

edit flag offensive delete link more


You might also want to take a look at this stackoverflow solution

phillity gravatar imagephillity ( 2018-02-20 00:41:29 -0500 )edit

I missed one information in my question which I am using webcam to detect the circle. If I used image that have circle shape, it can detect but if I used webcam (Logitech Pro C920M) cannot detect. I don't know what is the problem

syazwan0913 gravatar imagesyazwan0913 ( 2018-02-20 00:44:56 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-02-19 21:36:51 -0500

Seen: 697 times

Last updated: Feb 20 '18