Monday, July 20, 2009

You're Building a What?

A couple of months ago, my sister decided she wanted a photo booth at her wedding reception. She looked in to renting one, but decided it was prohibitively expensive. So, what's a bride to do? Call her tech-savvy sister of course!

I happily accepted the challenge, as it was right up my alley. After doing some research online (she was not the first person to have this idea, after all), I decided on a course of action.

Following is a description of the build:

Hardware:
Thinkpad T30 (courtesy of Dad)
Powershot A20 (my first digital camera)
A20 Power Supply ($13 on eBay)
Generic Webcam (a ViewQuest VQ110 -- something I picked up years ago and never use)
USB Panic Button ($9.50 on eBay)
Photosmart 325 Compact Photo Printer ($20 from Craigslist)
Generic USB hub
USB extension cable
LCD monitor
the actual booth and some furniture (thanks to my parents)

Notes on the printer: HP printers have excellent Linux support, and I basically just bought the cheapest photo printer I could find that could use the 100 cartridge (for best quality B&W photo printing)

Software:
Ubuntu 9.10
gphoto2 - for remote controlling the camera
Cheese - web cam video display
Panic Button Script - listens to the button and fires something off when it's pushed
Imagemagick - image processing
flickr_upload - Perl module to, you guessed it, upload to Flickr
Bash script to do everything

I made some modifications to the panic button script. Here's my version:

use Device::USB::PanicButton;

printf( "*******************\n" );
printf( "Push the button to\n" );
printf( "start taking photos\n" );
printf( "*******************\n" );

my $pbutton = Device::USB::PanicButton->new();
my $count = 0;


if(!$pbutton || $pbutton->error()) {
printf(STDERR "FATAL: ". $pbutton->error() ."\n");
exit(-1);
}

while(1) {
my $result = $pbutton->pressed();

if($result == 1) {
system( "/home/t30user/Photobooth/take.sh" ); # take the picture
} elsif($result <>error() ."\n"); # uh-oh!
} elsif($count % 60 == 0) {
$count = 0;
system("gphoto2 -n > /dev/null 2>&1"); # keep the camera alive
}
$count++;
sleep(1);
}


And here's take.sh:

#!/bin/bash

# Time stamped directory
stamp=`date '+%Y%m%d%H%M%S'`
cd working

echo
echo "*******************"
echo "* Taking photos *"
echo "*******************"
echo


# Take pictures
gphoto2 --capture-image -F 4 -I 2 --quiet > /dev/null 2>&1

echo "*******************"
echo "* Creating strip *"
echo "*******************"
echo

# Put them in a strip
img_list=" "
for i in $(ls ./*JPG)
do
img=`basename $i`
cp $img ../photos/$img
chmod 777 ../photos/$img
img_list="$img_list $img "
mogrify -colorspace Gray -resize 640x480 $img
done


montage $img_list -tile 1x4 -geometry +20+12 ../strips/$stamp.jpg
montage ../strips/$stamp.jpg ../strips/$stamp.jpg -tile 2x1 -geometry +0+12 -resize 600x1788 -density 300 ../print.ps
chmod 777 ../print.ps
cp ../print.ps ../prints/$stamp.ps

rm $img_list
cd ..

echo "*******************"
echo "* Printing strip *"
echo "*******************"
echo

lp print.ps

echo "*******************"
echo "* Uploading strip *"
echo "*******************"
echo

flickr_upload strips/$stamp.jpg

clear
echo "*******************"
echo "* Push the button *"
echo "* to start taking *"
echo "* photos! *"
echo "*******************"
echo
To start the photobooth, I ran
sudo perl panicbutton.pl
in the terminal -- all the user had to do then was push the button.

I stacked the webcam on top of the digicam (and held it in place with some rubber bands) and tried to make them point at roughly the same place. The monitor went inside the photo booth (while the laptop and printer stayed outside). I stretched the desktop across the two displays, and had Cheese in fullscreen mode on the monitor.

The photo booth prints out two copies of the strip side by side on 4x6 photo paper. This way, we had one copy for the photo album, and the guests could take a copy home with them as well.

Sorry - I have no screenshots or photos. However, I do have tenative plans to rebuild the booth (my dad wasn't giving up the laptop permanently, and the furniture pieces we were using were scrounged from around my parents' house), so I'll see if I can write this up properly then.