1import numpy as np
2import cv2
3
4cap = cv2.VideoCapture(0)
5
6fourcc = cv2.VideoWriter_fourcc(*'XVID')
7out = cv2.VideoWriter('output.avi', fourcc, 20.0, (640,480))
8
9while(cap.isOpened()):
10 ret, frame = cap.read()
11 if ret==True:
12 frame = cv2.flip(frame,0)
13
14
15 out.write(frame)
16
17 cv2.imshow('frame',frame)
18 if cv2.waitKey(1) & 0xFF == ord('q'):
19 break
20 else:
21 break
22cap.release()
23
24out.release()
25
26cv2.destroyAllWindows()