Reputation: 19293
I have the following code and I want to detect the circle.
img = cv2.imread("act_circle.png")
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
circles = cv2.HoughCircles(gray,cv2.CV_HOUGH_GRADIENT)
it looks like it does not have the attribute and the error is the following
'module' object has no attribute 'CV_HOUGH_GRADIENT'
Does anybody know where this hidden parameters is?
Thanks
Upvotes: 12
Views: 19366
Reputation: 3688
CV_HOUGH_GRADIENT
belongs to the cv
module, so you'll need to import that:
import cv2.cv as cv
and change your function call to
circles = cv2.HoughCircles(gray,cv.CV_HOUGH_GRADIENT)
Now in current cv2 versions:
import cv2
cv2.HOUGH_GRADIENT
Upvotes: 19
Reputation: 674
if you use OpenCV 3, then use this code :
img = cv2.imread("act_circle.png")
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
circles = cv2.HoughCircles(gray,cv2.HOUGH_GRADIENT) # change here
Upvotes: 5
Reputation: 597
In my case, I am using opencv 3.0.0 and it worked the following way:
circles = cv2.HoughCircles(gray_im, cv2.HOUGH_GRADIENT, 2, 10, np.array([]), 20, 60, m/10)[0]
i.e. instead of cv2.cv.CV_HOUGH_GRADIENT
, I have used just cv2.HOUGH_GRADIENT
.
Upvotes: 17