Time-lapse photography using the Raspberry Pi Camera

This is my first project using my Raspberry Pi camera, we had a need to monitor our new Guinea Pigs and while my girlfriend was away I thought I’d use the Raspberry Pi camera to do this. ¬†The project provides the following functionality:

  • Take a photo every x seconds
  • Collate photos into a timelapse video
  • upload the video to you-tube

Additional functions I added whilst I developed the system were:

  • Generate the video if the memory becomes full to enable further monitoring
  • Add a light sensor so that pictures of the dark are not taken, this would also allow the processing to be done during downtime (if the memory card is large enough)
  • Add a switch to enable the program to end cleanly

The circuit that I set up is shown below:

Time Lapse Supporting Circuit

There are two basic parts to the circuit:

  • Switch – used to turn the timelapse on\off
  • RC Timing Circuit – used to derive the light level from the time it takes the capacitor to charge, full details of this circuit and the theory\code can be found on Raspberry Pi Spy.

Setting up the software

The following pre-requisites are required:

  • Raspberry Pi with network connectivity
  • Raspbian distibution
  • Raspberry Pi camera installed and configured
  • The circuit shown earlier in the post connected to the ¬†GPIO

Run the following commands in order to install the required libraries.

sudo apt-get install python-gdata

sudo apt-get install python-pycurl

The next step was to include the library to upload the file to YouTube, for this I used YouTube-Upload.  To install this I ran the following steps ,replacing VERSION with the latest version, I used 0.7.3.

$ wget <a href="http://youtube-upload.googlecode.com/files/youtube-upload-VERSION.tgz">http://youtube-upload.googlecode.com/files/youtube-upload-VERSION.tgz</a>

$ tar xvzf youtube-upload-VERSION.tgz

$ cd youtube-upload-VERSION

$ sudo python setup.py install

I have provided the source code on this bog for reference.  The code includes comments to help you identify what is happening so rather than the walkthrough please take a look and edit as required to fit your needs.

Replace <youtube account id> and <password> with your youtube username and password, the title and other items can also be customised.

The videos generated can be seen on the YouTube channel

One thought on “Time-lapse photography using the Raspberry Pi Camera”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.