Ask Your Question

Revision history [back]

Circle detection with HoughCircles v3.1.0

I'm experimenting with the sample code at https://github.com/opencv/opencv/blob/master/samples/cpp/tutorial_code/ImgTrans/HoughCircle_Demo.cpp , but I'm can't figure out how to use HoughCircles to detect circles in a fairly simple test. I've created I png-file with Paint containing 3 black circles (see below). 2 with approximately the same center, and one with an offset. The input file is only black&white. But when I run the demo I can see that it can't detect the outmost circle at all, it detects the second circle, and the third circle is detected but with slightly incorrect radius and center.

1) Any clue why it can't detect the outermost circle ? 2) Any clue why the 3rd circle is offset?

I've also seen that HoughCircles() has a parameter

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.

The odd thing is that this sort of says that several circles with the same center but different radius can't be detected, thus invalidating my testcase. Is it so?

image description