Updated by Alexander Shishkov about 13 years ago

Hi,
cvHoughCircles has problems detecting small circles. I think that I have found a couple of bugs.
I attached the source image the circle is not detected using these parameters
cvHoughCircles( image, storage, CV_HOUGH_GRADIENT, 1, 10, 100, 10, 5, 20 );

The first bug is in line 931, 932. The coordinates (x,y) of the cell should be
y = ofs/(acols+2);
x = ofs - (y)*(acols+2);

As an enhancement, in the following line, the center of the cell should be located in the center of the cell, not in the corner
float cx = (float)( (x + 0.5)*dp), cy = (float)((y + 0.5)*dp);

The next one, i'm not sure if it is a bug or not, in line 936
int max_count = R_THRESH;
R_THRESH=30 is a constant
This produces that the circle is not detected because of line 983
(r_best < FLT_EPSILON && start_idx - j >= max_count) )
shouldn't max_count be initialized to cero?

And finally in line 995, the support of the circle must be tested with the parameter acc_threshold, instead of the constant R_THRESH
if( max_count > acc_threshold )

I'm using OpenCV2.2 [[OpenCV]]2.2 on Windows XP, 32bit, compiled with VS2008
I found this similar ticket 518
https://code.ros.org/trac/opencv/ticket/518
I also attach a test with the image from this ticket

Regards
Javier Barandiaran Martirena
http://jbarandiaran.googlepages.com/

Back