カメラから動画を書き出す
これもメモ.
import numpy as np
import cv2
cap = cv2.VideoCapture(0)
out = cv2.VideoWriter('output.mov',0,20,(640,480))
while(cap.isOpened()):
ret, frame = cap.read()
if ret==True:
out.write(cv2.resize(frame,(640,480)))
cv2.imshow('frame',frame)
if cv2.waitKey(1) == ord('q'):
break
else:
break
cap.release()
out.release()
cv2.destroyAllWindows()
これも何故かエラーを吐かれてよくわからなかったのだけど,どうも
out.write()のところでout.write(frame)としていたのがよくなかったらしい.
out.write(cv2.resize(frame, SIZE)) とすることで読み込んだ動画の大きさを変換して書き出すことができる?