Ask Your Question
0

Hough circle error

asked 2015-11-26 12:47:21 -0600

chikku gravatar image

updated 2015-11-27 12:27:56 -0600

pklab gravatar image

CODE:

import numpy as np
import cv2
img = cv2.imread('test_image5.jpg')
img = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
img = cv2.medianBlur(img,1)
cimg = cv2.cvtColor(img,cv2.COLOR_GRAY2BGR)
circles = cv2.HoughCircles(img,cv2.HOUGH_GRADIENT,1,20,param1=50,param2=30,minRadius=0,maxRadius=0)
circles = np.uint16(np.around(circles))
for i in circles[0,:]:
    cv2.circle(img,(i[0],i[1]),i[2],(0,255,0),2)
    cv2.circle(img,(i[0],i[1]),2,(0,0,255),3)

cv2.imshow('image3',cimg)
cv2.waitKey(0)
cv2.destroyAllWindows()

ERROR:

Traceback (most recent call last): File "H:***\tp\temp.py", line 8, in <module> circles = cv2.HoughCircles(img,cv2.HOUGH_GRADIENT,1,20,param1=50,param2=30,minRadius=0,maxRadius=0) AttributeError: 'module' object has no attribute 'HOUGH_GRADIENT'

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-11-27 06:33:04 -0600

nbsrujan gravatar image

Instead of using cv2.HOUGH_GRADIENT use cv2.cv.CV_HOUGH_GRADIENT

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-11-26 12:43:49 -0600

Seen: 2,019 times

Last updated: Nov 27 '15