Created
March 21, 2018 06:45
-
-
Save VGostyuzhov/e6b388aebb166fb3118d7c473942bd61 to your computer and use it in GitHub Desktop.
Capture webcam stream using opencv2 library.
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 cv2 | |
cap = cv2.VideoCapture(0) | |
fourcc = cv2.VideoWriter_fourcc(*'XVID') | |
out = cv2.VideoWriter('output.avi', fourcc, 20.0, (1024,768)) | |
while(True): | |
ret, frame = cap.read() | |
if ret==True: | |
frame = cv2.flip(frame, 1) | |
out.write(frame) | |
cv2.imshow('frame',frame) | |
if cv2.waitKey(1) & 0xFF == ord('q'): | |
break | |
else: | |
break | |
cap.release() | |
cv2.DestroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment