Wednesday, 19 March 2014

Get Arty with the Raspberry Pi Camera Making Time Lapse



What you will need:

  • A Raspberry Pi
  • A Raspberry Pi Camera Module
  • A Pi Camera Mount
  • Something to point at!

Setting up a Pi Camera with a Raspberry Pi

One of the best add on's for a Raspberry Pi is a Pi Camera. It is a small board that connects to a Raspberry Pi with a ribbon style cable. Connecting a Pi Cam can be fiddly as the cable needs to be the right way round for it to work.

Begin by unwrapping your Pi Camera and removing the small blue plastic from the lens. Next locate the ribbon cable connector nearest to the Ethernet port. It is a small think black connector. Pull the two clips at either ends up to open it. Place the Pi camera ribbon cable into the slot with the blue side facing towards the ethernet port and the silver connectors facing away from the ethernet port. Whilst holding the pi camera ribbon cable gently push down the two black connectors on the Pi.  Finally connect your Pi to a power source and let it boot.

That's the fiddly bit done! Now you will need to configure your raspberry pi before testing that your camera works. After logging in type:

sudo raspi-config

Select Enable Camera from the list with your keyboard and press enter. Select 'Enable' then 'Finish' and  'Yes' to reboot your Pi.

Once your Pi has booted again and you have logged in, and typed 'startx' to load the Raspbian graphical user interface, you can test that your camera works. Open a new LXTerminal window and type the following line:

raspistill -o cam.jpg

Press enter and you should see a preview of what your camera can see. It will then take a picture and save it in your home directory.

Getting Arty with Time Lapse Video

The Pi Camera takes some great resolution images, and is small enough to leave running by a window to take pictures over the course of a few hours. When you put all these images together in rapid succession you create a time lapse video. Here is an example of what you can do if you get good at time lapse photography:



To begin you will need to set your Raspberry Pi and camera up pointing out of a window somewhere. When I was in my office I pointed it out of a window at a road junction which is a bit boring, but sometimes you've got to work with what you have :)

I followed the Raspberry-Pi Spy's tutorial and I've summerised the main points here:

Once setup, log into your Pi and on the command line or from an LXTerminal window type:

mkdir webcam
cd webcam
raspistill -o image_%04d.jpg -tl 60000 -t 7200000

The last command will take a photo every 60 seconds (60000 milliseconds) for 2 hours (7200000 milliseconds) resulting in a sequence of 120 images. 
The “%04d” will result in a four digit number appearing in each filename.
Go away for two hours and when you come back you should be able to see all the pictures taken by typing 'ls' into the terminal window or on the command line.

Now you need to put them all together into a video. There are two ways in which you can do this. Firstly, you could use the Pi to create a video file, instructions for which can be found here, but this takes a long time and can result in your Raspberry Pi crashing. Instead I copied the files from the Raspberry Pi SD card via ftp to my computer. You could also use a USB memory stick to copy them over. Then using Movie Maker I added all the images and set the duration time to 0.04 before saving it as a movie.

Ta da, your very own time lapse creation!

Getting Arty with Stop Frame Animation

The Raspberry Pi is a great, cheap way to get started with stop frame animation. Here is an example of a stop frame animation I made a few years ago, it is actually my first ever YouTube video!


There is a great app created for the Raspberry Pi to help you created stop frame animations called 'Pi-mation':



All the steps you need to follow to download and install Pi-Mation can be found here. It is really easy to use.

Have fun! Point me in the direction of any of your creations. :)

1 comment:

  1. Just for clarification, that time lapse video was not shot with the raspberry pi/raspberry pi camera correct?

    ReplyDelete