Iâ€™ve always wanted to try out making timelapses of my garden during the day and night, and only recently have I really had a go. I downloaded an intriguing app called TimeLapse for my iPod touch, and set about taking some images.
Due to the glare of my house lights, simply sitting my iPod on a window sill just wouldnâ€™t do. As soon as it started getting dark, the glare on the window really detracted from the evening outside the window. I did find that one could just tape the iPod touch to the window, but the idea of leaving something that valuable in plain sight was a bit no-no.
Then, I realised that I could use my Raspberry Pi to do the same job. Coupled with a ÂŁ5 720p logitech webcam bought from eBay, I set about creating my timelapse machine.
From all of the tools available out there, I found using fswebcam was the most simple way to create timelapses.
NOTE â€“ you may need to do some experimentation to get your camera to work with fswebcam. Most logitech webcams work with it, as they usually support the UVC standard. Look into how to get webcams working on the Pi if you have any issues getting an image out of fswebcam in the following steps.
First, we need to install fswebcam, which will let us capture the images.
sudo apt-get install fswebcam
To install fswebcam.
Also make a directory to store our timelapse pictures.
Then, with fswebcam installed, try running
to take a simple image from the camera. It will soon let you know if there are any errors.
Now, we will make a script to take a timelapse.
Insert the following text into the nano editor:
import datetime import os from time import sleep resolution = "720x480" delay = 10 while True: os.system("fswebcam -D 2 -r " + resolution + "/home/pi/pictures/%s.jpeg" %datetime.datetime.utcnow().strftime("%Y-%m-%d-%H:%M:%S")) sleep(delay)
Your webcamâ€™s light should light up and take a photo once every 10 seconds. You can adjust the resolution of your camera, and the delay time (I used 10 seconds) in the script above.
Finally, to get your script to run on startup, lets put it in crontab.
sudo crontab -e
Then, make a new line. Make sure that your new line is blank and does not start with a #. Then, enter the following:
@reboot python /home/pi/timelapse.py
You can now reboot your Pi using
sudo reboot and your webcam should now take a photo once every ten seconds and store it in the directory
Have fun with your new time lapse machine!Published 2016-09-06