Tuesday, July 9, 2013

Remote Camera Control

Gphoto2 is a library/command line tool that can be used to remotely control a digital camera (DSLR) connected to via usb. Under Ubuntu gphoto can be installed from the repository:
sudo apt-get install gphoto2

The following are a few of the available commands to get started:

1. Shoot camera and download image as test.jpg
gphoto2  --capture-image-and-download --filename=test.jpg

2. Download all files on the camera to PC
gphoto2 --get-all-files

3. Show the camera configuration options
gphoto2 --list-config

Some examples from running the above on a Canon EOS 10D:
/main/imgsettings/iso
/main/imgsettings/whitebalance
/main/capturesettings/aperture
/main/capturesettings/shutterspeed


4. Change camera configuration
gphoto2 --set-config /main/capturesettings/shutterspeed=1/8

By combining the above commands in simple scripts we can do stuff like HDR imaging and time lapse:

Shoot three exposures using gphoto and convert to HDR using luminance:
for i in 0.5 1 2; do  gphoto2 --set-config /main/capturesettings/shutterspeed=$i --capture-image-and-download --filename=$i.jpg; done;
 luminance-hdr-cli  -s hdr.exr *jpg

Take a picture every 3 days:
for i in {1..10}; do  gphoto2--capture-image-and-download --filename=$(date -I).jpg; sleep 3d; done;