Ask Your Question

Revision history [back]

Hough circle error

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'

click to hide/show revision 2
No.2 Revision

Hough circle error

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,:]:

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.circle(img,(i[0],i[1]),2,(0,0,255),3)
cv2.imshow('image3',cimg)
cv2.waitKey(0)
cv2.destroyAllWindows()

cv2.imshow('image3',cimg)ERROR:

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'