How to capture, write and display a video in opencv.
import cv2 import numpy as np capture = cv2.VideoCapture(0) frame_width = int(capture.get(3)) frame_height = int(capture.get(4)) out = cv2.VideoWriter('output_1.avi',
cv2.VideoWriter_fourcc('M', 'J', 'P', 'G'), 15,
(frame_width, frame_height)) while True: ret, frame = capture.read() out.write(frame) cv2.imshow('window', frame) if cv2.waitKey(1) == 27: break capture.release() cv2.destroyAllWindows()
Comments
Post a Comment