There are many ways to create time lapse photography these days. The following is just one way we are using Axis 207MW cameras on campus to create interesting videos.
First we connect the camera to our ethernet or wireless network and mount it somewhere that it will not be likely to move. Once we have verified that the camera is up and running and reachable across the network, we setup a script that will start capturing the images.
To view the latest image from an axis camera, you can go to a URL similar to this one:
http://138.236.0.1/axis-cgi/jpg/image.cgi?resolution=1280×1024
Viewing that in a browser, you can see exactly what the camera could see at that moment.
Next we need to have a system grab an image from that URL on a set schedule. To do that we created a cron job which calls curl to grab an image from the camera and save it as a time stamped jpg file.
For example, you can tell curl to grab an image and save it to a file like so:
curl -s -o image.jpg
Here is an example script similar to the one we use:
#!/bin/bash
d1=`date +"%y%m%d-%H%M%S"`
d2=`date +"%y%m%d"`
if [ -e "/var/www/html/cam/$d2" ]; then
/usr/bin/curl --connect-timeout 45 -s -o /var/www/html/cam/$d2/$d1.jpg http://138.236.0.1/axis-cgi/jpg/image.cgi?resolution=1280x1024
else
mkdir "/var/www/html/cam/$d2"
/usr/bin/curl --connect-timeout 45 -s -o /var/www/html/cam/$d2/$d1.jpg http://138.236.0.1/axis-cgi/jpg/image.cgi?resolution=1280x1024
fi
cd /var/www/html/cam/$d2/
rm ../mostcurrent.jpg
ln -s /var/www/html/cam/$d2/`ls -t| head -1` ../mostcurrent.jpg
This script will create a new folder each day and store that days images in it. When a new day comes around, a new folder is created with the new days images. That way if we leave it running for a few months at a time, we don’t end up with a folder with thousands of files in it. This script also creates a link to mostcurrent.jpg so we can easily check out the latest image from the camera.
Next we tell our computer to run this script every minute by placing the following in /etc/crontab where cam-capture is the name of the script above:
* * * * * root /usr/local/bin/cam-capture
Let that run for a few hours and you should have a nice batch of images for the next step. To put all of the images together into a easy to watch movie, I have been using Quicktime. On my Apple Laptop I start Quicktime and from the File menu choose “Open Image Sequence…” A dialog box comes up and in there I choose the first image in the sequence. Usually Quicktime will get the ordering correct and when it is done you can play your time lapse video.
If you want to share the video with others just use Quicktime to export it to an iPod video or other MPEG4/H.264 video format and you are all set.
If you would like to take a look at some of the videos I have created lately, just click on one of these links:
Leave a Reply