#Visualstogramas import numpy as np import cv2 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, frame = cap.read() if ret==True: hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) hist = cv2.calcHist([hsv],[0],None,[256],[0,256]) cv2.imshow('Imagen Original',frame) cv2.imshow('Grises',hsv) if cv2.waitKey(1) & 0xFF == ord('q'): break else: break # Release everything if job is finished cap.release() cv2.destroyAllWindows() color = ('b','g','r') for i,col in enumerate(color): histr = cv2.calcHist([frame],[i],None,[256],[0,256]) plt.plot(histr,color = col) plt.xlim([0,256]) plt.show()