Circle detection with HoughCircles v3.1.0
I'm experimenting with the sample code at https://github.com/opencv/opencv/blob... , 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?
I've also tested the shoe-image in link text , but have not been able to reproduce the result shown in the Wiki-article
cv::HoughCircles
uses gradients for detecting. In a b/w image there are not that much gradients. You could blur your b/w image before HoughCircles.Finding coaxial circles is difficult, because minDist (Minimum distance between centers) must be greater than 0 and with a small value you get a lot of found circles for a single real circle.
Currently I have made a pull request where you can specify the maximum number of circles returned. If you know the number, you can set
minDist
to 1 or smaller andmaxCircles
to 3, but it is possible that you get 2 circles for one real circle and non for the other one, so try it out and give me some feedback.