import numpy as np import cv2 cap = cv2.VideoCapture(0) while(1): ret, frame = cap.read() img = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY) img = cv2.medianBlur(img,5) cimg = cv2.cvtColor(img,cv2.COLOR_GRAY2BGR) circles = cv2.HoughCircles(img,cv2.cv.CV_HOUGH_GRADIENT,1,20,param1=50,param2=30,minRadius=30,maxRadius=70) print type( circles) if circles is not None: circles = np.uint16(np.around(circles)) for i in circles[0,:]: # draw the outer circle cv2.circle(cimg,(i[0],i[1]),i[2],(0,255,0),2) # draw the center of the circle cv2.circle(cimg,(i[0],i[1]),2,(0,0,255),3) cv2.imshow('frame o',cimg) cv2.imshow('frame',frame) k = cv2.waitKey(30) & 0xff if k == 27: break cap.release() cv2.destroyAllWindows()