import cv2
import numpy as np
import cv2.cv as cv
cap = cv2.VideoCapture(0)
while(True):
ret,frame =cap.read()
img = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
# img = cv2.imread('soda.png',0)
img = cv2.medianBlur(img,5)
circles = cv2.HoughCircles(img,cv.CV_HOUGH_GRADIENT,1,250,param1=70,param2=30,minRadius=0,maxRadius=0)
circles = np.uint64(np.around(circles))
for i in circles[0,:]:
# draw the outer circle
cv2.circle(img,(i[0],i[1]),i[2],(0,255,0),2)
# draw the center of the circle
cv2.circle(img,(i[0],i[1]),2,(0,0,255),3)
cv2.imshow('detected circles',img)
if cv2.waitKey(60) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
I think it is a problem of empty
circles