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
| import cv2
cv2.namedWindow('mywin',cv2.WINDOW_NORMAL) cv2.resizeWindow('mywin',640,480)
cap = cv2.VideoCapture(0)
fourcc = cv2.VideoWriter_fourcc('m','p','4','v') vw= cv2.VideoWriter('./out.mp4',fourcc,25,(640,480))
while cap.isOpened(): ret,frame = cap.read()
if ret == True: cv2.imshow('mywin',frame) cv2.resizeWindow('mywin',640,480) vw.write(frame)
key = cv2.waitKey(40) if(key == ord('q')): print('exit') break
cap.realase() vw.realase() cv2.destroyAllWindows()
|