Camera board project: time lapse video

Our friends at DesignSpark have produced a really beautiful time-lapse video with one of our new camera boards. It doesn’t start very beautifully, because it was filmed on a day whose start can best be described as “sodden”, but by afternoon the clouds parted and England started to look exceptionally green and pleasant. If you want to skip the rain, fast-forward to 1m46. (There’s a guest appearance from a double rainbow later on, too.)

You can find detailed instructions on how to make your own time-lapse video with your own camera board over at DesignSpark. Big thanks to Andrew Back for the vid and the tutorial!

31 comments

David Palmer avatar

This script uses the technique of taking a picture and then sleeping a fixed length of time. This can lead to unevenness if the CPU time for each loop is not constant. One alternative is to wait until, say, the time is evenly divisible by 10 seconds with something like

(This is adapted from something I did on a Mac, and hasn’t been tested or run on the Pi. You can test it by setting dt to 60 seconds and take a time lapse of an accurate clock: the second hand should be the same place in all the pictures.)

The tricks are:
date +%s — gives the time in seconds since beginning of 1970
expr ${dt} – \( ${now} % ${dt} \) — % is the remainder operator, so this gives the number of seconds until the remainder is zero again.

#! /usr/bin/env bash
cd `dirname $0`
dt=10

ROLL=$(cat /var/tlcam/series)
SAVEDIR=/var/tlcam/stills

for (( j = 0 ; j < 9999999 ; j ++ ))
do
now=`date +%s`
left=`expr ${dt} – \( ${now} % ${dt} \)`
sleep $left
filename=$ROLL-$(date -u +"%d%m%Y_%H%M-%S").jpg
/opt/vc/bin/raspistill -o $SAVEDIR/$filename
done

JamesH avatar

There is a timelapse mode in the example software which does something similar, but will use more power since it doesn’t turn the camera off between shots.

TAbbott avatar

Hi, thanks for the cool script.
I’m getting an error in this line, and I don’t understand expr well enough:

left=`expr ${dt} – \( ${now} % ${dt} \)`

Is this right, or is it missing a bracket somewhere?

brigo avatar

Wonderful – the four seasons in one day!

meltwater avatar

Yep sounds like English weather!

Martin avatar

Beautiful.

mrpi64 avatar

Sweet!

skitchy avatar

You caught a ‘moving’ rainbow at 2:38 – don’t think I’ve ever seen that on a time-lapse before :)

AndrewS avatar

And there’s a brief double-rainbow at 2:40 ! What can it mean? ;-)

I wonder if you could use object-tracking on the clouds to give a very rough estimate of relative wind-speeds?

liz avatar

Woah! So intense!

bgracia avatar

A double rainbow means a baby Leprechaun was born!

AndrewS avatar

P.S. I wonder if the rainbow was moving because somebody was trying to chase the Leprechaun? :-D

transfinite avatar

Wonderful! All it needs is a soundtrack – “Little Fluffy Clouds”

http://en.wikipedia.org/wiki/Little_Fluffy_Clouds

Tom avatar

Very relaxing. The rainbow was a pleasant surprise.

Hiro avatar

Can you tell me how much space those 5515 files took up on the SD card? I’m just wondering how long it would be possible to run for if i was mains powered.

JBeale avatar

If you want a very long runtime you can: use a longer interval between shots, store a smaller image (fewer pixels and/or higher JPEG compression), use a larger SD card (up to 64 GB?) or use external USB storage device (flash drive or HDD).

JBeale avatar

…or use network link to upload each frame to cloud storage site, and run forever :-)

AndrewS avatar

*groan*
I’ve just realised that you were suggesting using cloud storage, to store pictures of clouds… ;-)

Andrew Back avatar

The files took up just over 9GB, but as has been pointed out you could capture images at, or closer to, the final video resolution.

Lots of fun to be had experimenting with all the various options!

Hiro avatar

Thanks for that, i was hoping to get a shot roughly every 5 seconds for a 36 hour period without the need for an external storage device.
If my maths is correct, at the resolution you have used that would work out at very roughly 45GB so it would fit on a 64GB SD card easily.

Terry Rowe avatar

I have been testing speeds by removing the sleep line I can get 1 picture every 6 second tried 32Gb SD and 64Gb USB Pen both
give the same results LED is on all the time. Sleep 2 =7second 3=9 seond delay that is on a old 256Mb PI
Hope this is of info

RIch avatar

There’s a -t option to raspistill that specifies how long to wait before taking the image. It defaults to 5s. If you use the -t option to reduce that you would be able to take images much faster.

Phil Loarie avatar

While this is a pretty good stab at time-lapse using a raspberry pi, I would like to see if it could be smoother using a more optimal shutter time and interval. Some of the best time-lapse work I’ve seen has come from Adonis Pulatus found here https://vimeo.com/adonispulatus.

Adonis has found that using a 1 second interval and dragging the shutter to 1/2 second is the best for most daylight situations. The key is ‘dragging the shutter’ as this will smooth out things like birds, planes, or people passing in front of the lens.

In many cases a neutral density filter will be needed to compensate for the ‘over’ exposure of the long shutter time. It would be handy too to understand what exposure controls are available on this camera.

Check out his work at the above web site to see what I mean.

Hope this helps,
-Phil Loarie

Andy avatar

How fast can this thing take pictures/frames? I was wondering if I could use the time-lapse command and just set it to a very low delay (100fps) to capture High-speed video. Of course, then I would have a bunch of pictures that I would have to sort out. So I guess it would be better to have some way of doing this with video. I’ll look around to see if there would be a good/better way to do this.
Andy

Eduardo Brito avatar

If only there was a case to protect the camera and a better way to connect to the board (without a dangling flat cable) it would be perfect, really…!

A small cable that could be soldered to the board and put inside a standard raspberry pi box and the camera in a protected box, like a real cam, with a removable cable that would connect to the raspberry pi case…

JamesH avatar

Feel free to design one! That’s what the community is for!

David avatar

I’ve fitted my camera inside my clear case. It was a bit fuzzy, so I drilled a hole in the case to fit the lens through and then bolted the board to the case with M2 screws and nuts. This works great and the cable folds back and forth on itself nicely.

Tony avatar

I got my camera yesterday.
Glued a small strip of plastic to a 8pin header that fits on the gpio. blutaked the camera to the plastic,
Reasonably secure.

Popov avatar

First test after receive my camera module.

http://www.youtube.com/watch?v=2v40zUSi7zI

Paul df avatar

Is there a way to take stills “NOW” ie without the delay of 5 or 6 seconds. I want to synchronise several cameras so that they all take a picture at exactly the same moment from many different angles?

Mo Ritz avatar

Hi,
here my first try

http://www.youtube.com/watch?v=Wl7rxBGnrVI&hd=1

Time laps:
Rapberry Pi Camera 27.05.2013
4,61GB – 3.780 Pictures
Resolution: 1920×1080

Comments are closed