Raspberry Pi and Gphoto

My plan to use Raspberry Pi for controlling a camera was set back a bit. RasPi seems to have some kind of problems with its USB. Whenever I use Gphoto to take a photo, the connection crashes somehow and everything after it fails. This seems to be a known problem and someone has already solved (or circumvented) it. Even something similar to what I planned has already been made by this guy: http://www.rezamahmood.net/raspberrypi-gphoto-web-api/. My goal is not a web app, but a command line python app.

My setup will include a RasPi and Canon EOS 1100D. I'm going to use it for astrophotography. My great plan is to have a remote controllable system, so I can sit inside myself and have the camera shooting outside. Or most likely, I'll be next to the camera mount looking through a telescope... Anyways I need a system I can use to extend my cameras limits. With the camera itself I can take max 10 sequential photos automatically, exposure times are limited to max 30 seconds and my SD card is only 16 GB. Ok, that will not fill up too quickly but since I'm going to code something, better to take care of that as well.

In addition to arbitrary exposure times and number of sequential photos, the program should be able to change the ISO in use. That's an easy task with Gphoto. It also will move all the photos to my NAS instantly after taking them (so I can take more than 16GB on one session :) ). While moving the photos to a network drive it renames them according to the celestial object I'm shooting, timestamps them and puts them into their own directory.

First working version

The first working version of the script is here. It will do everything described above, but barely. You need to have Gphoto installed on your RasPi (or whatever you're using) to make this work. You also need to download and compile usbreset.c. In case you need step by step instructions for setting up RasPi, here they are:

$ sudo apt-get install gphoto gcc
$ gcc usbreset.c -o usbreset

The code is licensed (if a short piece of code like this even can be licesed) under GPL.

Download the file and run it
$ kamera.py -i <iso> -e <exposure time> -n <number of photos> -t <name of object in the photo>

It will take the photos and move them in to a directory specified in first lines of the code.

Next I'll probably rewrite the whole thing to look more like a program and not a script. That way it will be extendable for other than command line usage. Web app such as here or maybe something to use from Android.
Mikko Laine,
Jan 6, 2013, 4:44 AM
Mikko Laine,
Jan 6, 2013, 5:19 AM