Skip to content

Instantly share code, notes, and snippets.

@brunomlopes
Created August 31, 2010 14:59
Show Gist options
  • Save brunomlopes/559151 to your computer and use it in GitHub Desktop.
Save brunomlopes/559151 to your computer and use it in GitHub Desktop.
from VideoCapture import Device
from os import listdir
from datetime import datetime
from threading import Timer
from sys import stdin
from string import zfill
cam = Device()
format = "snap_%s_%s.png"
i = 1
l = [int(a.split("_")[1]) for a in listdir(".") if a.endswith("png")]
if len(l)>0:
i = max(l)+1
def takesnapshot(i):
n = format % (zfill(i,5), datetime.now().strftime("%Y-%m-%d_%H-%M-%S"))
print n
cam.saveSnapshot(n, quality=100)
Timer(10.0, lambda : takesnapshot(i+1)).start()
cam.setResolution(1280,960)
takesnapshot(i)
while stdin.read(1) != 'q':
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment