Raspberry PI Shotter 0.1

The Shotter is one of my first project I used the Raspberry for, and the idea is very simple: using a Raspberry PI and a webcam to take a photo every n seconds, and eventually mounting a video from the taken frames.

I made this with one of my PIs, and i configured it to automatically start taking the photos when I plug a usb drive, and to save the photos directly to the key. If you want to stop it, you just unplug the usb key or switch off the power. The photos are saved with an alphabetical friendly format, that is a increasing number padded with zeros: ‘00000001.jpg’, ‘00000002.jpg’, … This makes easy to make the final video, for example with mencoder: 

mencoder “mf://*.jpg” -mf fps=10 -o test.avi -ovc lavc -lavcopts vcodec=msmpeg4v2:vbitrate=800

The photos have a small size, about 70-80KB, so that a 1Gb usb key can handle more than one day of photos taken every 10 seconds.

I also added a led to the PI, which it’s blinking when the PI is waiting for the timeout to expire, just to say that everything is working fine (it’s been very useful while debugging).

Here are some videos I made with my shotter:

I think it’s great for taking photos during a party (I did it but I won’t publish the video here 🙂 )

Here’s a stupid python code to do the job (launched by a usbmount script, see this other post where I explain something more about usbmount or just search the Internet)


import sys
import time
import os
import RPi.GPIO as GPIO


def getIndex():
        f = open('/home/pi/shotter_service/index', 'r')
        text = f.read()
        index = int(text)
        index = 0
    return index

def setIndex(index):
    f = open('/home/pi/shotter_service/index', 'w')

def padding(what, length):
    what = str(what)
    for i in range(length - len(what)):
        what = "0" + what
    return what

dev = 0
secs = 10
version = "0.1"
index = getIndex()

state = False

if len(sys.argv) > 1:
  dev = int(sys.argv[1])

if len(sys.argv) > 2:
  secs = int(sys.argv[2])
while True:
  print "Current Index is " + str(index)
  os.system("fswebcam -r 640x480 -S 15 --subtitle "Daniele Nicassio's Projects" --banner-colour 80000000 --line-colour 00FFFFFF --title "Raspberry PI Shotter "+version+"" --info "https://www.nicassio.it/daniele/blog" --no-timestamp --jpeg 95 -d /dev/video"+str(dev) + " --save /media/usb0/""+padding(index, 10)+".jpg"")
  index += 1
  for i in range(secs):
    state = not state
    GPIO.output(22, state)


3 thoughts on “Raspberry PI Shotter 0.1”

  1. Great little project – nicely done. And thank you for the mencoder line – I’ve got hold of a pre-release camera module and have been trying to figure out how to do a timelapse video for the past week. Going to try your method!

Comments are closed.