Last active
September 18, 2015 13:25
-
-
Save TheAnonymous/8aeaebeb884a1c29599f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import cv2 | |
#from matplotlib import pyplot as plt | |
cap = cv2.VideoCapture(0) | |
cap.set(cv2.CAP_PROP_FPS, 20) | |
# Define the codec and create VideoWriter object | |
#fourcc = cv2.cv.CV_FOURCC(*'DIVX') | |
###width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH) + 0.5) | |
###height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT) + 0.5) | |
size = (int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)), | |
int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))) | |
fourcc = cv2.VideoWriter_fourcc(*'mp4v') | |
#w=int(cap.get(cv2.cv.CV_CAP_PROP_FRAME_WIDTH )) | |
#h=int(cap.get(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT )) | |
out = cv2.VideoWriter('~/Desktop/output.mp4',fourcc, 20.0, size, True) | |
while cap.isOpened(): | |
ret, frame = cap.read() | |
if ret: | |
if frame is not None: | |
out.write(frame) | |
cv2.imshow('frame',frame) | |
if cv2.waitKey(1) & 0xFF == ord('q'): | |
break | |
else: | |
break | |
# Release everything if job is finished | |
cap.release() | |
out.release() | |
cv2.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment