I'm attempting to locate some colored balls in an image, and to reduce the risk of false positives, I'm first reducing the image to a binary image based on the color of the ball that is currently being searched for. OpenCV's HoughCircles fails to find any circles in the binary image, while performing reasonably well on the original image converted to grayscale. Does HoughCircles simply not work on binary images? I haven't been able to find any documentation suggesting so.
The input image should be for houghcircle: 8-bit, single-channel, and grayscale
.
In your image also houghcircle is able to find that circle. All you need is to choose the correct parameters for function. I tried these parameters and its able to find it:
rows = gray.shape[0]
circles = cv2.HoughCircles(gray, cv2.HOUGH_GRADIENT, 1, rows / 8,
param1=30, param2=15,
minRadius=0, maxRadius=0)
Note: Its better to apply gaussian or medianBlur before houghcircle.
Result: