import numpy as np import cv2 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: # img = cv2.flip(frame,1) # write the flipped frame # out.write(frame) # dst = cv2.filter2D(frame,-1,kernel) imggris = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY) laplacian = cv2.Laplacian(imggris,cv2.CV_64F) sobelx = cv2.Sobel(imggris,cv2.CV_64F,1,0,ksize=3) sobely = cv2.Sobel(imggris,cv2.CV_64F,0,1,ksize=3) cv2.imshow('frame',frame) cv2.imshow('laplacian',laplacian) cv2.imshow('sobel en X',sobelx) cv2.imshow('Sobel en Y',sobely) if cv2.waitKey(1) & 0xFF == ord('q'): break else: break # Release everything if job is finished cap.release() cv2.destroyAllWindows()