Automated Car Photo Capture

General race coordinator discussions.
Jeff Piazza
Pine Head
Pine Head
Posts: 84
Joined: Thu Apr 10, 2008 12:49 pm
Location: Wellesley, Massachusetts

Automated Car Photo Capture

Postby Jeff Piazza » Sun Apr 10, 2016 8:43 am

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.

Image

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: http://www.amazon.com/Hi-Eshop-Automatic-Sensing-Handsfree-Adjustable/dp/B010FP9BVS?ie=UTF8&psc=1&redirect=true&ref_=oh_aui_detailpage_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 (http://chdk.wikia.com/wiki/CHDK), along with chdkptp running on the RPi (https://www.assembla.com/spaces/chdkptp/wiki).

I used a small C program to read the bar code scanner output; it's available at https://github.com/jeffpiazza/rpi-utils/tree/master/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

BARCODE_SCANNER_DEV=/dev/input/by-id/usb-Megawin_Technology_Inc._USB_Keyboard-event-kbd
WEBSERVER=http://MBP17.pwd/derbynet

# 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" \
            $WEBSERVER/action.php
fi
done


This all sounds a lot more complicated than it really is. Get in touch if I can help you with a similar project.


Indy
Journeyman
Journeyman
Posts: 48
Joined: Sun Apr 24, 2011 7:27 am
Location: Twin Cities, MN

Re: Automated Car Photo Capture

Postby Indy » Sun Apr 10, 2016 12:25 pm

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?

Thanks,
David


User avatar
Vitamin K
Master Pine Head
Master Pine Head
Posts: 896
Joined: Sat Apr 20, 2013 7:26 pm
Location: Montgomery County, MD
Contact:

Re: Automated Car Photo Capture

Postby Vitamin K » Sun Apr 10, 2016 1:39 pm

Very cool! I bet the kids had a blast with that.


Jeff Piazza
Pine Head
Pine Head
Posts: 84
Joined: Thu Apr 10, 2008 12:49 pm
Location: Wellesley, Massachusetts

Re: Automated Car Photo Capture

Postby Jeff Piazza » Mon Apr 11, 2016 7:35 am

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.

Image


User avatar
davet
Master Pine Head
Master Pine Head
Posts: 437
Joined: Wed Jan 16, 2013 2:33 am
Location: Andover, MN

Re: Automated Car Photo Capture

Postby davet » Mon Jun 06, 2016 6:46 am

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:



Return to “General Coordinator Topics”

Who is online

Users browsing this forum: No registered users and 1 guest