{% extends "base.html" %} {% block title %} HoughCircles {% endblock %} {% block description %}
Finds circles in a grayscale image using the Hough transform.
{% endblock %} {% block signature %}cv2.HoughCircles(image, method, dp, minDist[, circles[, param1[, param2[, minRadius[, maxRadius]]]]]) → circles{% endblock %} {% block parameters %}
cv2.HOUGH_*
): Detection method to use. Currently, the only implemented methods are CV_HOUGH_GRADIENT
, which is basically 21HT, described in [Yuen90], and CV_HOUGH_GRADIENT_ALT
.dp=1
, the accumulator has the same resolution as the input image. If dp=2
, the accumulator has half as big width and height. For CV_HOUGH_GRADIENT_ALT
the recommended value is dp=1.5
, unless some very small circles need to be detected.(x,y,radius)
or (x,y,radius,votes)
.CV_HOUGH_GRADIENT
and CV_HOUGH_GRADIENT_ALT
, it is the higher threshold of the two passed to the Canny edge detector (the lower one is twice smaller). Note that CV_HOUGH_GRADIENT_ALT
uses Scharr algorithm to compute image derivatives, so the threshold value should normally be higher, such as 300 for normally exposed and contrasty images. Default is 100.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. In the case of CV_HOUGH_GRADIENT_ALT
algorithm, this is the circle "perfectness" measure. The closer it is to 1, the better shaped circles the algorithm selects. In most cases 0.9 should be fine. If you want better detection of small circles, you may decrease it to 0.85, 0.8 or even less (but then also try to limit the search range [minRadius
, maxRadius
] to avoid many false circles). Default is 100.CV_HOUGH_GRADIENT
returns centers without finding the radius. CV_HOUGH_GRADIENT_ALT
always computes circle radiuses. Default is 0.minRadius
and maxRadius
), if you know it. CV_HOUGH_GRADIENT
, you may set maxRadius
to a negative number to return centers only without radius search, and find the correct radius using an additional procedure.GaussianBlur()
with \(7\times 7\) kernel and \( 1.5 \times 1.5\) sigma or similar blurring may help.