Skip to content

Instantly share code, notes, and snippets.

@T31337
Created August 4, 2014 14:11
Show Gist options
  • Save T31337/ee4092b9ac020daecd7a to your computer and use it in GitHub Desktop.
Save T31337/ee4092b9ac020daecd7a to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import cv
from datetime import datetime
if __name__ == '__main__':
capture = cv.CaptureFromCAM(0)
cv.NamedWindow('Webcam')
while True:
frame = cv.QueryFrame(capture)
cv.ShowImage('Webcam', frame)
c = cv.WaitKey(10) % 256
if c == 27:
# ESC pressed. Finish the program
break
elif c == 10:
# ENTER pressed. Store image to disk
cv.SaveImage(datetime.now().strftime('%Y%m%d_%Hh%Mm%Ss%f') + '.jpg', frame)
capture = None
cv.DestroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment