My D40 auto-bracketing kit.

23rd
Aug

HDR photography with Raspberry Pi and gPhoto2

This entry was posted in How To and tagged , , , on by .

44 Flares Twitter 13 Facebook 13 Google+ 9 Pin It Share 1 44 Flares ×

UPDATE: See my new blog post where I rewrote the code in Perl and added a trigger for the Pi.

I bought my Nikon D40 in 2006. The D40 is my first and only DSLR camera and I’ve loved using it every day that I’ve had it. At the time, it was Nikon’s entry-level DSLR and it suited my budget and photography skills. Over the last 6 years that I’ve owned the device my photography skills have improved but not my budget1. I’d had to make do with the limitations of the D40 — 6 megapixel DX sensor, 200-3200 ISO range, no auto-bracketing — but the lack of auto-bracketing has been the most limiting.

I love making high dynamic range (HDR)2 photographs. I love how my photographs come alive with the expanded range offered by HDR. HDR photography involves taking multiple photographs at varying exposure levels and combining the photos into a single final image. HDR photography requires a good tripod and a camera that can shoot bracketed photos. Having a camera body with auto-bracketing makes this easy. On the D40 I can manually adjust the exposure values (EV) between each capture but I risk moving the camera. A slight movement can make aligning the images much harder.

I’ve researched various solutions for my problem. I used a Mac app, Sofortbild, to tether my D40 to my MacBook via USB. Sofortbild provides complete remote control of a Nikon DSLR camera — like shutter speed, aperture, exposure, white balance, iso, image format — and automatically transfers captures images to the Mac hard drive. It can also auto import images into iPhoto, Aperture or Adobe Lightroom. However I was interested in it’s use for HDR photography.

Perform bracketing with an arbitrary number of different exposure values by defining minimum and maximum shutter speed and step. After bracketing high dynamic range images can automatically be calculated including auto image alignment and saved in all major high dynamic range image file formats. Filenames will get same index including incrementing suffix for easier workflows with external high dynamic range applications.

Sofortbild is easy to use and fully functional but … the setup wasn’t only practical in a studio or controlled set. I just didn’t see myself lugging a laptop, tripod, camera and lenses around. With a MacBook Air, maybe. A 7 lb MacBook. No. I wanted something lighter.

I started researching options to control the brackets using my iPhone. Searching the web I found a project called DSLR.bot. The creator wrote an iPhone/iPad (iOS) app that could trigger an IR LED to send the correct binary sequence to trigger the IR on the Nikon. The creator sells a pre-built IR remote but I built one myself. However, he author of the app limited the fastest shutter speed to 3/10 second. This was too slow for my daylight HDR. Most of my test shots were completely blown out in the highlights.

When the Raspberry Pi single board computer was announced I could immediately see the usefulness of such a small. I ordered one and four months later I could starting working on my first project. I planned to used the Raspberry Pi to control my Nikon via USB and capture bracketed images.

After much research and trial and error I think I have a working solution.

Apple iPhone 4 (3.85mm, f/2.8, 1/120 sec, ISO80)
My D40 auto-bracketing kit.

What you’ll need

Installing Raspbian “wheezy” Linux on an SD card

I used an OS X user account that has administrator privileges to install Raspbian “wheezy” Linux onto a 4GB SD card. The card was mounted on my OS X 10.8 iMac via a Moshi card reader. I followed the instruction on the Wiki with some small tweaks. A little trial and error and I had a working RPi.

My disk showed up as follows:

/dev/disk4s1   3.7Gi  722Mi  3.0Gi    20%         0        0  100%   /Volumes/NIKON D80

The Wiki did not make it clear that I needed issue the commands from an account with system administrator privileges and that the diskutil commands must be executed using sudo. I was frustrated running these commands until I understood that little detail.

It is necessary to unmount the partition so that you will be allowed to overwrite the disk:

iMac-2:~ khurt$ sudo diskutil unmount /dev/disk4s1

Using the device name of the partition, in my case /dev/disk4s1, I got the raw device name for the entire disk, by omitting the final “s1″ and replacing “disk” with “rdisk”. So my raw device name was /dev/rdisk4.

In the terminal I wrote the image to the card with this command, using the raw disk device name from above.

iMac-2:~ khurt$ sudo dd bs=1m if=~/Downloads/2012-07-15-wheezy-raspbian.img of=/dev/rdisk4

Once complete, I unmounted the SD card and inserted into the slot on my Raspberry Pi. I hooked up the Raspberry Pi to my home network via my AirPort Express via an Ethernet cable. My RPi was powered from a USB charger I picked up from Radio Shack. My plan was to get the device controlling my camera with a script and the power the device from the Mophie Juice Pack Powerstation.

gPhoto2

Since my plan was to use the RPi to control my Nikon D40 for exposure bracketing of images for use in HDR photography I needed software that could send Picture Transfer Protocols (PTP) commands to my Nikon. My research led me to a library, gPhoto2, written for this purpose.

gPhoto2 is a free, redistributable, ready to use set of digital camera software applications for Unix-like systems … gPhoto2 runs on a large range of UNIX-like operating system, including Linux, FreeBSD, NetBSD, MacOS X, etc.

Fortunately someone had ported gPhoto2 to Raspian “wheezy”. My first order of business was to download and install the library.

I used the following command:

pi@raspberrypi ~ $ sudo apt-get install gphoto2

The following new packaged were installed (successfully):
    gphoto2 libcdk5 libexif12 libgd2-xpm libgphoto2-2 libgphoto2-l10n libgphoto2-port0 libltdl7

Once gPhoto2 was installed I tested to make sure things worked. I plugged my Nikon D40 into the RPi via a mini-USB to USB cable and ran the following command:

pi@raspberrypi ~ $ gphoto2 --auto-detect
Model                          Port                                            
----------------------------------------------------------
Nikon DSC D40 (PTP mode)       usb:001,006     

Capturing images

I tested out a few of the commands to set ISO, exposure value (EV) and capture images. However, I needed a way to issue commands to capture five successive images at different exposure values without and I had no way to trigger. After much trial and error I finally figured out the right combination of gPhoto2 and bash script commands to control the D40 when the camera is turned on.

#this command will set the exposure compensation vale to zero
--set-config /main/capturesettings/exposurecompensation 0

#this commands sets the camera to save images to the SD card
--set-config /main/settings/capturetarget=1

#this command will capture an image
—capture-image

#this command will set the ISO on the D40 to 200
--set-config /main/imgsettings/iso=0

I wanted a script that would wait until the camera was running, take 5 photos, then go back to waiting. I looked for ways to trigger the script when the camera shutter button was presses but I could not find a way to do so. The best I could do was wait until the camera was turned on then capture the images and exit.

I used the following code to keep the script in a wait state until the camera is turned on.

# Wait for camera to be turned on
# by checking USB
DEVICE=$(gphoto2 --auto-detect | grep usb | cut -b 36-42 | sed 's/,///')
while [ -z ${DEVICE} ]
    do
    sleep 1
    DEVICE=$(gphoto2 --auto-detect | grep usb | cut -b 36-42 | sed 's/,///')
done

Once the RPi has detected the camera has been turned on I could initialize the camera and capture images.

echo "Camera has been turned on"
# Configure camera for gphoto2 access and later capture:
# NOTE: I'm not sure this is needed.

gphoto2 --set-config-value /main/capturesettings/exposurecompensation=0 
--capture-image-and-download 
--filename junk.jpg 
--force-overwrite

rm -f junk.jpg

# Assumes camera is in Aperture Priority mode
# Sets ISO to 200 and capture target to SD card
# see config.txt for other options

# Capture 5 images at EV 0,-2,-4,2,4
echo "Capturing five images"
gphoto2 --set-config /main/imgsettings/iso=0 
    --set-config /main/settings/capturetarget=1 
    --set-config-value /main/capturesettings/exposurecompensation=0 
    --capture-image 
    --set-config-value /main/capturesettings/exposurecompensation=-2000 
    --capture-image 
    --set-config-value /main/capturesettings/exposurecompensation=-4000 
    --capture-image 
    --set-config-value /main/capturesettings/exposurecompensation=2000 
    --capture-image 
    --set-config-value /main/capturesettings/exposurecompensation=4000 
    --capture-image

The script is executed from the pi user crontab every minutes. The challenge is that I wanted the script to run, capture 5 images, and stop until the user was read to capture another set. Remember, I had no way to trigger the script with a camera event. But I also wanted to make sure that the script would launch multiple copies of itself with in the time it took to capture the images. I decided to set a status flag using a file to indicate to the script when it was already running. I used the useful bits of a script written by Jonathan Franzone

# ------------------------------------------------------------
# Setup Environment
# ------------------------------------------------------------

PDIR=${0%`basename $0`}
LCK_FILE=`basename $0`.lck

# ------------------------------------------------------------
# Am I Running
# ------------------------------------------------------------

if [ -f "${LCK_FILE}" ]; then

    # The file exists so read the PID
    # to see if it is still running
    MYPID=`head -n 1 "${LCK_FILE}"`

    TEST_RUNNING=`ps -p ${MYPID} | grep ${MYPID}`

    if [ -z "${TEST_RUNNING}" ]; then
        # The process is not running
        # Echo current PID into lock file
        echo "Not running"
        echo $$ > "${LCK_FILE}"
    else
        echo "`basename $0` is already running [${MYPID}]"
        exit 0
    fi
else
    echo "Not running"
    echo $$ > "${LCK_FILE}"
fi

The somewhere in the script after I’ve captured my images I could put this.

# ------------------------------------------------------------
# Cleanup
# ------------------------------------------------------------

rm -f "${LCK_FILE}"

Putting it all together

Putting the thing together3 I have a complete script for capturing five images seconds after the D40 is turned on.

#!/bin/bash

#  hdr.sh
#
#
#  Created by Khürt L. Williams on 8/21/12.
#  Description: Script for executing gPhoto2 commands to record 5 bracketed images
#  Portions are from a script written by Jonathan Franzone: http://www.franzone.com/2007/09/23/how-can-i-tell-if-my-bash-script-is-already-running/

# ------------------------------------------------------------
# Setup Environment
# ------------------------------------------------------------

PDIR=${0%`basename $0`}
LCK_FILE=`basename $0`.lck

# ------------------------------------------------------------
# Am I Running
# ------------------------------------------------------------

if [ -f "${LCK_FILE}" ]; then

    # The file exists so read the PID
    # to see if it is still running
    MYPID=`head -n 1 "${LCK_FILE}"`

    TEST_RUNNING=`ps -p ${MYPID} | grep ${MYPID}`

    if [ -z "${TEST_RUNNING}" ]; then
        # The process is not running
        # Echo current PID into lock file
        echo "Not running"
        echo $$ > "${LCK_FILE}"
    else
        echo "`basename $0` is already running [${MYPID}]"
        exit 0
    fi
else
    echo "Not running"
    echo $$ > "${LCK_FILE}"
fi


# ------------------------------------------------------------
# Image capture
# ------------------------------------------------------------

# Wait for camera to be turned on
# by checking USB
DEVICE=$(gphoto2 --auto-detect | grep usb | cut -b 36-42 | sed 's/,///')
while [ -z ${DEVICE} ]
    do
    sleep 1
    DEVICE=$(gphoto2 --auto-detect | grep usb | cut -b 36-42 | sed 's/,///')
done

echo "Camera has been turned on"
# Configure camera for gphoto2 access and later capture:
# NOTE: I'm not sure this is needed.

gphoto2 --set-config-value /main/capturesettings/exposurecompensation=0 
--capture-image-and-download 
--filename junk.jpg 
--force-overwrite

rm -f junk.jpg

# Assumes camera is in Aperture Priority mode
# Sets ISO to 200 and capture target to SD card
# see config.txt for other options

# Capture 5 images at EV 0,-2,-4,2,4
echo "Capturing five images"
gphoto2 --set-config /main/imgsettings/iso=0 
    --set-config /main/settings/capturetarget=1 
    --set-config-value /main/capturesettings/exposurecompensation=0 
    --capture-image 
    --set-config-value /main/capturesettings/exposurecompensation=-2000 
    --capture-image 
    --set-config-value /main/capturesettings/exposurecompensation=-4000 
    --capture-image 
    --set-config-value /main/capturesettings/exposurecompensation=2000 
    --capture-image 
    --set-config-value /main/capturesettings/exposurecompensation=4000 
    --capture-image

# Wait for camera to be turned off
# by checking the USB
DEVICE=$(gphoto2 --auto-detect | grep usb | cut -b 36-42 | sed 's/,///')
while [ ${DEVICE} ]
    do
    echo "Turn off the camera"
    sleep 5
    DEVICE=$(gphoto2 --auto-detect | grep usb | cut -b 36-42 | sed 's/,///')
done

# ------------------------------------------------------------
# Cleanup
# ------------------------------------------------------------

rm -f "${LCK_FILE}"

# ------------------------------------------------------------
# Done
# ------------------------------------------------------------

exit 0

Next steps

My solution is useful but I’m not happy about the script and the way the camera is operated. Ideally, I would like a way to trigger the captures either via detecting the depression of the shutter button on the D40 or via a push button connected to the GPIO on the Raspberry Pi. The script could then be a simple loop that waits for a trigger event, captures five images, and then goes back to waiting.

I would also like to encase the Raspberry Pi and cables inside a compact exposure. Currently a rubber band holds the package together. I’ve ordered the Pi Box from Adafruit that should work nicely. Adafruit has a wide assortment of products designed for the Raspberry Pi.

You can see some of the images I captured with this solution on my photo blog.


  1. I’ve budgeted for lens – Nikkor 35mm f/1.8 and Nikkor 50mm f/1.8 – and a studio lighting kit – AlienBees 800 – but not a new body. 

  2. I use Adobe Lightroom plug-ins Photomatix Pro and HDR Efex Pro

  3. You can download the script from my public Dropbox folder. 

44 Flares Twitter 13 Facebook 13 Google+ 9 Pin It Share 1 44 Flares ×
This entry was posted in How To and tagged , , , on by .

About Khürt Williams

I am a husband, a father, a certified information system security professional, web developer, blogger and photographer who lives and works in the Princeton area. I am active in the Princeton area's social media community and currently serve as President to the Princeton Macintosh Users Group. I am passionate about funding research to find a cure for Type 1 diabetes. You can sometimes find me sitting with my iPad drinking coffee in one of Princeton's cafés.

76 thoughts on “HDR photography with Raspberry Pi and gPhoto2

  1. Pingback: HDR Photography with a Raspberry Pi - Island in the Net

  2. Khürt Williams

    I’m almost ready with an update to the project. I’m rewriting the script in Perl and I think I may have found a way to deal with the USB reset issue and also trigger the capture using the shutter release. The rewrite is based on suggestion from a number of the comments.

    Reply
    1. eriohoErio

      Yeap, I just read some solution on usbreset. But for that there are 2 disadvantages:

      1) using the usbreset can make it to be able to run the second command for sure, but the lag time to re-trigger the shutter is rather to long in some case. I use a for loop to reset usb after a shutter trigger, it takes a bit time.

      2) about the limitation on using usbreset is, we have to specify the bus and port number (e.g. /dev/bus/usb/001/00X), and the variable “X” will add 1 for each time we plug and unplug, hard to hard-code it in my shell script. That would be nice if usbreset would run based on the device name (human readable), rather then an incremental number.

      Reply
  3. eriohoErio

    Hi Khürt,

    Really cool on your guide and I try it on my D3s. I use your code but failed to capture more than one shot. Yes, it can capture one shot but no another.

    After taking the junk shot, it is OK, but when it try to take the “real” shot, it will prompt:

    *** Error *** PTP I/O error

    *** Error *** An error occurred in the io-library (‘Unspecified error’): No error description available

    After that, only a few commands can be done (e.g. –auto-detect) but no longer can take any shot.

    It resume normal when I switch the camera on and off, but can only take one shot too.

    Do you experienced it?

    Reply
    1. Khürt Post author

      Sometimes gPhoto is unable to reset the USB port on the Raspberry Pi. I’ve found that the latest built of Wheezy and gPhoto2 is more stable. I’ve also started using a utility to reset the USB port before starting a capture series. I’m working on an update to the script that I think will address these issues.

      Reply
  4. nobody

    Thank you for this great idea! Based on the suggestion about the wait-event parameter I played a little round and found a solution with capture-tethered and the hook scripts. As a result I take a picture with the camera and the raspberry pi takes the other 4 pictures afterwards. For anyone who is interested, I used the above setup and modified following scripts: /etc/rc.local added the line /usr/local/bin/HDR.sh &

    The file /usr/local/bin/HDR.sh:

    !/bin/sh

    loop forever

    cd /tmp while [ true ] do

    Wait for camera to be turned on

    by checking USB

    DEVICE=$(gphoto2 –auto-detect | grep usb | cut -b 36-42 | sed ‘s/,/\//’) while [ -z ${DEVICE} ] do sleep 1 DEVICE=$(gphoto2 –auto-detect | grep usb | cut -b 36-42 | sed ‘s/,/\//’) done

    loop for all photos to be taken until camera is switched off or so

    until [ $? -ne 0 ] do

    wait for the first photo

    gphoto2 –capture-tethered –hook-script /usr/local/bin/hook.sh

    do the other photos

    gphoto2 –set-config capturetarget=1 \ –set-config-value /main/capturesettings/exposurecompensation=-2000 \ –capture-image \ –set-config-value /main/capturesettings/exposurecompensation=-4000 \ –capture-image \ –set-config-value /main/capturesettings/exposurecompensation=2000 \ –capture-image \ –set-config-value /main/capturesettings/exposurecompensation=4000 \ –capture-image \ –set-config-value /main/capturesettings/exposurecompensation=0

    done done

    and finally the file /usr/local/bin/hook.sh:

    !/bin/sh

    case “$ACTION” in

    delete downloaded file and kill gphoto, so original script can continue

    download)
    rm $ARGUMENT
    kill $(pidof gphoto2)
    ;;
    *)
    ;;
    

    esac exit 0

    Reply
    1. Khürt Williams

      I’m rewriting my scripts in Perl. I think I understand how the wait-event option works. It may be possible to have the script run as a deamon waiting for the user to turn on the camera. Once the camera is on, the script waits for the user to press the shutter release. This image is then discarded and the script proceeds to capture 5 images then goes back to waiting for the user to press the shutter release. I’ll test this out today.

      Reply
  5. Pingback: Ten pimped-out projects for the Raspberry Pi | AyeITech

  6. James

    Another comparable device is the Z902 (current model is the Z2C) or the Measy U1A. There’s also the Cotton Candy, though that one weighs in at $199 before shipping. Seems to be quite a few companies coming out with these types of devices right now.

    Reply
        1. Khürt Post author

          I assume then you mean that the D40 could send a signal to the USB port. But … what would cause it to do that?

          The D40 doesn’t send any “event” type signals to it’s mini-USB port, other than providing power to the USB port when the camera is turned on. I’m not trying to get the camera to trigger the RPi. I want the RPi to trigger the camera.

          The use case for a camera is the other way around — “capture an image when this event happens”. An event would be pushing the shutter button or a capture signal sent from another device connected to the mini-USB port on the camera.

          Reply
          1. Dave

            Hi Khurt, isn’t triggering from a Nikon Remote Control a similar event as pushing the shutter button?

            I guess what I’m trying to say is couldn’t you use the remote to take a range of shots?

            Reply
            1. Khürt Post author

              Dave, I think you misunderstand the reason why I undertook the project. The D40 does not have auto-bracketing for use in HDR photography. HDR involves taking multiple captures of the same subject at different exposures. I’m using the RPi to control the D40 to take a photo, change the exposure, take another photo, etc. Yes, I could use the remote to do this but changing the exposures requires touching the camera which means the position of the lens will move. Even the smallest change messes up the HDR . Here is a great tutorial on HDR photography: http://www.stuckincustoms.com/hdr-tutorial/ If the D40 had auto-bracketing I would have no use for the RPi for this project. The other project I mentioned in the blog post is using the RPi to trigger the Nikon at intervals for time lapse photography. I don’t want the camera to tell the RPi to do something. I want the RPi to tell the camera to do something.

              Reply
              1. Dave

                Khurt, I understand the D40 side of things – I think I just misunderstood some of your original post.. I’ve read it back now and get what you are doing…

                One new question, when you go out in the field do you have the RaspberryPi turned on (plugged into your power source) constantly?

                I guess it doesn’t consume much power?

                In addition Is setting up the cron job straightforward?

                Thanks!

                Reply
                1. Khürt Post author

                  I turn the RPi on and off as needed. The battery pack lasts a long time. The problem is that I have no way to tell the RPi to stop taking photos. Once way was to turn off the camera. The problem is that when I would turn the camera back on I was forgetting to disconnect the RPi from the USB, and boom … before I could compose my imaged the RPi would trigger another batch of captures. So … I turn the RPi on/off as needed to allow me to compose between captures.

                  The crontab is straight forward. However, I found some Python code that may help me start up my script at boot time similar to a system service.

                  Reply
                  1. Dave

                    OK thanks for clearing that up – what is the boot time like, how long do you have to wait for the RPi to start triggering the camera?

                    Reply
                  2. Erik

                    Khurt- Awesome job! Been reading you & Dave Hunt’s projects, and the RPi. There are daughter-boards that have buttons on them- if you could build a case or if they fit in the existing case, you could build a “trigger” function to kick off the HDR script when you need it. Might take some experiments, but would be slick!

                    Reply
                    1. Khürt Post author

                      Hi Erik, Thanks for the words of encouragement. I’m writing a perl script to control the camera via gPhoto and trigger the image capture via the camera shutter button. My goal is to have the entire thing triggered via a button and the RPi GPIO. I may even write some Perl bindings to the gPhoto library if I find the motivation and time.

  7. Pingback: Mini-Rechner Raspberry Pi: Bastel-PC lässt Elche reden | Konrad Lischka

  8. Pingback: Week 52 - Auld Lang Syne - Island in the Net

  9. Pingback: The 5 Most Popular Posts of 2012 - Island in the Net

  10. Pingback: Week 34 - Sunrise - Island in the Net

  11. nemik

    Hey, just a suggestion but you could also just unplug the camera from the Pi’s USB rather than turning it on and waiting the 5 seconds. If it’s unplugged, gphoto won’t detect it. You could then even splice in a switch to the Vcc line on the USB cable and turn it on, off when you want.

    Reply
  12. Andrea

    Hello Khurt and everybody else who’s reading this post.

    My Rpi is running the so called “Soft-float Debian wheezy” and I’ve recently installed the gpohoto2 library (ver. 2.4.14, that is what is available from the repository) but unfortunately I haven’t been able to get the library up and running properly yet so far with my Canon Powershot cameras (A300 and A520 models).

    The auto-detect function works just fine and both the cameras are correctly recognised but as I try to list files, it runs through the tree folders but retrieves no JPG files stored in the SD card (note there are several); besides, when I try to capture image and download it turns out that “This camera cannot capture”.

    Wanna hear the weird thing?

    As I move the cameras to my laptop where I have installed Ubuntu and a not-so-much-earlier version of the gphoto2 library everything works just fine !!!

    I tried to run gphoto2 bot as “pi” and “root” users but it behaves in the same way.

    Does anyone would be so kind to help me figure this out? Am I the only one?

    Reply
    1. Khurt Williams Post author

      Andrea, I tried using gPhoto with my Sony point-n-shoots (DSC-W55 and HDR-CX11). Neither worked well. I suspect the code in gPhoto on the Raspberry Pi is optimized for DSLR cameras.

      Reply
    2. Will

      Hi

      Is Pi trying to mount the camera when it is plugged in/turned on. (does a screen pop up asking you what to do with it?) if so try to unmount the camera then try Gpgoto2.

      I had loads of problems with Gphoto2 at first, it would recognize the camera but not do much. It turned out that I needed to set the camera’s USB setting to PTP / MTP and unmount the camera from Ubuntu.

      Reply
    3. Andrea

      Hi everybody. Thanks for the replies. I’m happy to announce that I did fix the problem. I built a new SD image and on this fresh installation I installed the gphoto2 from te repository with the usual apt-get command. It worked as it was intended to do. Then I realised why it didn’t work on the other SD card: before installing from the repository I tried to compile the source code of gphoto2 (so to have the latest release) on my own but the compiling process ended with several errors; only after this unsuccesfull operation I decided to get it from the repository but something must have gone wrong and looks like the two operations made a mess ! Needless to say that I use the command line shell only on Linux and obviously I had already put all the cameras in PTP mode.

      Reply
  13. Justin

    Nice work! This gave me an excuse to buy a raspberry!

    I have been playing with your code (not on a raspberry, on a win7 machine with ubuntu running in vmware) and got it to work with my Nikon D3000. It seems that the bracketing is slower then continuous shooting? Do you have the same experience?

    Reply
      1. Justin

        Have you played with the capture target? i.e.: gphoto2 –set-config capturetarget=0 will only keep the photos in the camera’s ram, instead of writing to the card.

        Then query and download the images from the ram?

        I don’t know if it possible though.

        Reply
        1. Khurt Williams Post author

          I did not use capturetarget = 0 because my Nikon ( and most DSLR cameras ) do not have internal memory. Images must be captured to SD card. If your capture has internal storage then capturetarget = 0 may work for you.

          Reply
          1. Will

            I’ve got a D40x the camera has a frame buffer for when using burst shooting but I don’t know to get Gphoto to access that.

            It seems that Gphoto likes to take a picture and then feed back on it’s progress, If you could get Gphoto to ignore the feedback then maybe it could go faster. (similar to when the camera is set to single shot)

            Reply
            1. Will

              Ok last night I had a quick play with my setup before the battery died.

              I tried these two lines of code; the first line sets the camera to burst mode the second tells the camera to use 5 bursts. this successfully utilized the camera’s frame buffer.

              gphoto2 –set-config /main/capturesettings/capturemode=1 gphoto2 –set-config /main/capturesettings/burstnumber=5

              However when trying these settings with your script I ended up with 5 frames of each exposure intotal 25 frames.

              Reply
              1. Khurt Williams Post author

                That makes sense. My script capture 5 different exposures of the subject. If you call your gphoto2 command within the loop the burst mode will be run five time. 25 images. What are you trying to accomplish.

                Reply
  14. RichShumaker

    You might want to check this out for GPIO control – http://davidhunt.ie/?p=2641 and I have just started my RasPi Camera Controlling and until I get a camera that works I can’t take the next step. The next step for me is creating a web page to control the camera so then I can use any web browser on the network to control it. Last but not least I bought this battery pack and got 7 hours of RasPi on it with video playing 85% of the time – http://www.amazon.com/gp/product/B006VYXH6S/ref=oh_details_o02_s00_i00 Have a great day. Rich Shumaker

    Reply
  15. RichShumaker

    You might want to check this out for GPIO control – http://davidhunt.ie/?p=2641 and I have just started my RasPi Camera Controlling and until I get a camera that works I can’t take the next step. The next step for me is creating a web page to control the camera so then I can use any web browser on the network to control it. Last but not least I bought this battery pack and got 7 hours of RasPi on it with video playing 85% of the time – http://www.amazon.com/gp/product/B006VYXH6S/ref=oh_details_o02_s00_i00 Have a great day. Rich Shumaker

    Reply
  16. GlennPhillips

    Glad I’ve found this, have just got RPi and looking to set up similar with Nikon D2H. Will cetainly try out your script.

    Reply
    1. khurtwilliams

       @GlennPhillips  Thanks for stopping by.  I hope you are successful in getting your D2H to work with gPhoto2 and the Raspberry Pi.  I’m hoping to refine the script and add a triggering mechanism … soon.

      Reply
  17. medwards

    gphoto2 appears to have two options which may help you capture images based on events: –capture-tethered and –wait-event (or –wait-event-and-download).  The manual does give the caveat that using these options requires support in both the camera and driver.   Good stuff – I haven’t yet ordered a Raspberry Pi due to not having a project in mind that it can help with… but now you’ve given me some ideas!  :)

    Reply
  18. BillyScott

    Great piece of ingenuity. Could you possibly use a remote trigger that feeds its signal to the pi? Using something like the Gert board?

    Reply
  19. BillyScott

    Great piece of ingenuity. Could you possibly use a remote trigger that feeds its signal to the pi? Using something like the Gert board?

    Reply
      1. vfpvaz

         @khurtwilliams OK, I’ve got it running, but I have some errors. My Nikon D40 takes 5 shots, but it shows me this:*** Error ***              The property ‘Exposure Compensation’ / 0×5010 was not set, PTP errorcode 0x200f.   *** Error ***              Failed to set new configuration value -2000 for configuration entry /main/capturesettings/exposurecompensation. 

        Reply
    1. khurtwilliams

       @unknown875 I have an Eye-Fi.  Used it for photo-shoot earlier this year.  My model works with JPEG only but I still found it useful.  I found the transfer speed a bit lacking and the connections were not stable.  Still, a recommended product if you need to shoot with a wireless tether.

      Reply
  20. unknown

    Nice work, was wondering have you heard of MK802? its similar to rasberry pi but much smaller and more powerful and for cheaper (is you include the cost of case) it has built in wifi and heres a performance comparison http://www.youtube.com/watch?v=xbbfyWmmsKE, this can run linux to. would do you think?  

    Reply
      1. mgarbowski

         @khurtwilliams  @mgarbowski No. I never heard of it before this. I’m also fortunate to have a Dt00 that doesn’t need this extra setup in order to bracket. But, I love reading these sorts of self-help/self-invention projects, especially when it relates to an area I understand.

        Reply
  21. Pingback: Camera Pi – DSLR Camera with Embedded Computer

Leave a Reply