#Visualstogramas import numpy as np import cv2 import cv from matplotlib import pyplot as plt cap = cv2.VideoCapture(0) # Define the codec and create VideoWriter object #ourcc = cv2.cv.CV_FOURCC(*'XVID') # cv2.VideoWriter_fourcc() does not exist #ut = cv2.VideoWriter('output.avi',fourcc, 20.0, (640,480)) kernel = np.ones((3,3),np.uint8) while(cap.isOpened()): ret, img = cap.read() cimg = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) circles = cv2.HoughCircles(cimg,cv2.cv.CV_HOUGH_GRADIENT,1,70,param1=50,param2=30,minRadius=50,maxRadius=100) 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('detected circles',cimg) cv2.imshow('Imagen Original',img) if cv2.waitKey(1) & 0xFF == ord('q'): break # Release everything if job is finished cap.release() cv2.destroyAllWindows()