1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
   | 
  import numpy as np import cv2 as cv
 
  cap=cv.VideoCapture(0)  
 
  fourcc=cv.VideoWriter_fourcc(*"DIVX")       
 
 
 
 
 
  out=cv.VideoWriter("output.avi",fourcc,50.0,(640,480),0)     '''out=cv.VideoWriter("output.avi",fourcc,50.0,(640,480))''' while cap.isOpened():     ret,frame=cap.read()     if not ret:         print("Cannot receive frame (stream end?).Exiting...")         break     frame=cv.flip(frame,1)     gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)            out.write(gray)     '''out.write(frame)'''     cv.imshow("frame",frame)         if cv.waitKey(1)==ord("q"):          break
  cap.release() out.release() cv.destroyAllWindows()
 
  |