scheck media – Fotografie, Webdesign und Programmierung

You Are Viewing

A Blog Post

control your DSLR with a Raspberry PI

The semester vacation is over and at the end I made first steps with the libgphoto2. It is my goal for quite a while to control my DSLR remotely and without any cable connections. The solutions which you can buy have no possibility to change the camera settings. That’s the reason why I have bought a Raspberry PI Model B and a Wi-Fi nano stick. Therefore was enough performance available to handle the image data.

In the past I have tried my luck with Python and node.js but the project failed because of problems with the wrapper-libraries. Thus I wrote the application in C++ for the Raspberry. This gives me more control to find a problem because I use libgphoto2 directly. The software is a backend and provides a small REST functionality. It is “small” because at the moment only “GET” is implemented. Anyway you can send a HTTP command to the Raspberry, that will be executed and you get a JSON or XML file as response.  For example the trigger-command sends you the image data as base64 string in the response file when the command was successfully executed.With this kind of process it is platform independent. Only the streaming functionality of the live view is based on the client/server principle. If the application receives a live view command you get the socket connection data as response. The socket sends the data as soon as someone is connected. The process of the stream is simple. The first 4 bytes (big endian) determine the size of the coming image. You can see on the example client on github how it works. À propos github, you can find the project under the following url There you will also find a readme file with an overview of the implemented features.

I have recorded a movie because picture speaks louder than words.

The following functions are to be implemented in the future:
- time lapse
- continuous shooting
- bulb mode

I have tested the application with a Nikon D90 and at the moment it isn’t a stable software. Actually  I’m just  beginning but for this the application works well.

If I have caught your interest, feel free to work at the project!

  • zoel on %A %B %e%q, %Y

    Hi, I want to know about it, in raspbian wheezy we must install webserver like LAMP and we will use webserver ip to remote it? thanx and sorry for my english ;-)

    • Tobias Scheck on %A %B %e%q, %Y

      Hey zoel, I hope I understand correctly. All what you have to do is starting the application. Inside the application is an own webs- erver (libmicrohttp) which answer to your requests. You can setup the listen-port in the settings.xml. For example, if your port is 8888 you have access to the api with http://device-ip:8888/. A valid list with all commands can you find in the available git repository.

  • Yannik on %A %B %e%q, %Y

    Hi, während des Compilens tritt bei mir immer dieser Fehler auf:
    In file included from Api.h:12:0,
    from Server.h:14,
    from main.cpp:13:
    CameraController.h:59:29: error: ISO C++ forbids initialization of member ‘_save_images’ [-fpermissive]
    CameraController.h:59:29: error: making ‘_save_images’ static [-fpermissive]
    CameraController.h:59:29: error: ISO C++ forbids in-class initialization of non-const static member ‘_save_images’
    make: *** [main.o] Fehler 1

    Was mache ich falsch?

    • Tobias Scheck on %A %B %e%q, %Y

      Hi Yannik,

      der Fehler lag bei mir. Ich hatte die ganze Zeit unter XCode auf dem Mac gearbeitet und die Updates ins git Repository geschoben. Leider hatte ich das nicht weiter überprüft, da es auf dem Mac ohne Probleme lief. Die Fehler habe ich eben auf dem Raspberry behoben und das kompilieren ging dann auch. Die Änderungen sind nun im Repository online. Beachte, dass nun noch die libfreeimage-dev zum kompilieren benötigt wird (thumbnail erstellung). Bei dem webif gibt es gerade noch ein Speicherzugriffsfehler…

      • Yannik on %A %B %e%q, %Y

        Ok, danke. Hatte es schon auf dem Mac compiled, da lief es auch, wollte es aber nun doch lieber auf dem Raspberry haben.

  • Olarn U. on %A %B %e%q, %Y

    Your project is so cool!!! I want to try it with my D700 but I’m not familier with c++. Would you please provide instructions to make it works? I have Mac and Xcode if needs, but it should be great if it can do everything on RPi.


  • Andre on %A %B %e%q, %Y

    Hey Tobias, ich würde gerne deine Api testen und mir einen Photobooth für meine Hochzeit bauen. Mit gphoto2 kann ich schonmal Bilder machen und speichern auf dem Raspberry mit meiner Canon, nun wollte ich deine Api testen und mir ein Webinterface dafür bauen. Nur leider weiß ich nicht, wie ich deine Api compile. Kannst du mir sagen, wie das geht?


    • Tobias Scheck on %A %B %e%q, %Y

      Hey André, entschuldige die späte Antwort. Ich war jetzt für 5 Monate auf Malta für ein Auslandspraktikum und kam nicht so richtig dazu mich um meinen Blog und die Kommentare zu kümmern.

      An sich musst du nur den Befehl “make” ausführen und das hinterlegt Makefile macht den Rest für dich. Als Resultat sollte dann eine Datei erstellt werden “CameraControlerApi”. Diese Datei ist dann auf dem Raspberry ausführbar.

      Um den Source erfolgreich zu kompilieren benötigst du noch die Bibliotheken: libboost-dev, libgphoto2, libmicrohttpd-dev, libexif-dev.

      Sollte es Probleme geben, einfach ein Zeichen geben. Dann muss ich noch mal schauen. Ich habe den Raspberry PI gerade nicht am laufen um genau zu schauen.

      Viel erfolg!

  • Jose Maria Camara on %A %B %e%q, %Y

    Hi, it’s really great your project and when I was lloking this video I started to thinking to try to do that. I have a nikon d90 too. Now I want to start to buy the hardware. Raspberry pi and wireless usb I ordered yet but I have a doubt with the camera cable, could you send me where I can buy that cable? I suppose that the cable is gps port (d90) to usb raspberry, is it OK, Thanks so much and well done ¡¡¡

    • Tobias Scheck on %A %B %e%q, %Y

      Hey Jose, actually you just need a USB to Mini-USB cable because you connect your camera over USB to the Raspberry PI.

      • Jose Maria Camara on %A %B %e%q, %Y

        Thank you so much, in few days Ill have the hardware and I will to try the software ¡¡ Ill tell you my advances . Thank you so much Tobias ¡¡

Leave a Reply

“The higher the technology, the higher the need for contact.”
John Naisbitt

do not hesitate

Contact me

Contact Info