Page 1 of 1

Automated Car Photo Capture

Posted: Sun Apr 10, 2016 8:43 am
by Jeff Piazza
As I'm sure many of you do, we like to try to capture a photo of each car as it's checked in. This year we made it a self-service affair by adding a bar code scanner and a Raspberry Pi to control the camera, upload the captured photo, and match the photo to the appropriate racer.

As they arrive, racers receive a car tag that includes a bar code telling their car number. As part of the check-in process, the boy puts his car on the photo stand and then scans the bar code. The RPi operates the camera and captures the photo, then uploads it to our web server, along with the car number. The receiving web server matches the car number to the racer and drives (among other things) a slide show of cars as they check in.


If you've somehow never heard of it, the Raspberry Pi is a $35 single-board computer with USB and HDMI ports. For this particular application, it's running headless (no display, no keyboard, no mouse) with a wifi dongle, bar code scanner and a USB cable running to the camera.

Bar code scanners are inexpensive; I used this particular one, but I believe most any scanner would work: ... ge_o03_s00

Most DSLR cameras can be operated under computer control (this is called "tethering," I think); gphoto2 is the usually-recommended software for this. I use a less-expensive Canon point-and-shoot, for which tethering wouldn't normally be an available feature; tethering is possible in this case using the excellent open-source firmware, the "Canon Hacker's Development Kit," or CHDK (, along with chdkptp running on the RPi (

I used a small C program to read the bar code scanner output; it's available at ... er/barcode. A shell script runs when the RPi starts up that loops continuously waiting for a new scan that starts with the letters "PWD"; when it reads one, it captures a photo (chdkptp) and uploads it to the server (curl):

Code: Select all

#! /bin/sh


# Ignore error failures
set +e

while true ; do
    CAR_NO=`barcode $BARCODE_SCANNER_DEV | grep -e "^PWD[0-9]*$" | sed -e "s/PWD//"`
    if [ "$CAR_NO" ] ; then

	PREFIX=`echo $CAR_NO | sed -e "s/\(PWD[0-9]\).*/\1/"`

	# Assumes there's only one camera attached
	chdkptp -c -e"rec" -e"remoteshoot Car$CAR_NO"

	curl -F action=photo.upload \
             -F MAX_FILE_SIZE=30000000 \
             -F repo=car \
             -F carnumber=$CAR_NO \
             -F "photo=@Car$CAR_NO.jpg;type=image/jpeg" \
This all sounds a lot more complicated than it really is. Get in touch if I can help you with a similar project.

Re: Automated Car Photo Capture

Posted: Sun Apr 10, 2016 12:25 pm
by Indy
Very cool! Thanks for sharing. I have a Raspberry Pi but I haven't done much with it - I should give this a try.

How well does the small lightbox work? I've been thinking about getting one. Do you have a car photo you can share?


Re: Automated Car Photo Capture

Posted: Sun Apr 10, 2016 1:39 pm
by Vitamin K
Very cool! I bet the kids had a blast with that.

Re: Automated Car Photo Capture

Posted: Mon Apr 11, 2016 7:35 am
by Jeff Piazza
Here's a representative sample. I find it's necessary to adjust the white balance for good results, and I should probably experiment more with the placement of the lights.


Re: Automated Car Photo Capture

Posted: Mon Jun 06, 2016 6:46 am
by davet
That is super cool. For the last couple yrs I had been trying to get our Pack to takes pics at checkin so they could show them on the big screen when the awards are given for Best of Show, Best paint, Most Patriotic, etc. I think it would just take too long to individually load each one and try to quickly bring up the right pic at the right time. This seems to solve that. :thumbup: