4.6: Control a camera

Using the gPhoto2 tool and a usb-connected digital camera, you can automatically take pictures using your Pi to create, e.g., a time lapse video. The stuff described below achieves something similar to what can be done using Motion (check the section on Motion here) but where Motion is targeted to creating security cameras using webcams, gPhoto2 is geared towards controlling digital cameras.

gPhoto2

gPhoto is a tool that can control a usb-connected camera. Check here for a list of compatible cameras. Let's install using the familiar: sudo apt-get install gphoto2. Connect your camera using the usb-cable, turn it on, and check if it is connected:

    gphoto2 --list-config

This will give you a list of supported settings and actions. You can figure out how to use those settings using gphoto2 --get-config {name}. For example, if --list-config lists the setting /main/settings/iso then you can get a list of possible values for this setting using:

    gphoto2 --get-config iso

Next, you can set either of those values using the shown choice numbers:

    photo2 --set-config iso=7

(source: 1)

Taking pictures

If the camera is set, take a picture and download it to your Pi:

    gphoto2 --capture-image-and-download --filename "%Y%m%d%H%M%S.jpg"

Create timelapse

    gphoto2 -I 10 -F 600 --capture-image-and-download --filename "%Y%m%d%H%M%S.jpg"

This sets the camera to take a picture every 10 seconds, and take 600 pictures in total. For me, this command consistently got stuck at the 10th picture, with the camera indicating it was writing a picture to the SD-card but never finishing the operation. This unfortunately forced me to set a cron job to take pictures.

After taking some pictures, the images should be combined into a video file. The source mentioned earlier also describes how to do that, using MEncoder.

results matching ""

    No results matching ""