Skip to content Skip to sidebar Skip to footer

Python OpenCV Hough Circles Returns None

I'm trying to figure out Hough Circles before I incorporate it into my main code for a tracking program I'm trying to write, but I can't seem to get anything but None out from

Solution 1:

The following code will give you non-None circles:

import numpy as np
import cv2

img = cv2.imread("../images/opencv_logo.png", 0)
img = cv2.medianBlur(img,5)
cimg = cv2.cvtColor(img,cv2.COLOR_GRAY2BGR)
cv2.imshow("grayscale", cimg)
cv2.waitKey(0)

circles = cv2.HoughCircles(img,cv2.HOUGH_GRADIENT,1,20,
                                    param1=50,param2=30,minRadius=0,maxRadius=0)
print (circles)

Indeed, the output is:

[[[  45.5         133.5          16.50757408]
  [  97.5          45.5          16.80773544]
  [ 147.5         133.5          16.32482719]]]


Note: the snippet uses the following as its input image:

enter image description here


Post a Comment for "Python OpenCV Hough Circles Returns None"