Skip to content

Instantly share code, notes, and snippets.

@towc
Created February 27, 2019 14:51
Show Gist options
  • Save towc/bf56645b21ec40200fb3174bd5c06061 to your computer and use it in GitHub Desktop.
Save towc/bf56645b21ec40200fb3174bd5c06061 to your computer and use it in GitHub Desktop.
import cv2
cap = cv2.VideoCapture(0)
fourcc = cv2.VideoWriter_fourcc(*'MJPG')
out = cv2.VideoWriter('appsrc ! videoconvert ! gtksink',
fourcc, 20.0, (640, 480))
while cap.isOpened():
ret, frame = cap.read()
if ret:
# frame = cv2.flip(frame, 0)
out.write(frame)
cv2.imshow('frame', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
else:
break
cap.release()
out.release()
cv2.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment