Skip to content

Instantly share code, notes, and snippets.

@benhosmer
Last active December 17, 2015 18:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benhosmer/5653641 to your computer and use it in GitHub Desktop.
Save benhosmer/5653641 to your computer and use it in GitHub Desktop.
Raspberry pi camera module time-delayed loop.
#!/usr/bin/env python
'''
Usage:
python timed_capture.py
'''
import datetime
from time import sleep
import subprocess
fps = 1 # The number of frames to capture per second.
total_dur = 10 # The total capture time.
'''
The settings above capture 1 frame every second and runs
for a total of 10 seconds. Afterwards you'll have 10 images
captured 1 second apart from each other
'''
for x in range(total_dur):
current_time = str(datetime.datetime.now())
file_name = current_time.replace(' ', '_') + '.jpg'
subprocess.call(['raspistill', '-o', file_name, '-n'])
sleep(fps)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment