Using the Python script and setting up within Raspbian
Setting up Raspbian to control the camera is pretty easy.
Using the raspiLapseCam.py script I opted for an automated startup when the device is booted up. That way there’s no need for any SSH commands to be issued and it is simply a case of flicking a switch.
Connect to your Raspberry Pi and download the script
To do this log into your box using Terminal on the Pi or log in remotely using Terminal or Putty:
(where XX.XX.XX.XX is the IP address of your Raspberry Pi)
First of all, we’ll need to get the Python script to control the camera. We’ll copy this into the /home directory as it’s easy to find and a good starting point, but copy to the place the suits you and your build. This is also a good time to create a folder to write images to, and change the permissions to make it writeable. This setup should work as the script writes to the folder /home/timelapse/ as a default; although you can change this if you wish. Just make sure you update the pathway within the Python script itself.
Download the raspiLapseCam.py file from the repo:
cd /home mkdir timelapse chmod 777 timelapse sudo wget https://bitbucket.org/fotosyn/fotosynlabs/raw/9304ee9262638efebdd66d543b844a3075401782/RaspiLapseCam/raspiLapseCam.py
To check everything is installed, simply type
Create a cron job for launching the Python script on boot
The script should be visible in the directory. Next, we can automate the startup so the camera activates each time it is powered up. To do we need to add a cron job. This will mean on each boot of the Raspberry Pi the script will activate and begin capturing images.
To create a cron job for launching the Python script on boot issue the command:
sudo crontab -e
At the bottom of the script insert
@reboot python /home/raspiLapseCam.py &
Of course change /home to the correct pathway where you have the script.
Save this script (CTRL + X) and Y. Once you have done this, check that it has been created successfully with:
sudo crontab -l
Rebooting the device will mean this script executes. On testing I found that it needs a full shutdown before this will reliably work each time. So to reuse the device you’ll need to log in, and perform a shutdown with:
sudo shutdown "now"
Once you have shut down correctly, and allowed the Pi to completely power down, you can simply switch on the Raspberry Pi’s battery power supply and the script will launch normally when the device boots up. This is especially useful if you’re deploying the timelapse camera for an extended period outside the range of network connections.
If you need any more information on setting up cron on the Pi check out this guide to running a Python script on boot.
Using the camera
raspiLapseCam.py will create a folder for each timelapse session. You can change where this saves within the .py file but as a default this is in the same location in a subfolder. This way you can easily grab all the images from a session and then sequence them into an animation or video clip.
The effects and adjustments are all still available as it uses raspistill to capture images. Simply edit these parameters within the script if you want to make changes.
Next thing is to use it! There are no rules but as a suggestion best times are at dawn and dusk when the light is at its most changeable and dramatic. Many photographers refer to this time as the ‘Golden Hour’
Shooting overnight proved a bit more tricky with everything in darkness. I guess there would be a trade-off between the required increase in exposure time and battery life. Under normal conditions I was getting around 7.5 hours uptime using standard Durcaell AA batteries and a Raspberry Pi Model B.
Post capture and editing
Putting the images together is easy. QuickTime allows you to join a sequence of images together and save out as a video clip. There are other tools out there like Premier and After Effects too. If you find your images are slightly off kilter I recommend running everything through a Photoshop action to remove the offset angle.
You can also combine still frames to make a movie clips using a command line entry like:
cd /<your_timelapse_folder> ls *.jpg > list.txt sudo apt-get install mencoder mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4:aspect=16/9:vbitrate=8000000 -vf scale=1920:1080 -o timelapse.avi -mf type=jpeg:fps=24 mf://@list.txt