Photo booths are fun! They can inspire goofiness in just about anyone.
For my first project with the Raspberry Pi I built a photo booth for a party. This was a great project for learning to tinker with photography and electronics on the Pi. People were happy with the booth, and curious how it was built, so I thought I'd share what I learned.
This project tutorial assumes a very basic knowledge of linux/bash and the ability to solder a simple circuit.
Overview: four main components of the booth
- Camera, with USB connection and preferably with an AC power adapter and tripod
- Photo printer
- Controller, the user interface, with a start button and indicator lights, and a brain of Raspberry Pi, which controls the camera, assembles the photo montage, and drives the printer. This is what I will show you how to build.
- Booth enclosure, not strictly necessary, but does provide the intimacy essential for maximum fun; best when filled with beautiful women in fabulous dresses
Parts needed for the controller:
Powered USB hub
GPIO ribbon cable
Perma-proto-board Pi cobbler
LED-illuminated momentary contact switch
LED indicator lights
wire for making connections
soldering iron and solder
SD card reader
computer to set up the SD card
monitor/TV with HDMI
USB keyboard and mouse
Step 1: Setup RPi
Do you already have your RPi with Raspbian installed and can access it through SSH? Then skip to Step 2: Connect the Camera. Otherwise, grab your RPi, an SD card, an SD card reader, and another computer and:
1) Prepare an SD card with a Raspbian install
2) Boot up and configure
Enable the SSH server during configuration, so you can run your RPi headless, i.e., without a monitor or keyboard, via the command line from a remote terminal.
3) Set up a network connection
Open Midori to test if you are connected to the internet. Then, once you are successfully connected, open a terminal window and type "sudo ifconfig" to get your ethernet IP address; write down this number (something like 10.0.1.19).
4) and lastly, set up SSH
Log in to your RPi from another computer on the network. Now you're ready for the next step.
Step 2: Connect the Camera
After getting your Pi initially set up, get a camera hooked up. You can control most cameras with the RPi using Gphoto2, a well supported, actively updated, free, command-line digital camera controller for *NIX operating systems. Using scripts you can thus automate your camera's controls.
Install gphoto2 from the command line (via SSH on your other computer, or LXTerminal from the RPi desktop)
1) Update the system:
sudo apt-get update
2) Download and run this script, which installs and updates gphoto2:
sudo wget raw.github.com/gonzalo/gphoto2-updater/master/gphoto2-updater.sh
sudo chmod 755 gphoto2-updater.sh
3) To ensure your camera mounts properly to be controlled via USB (see this thread), remove these files:
sudo rm /usr/share/dbus-1/services/org.gtk.Private.GPhoto2VolumeMonitor.service
sudo rm /usr/share/gvfs/mounts/gphoto2.mount
sudo rm /usr/share/gvfs/remote-volume-monitors/gphoto2.monitor
sudo rm /usr/lib/gvfs/gvfs-gphoto2-volume-monitor
sudo shutdown -r 0
5) Attach your camera to the RPi with USB and test it out
Do you see a new file in the home directory? This is the photo that was captured. Yay!
Step 3: Connect the Printer
Now you need a printer. A dye sublimation printer makes decent quality photo prints fairly quickly. I used the Canon Selphy CP900, which I randomly bought at Best Buy for this project without doing much research. Luckily it worked out.
Use CUPS to drive the printer. You can check to see if CUPS supports a particular printer. The Canon Selphy CP-900 is not on that list. I got it working using the SELPHY-CP770 driver (this was the lucky part), which, though it was available through the actual CUPS installation, I do not see on the list linked to above (as of Feb 2014).
1. Install CUPS from the RPi command line (for further guidance/troubleshooting, see here)
sudo apt-get install cups
Add the user (pi) to the group allowed to print (lpadmin)
sudo usermod -a -G lpadmin pi
2. Connect your printer and setup CUPS from the RPi desktop
Attach to the RPi by USB and power up your printer.
Open Midori and type into the URL line
This will open up the CUPS setup.
Click "administration" and "add printer;" enter your username and password (e.g., the defaults "pi" and "raspberry").
You should see your printer listed under "local printer;" select it and click "continue."
Set the name and location of your printer as you like, and click "continue."
Select the driver for your printer. For me, there was no CP900 driver, but the CP770 driver worked just fine.
Set the default options.
Now you should be done with printer setup.
3. Test printing
Check for active printers
Do a test print. "lpstat -p" will give you the name of the printer, in my case "Canon_CP900," which was designated during the CUPS setup above. List the files in your home directory by typing "ls." "capt0000.jpg" is the photo previously captured by the camera. Substitute your own printer name and photo capture name into the command to print, "lp"; the -d argument determines the print destination.
lp -d Canon_CP900 capt0000.jpg
Step 4: Build the Electronics
There are three parts for the user interface:
- start button, lights up when ready for shooting and starts the photobooth process when pressed
- pose LED, tells the subjects to pose, flashes faster just before the shot
- please wait LED, lights up while the photos are being processed and sent to the printer, lets the next subjects know they need to wait; necessary so the print queue doesn't fill up and crash the Pi
To me the most exciting thing about the RPi is the GPIO (general purpose input/output), which lets you work with electronics with your Pi.
3) Wire the circuit. See the circuit diagram. After breadboarding it up and trying it out to your satisfaction, solder everything together using a PermaProto for Pi. I made the "pose" light a green LED and the "please wait" light a red LED. The "ready to start" LED in the diagram was wired to light the pushbutton switch.
4) Mount it all in a box. I ended up using a cheap enclosure from Radio Shack. I wish I had spent more time on this part of the project, making it look more fancy. I bet you can get more creative.
Almost ready to go! Now we just need to do a bit more prep of the RPi.
Note: the button is based on this useful tutorial.
Step 5: Set Up Full Rig, Download Scripts, Test
1) Connect the printer and camera to the RPi using a USB hub.
2) Make a label for the montage. Name the file "photobooth_label.jpg" and put it onto your RPi in the home directory.
I used Illustrator, exporting a ~110x1100 pixel .jpg, oriented vertically. The words read from bottom to top. I guess you could also use Photoshop, GIMP, or Inkscape.
Upload the photobooth label file to your RPi by opening a local terminal window, change to the local directory where this file is and transfer the file:
scp photobooth_label.jpg email@example.com:~
Alternately you could email it to yourself and use the RPi GUI to get the file. Or, with a windows machine, use WinSCP.
3) Get the scripts. On the RPi make a directory for and download three scripts; make them executable.
mkdir -p ~/scripts/photobooth
sudo wget raw.github.com/safay/RPi_photobooth/master/assemble_and_print
sudo wget raw.github.com/safay/RPi_photobooth/master/photo_booth.py
sudo wget raw.github.com/safay/RPi_photobooth/master/startup_script
sudo chmod 755 *
Edit the "assemble_and_print" script. Change the "lp" line to include your printer name.
sudo nano assemble_and_print
^X to exit, save the changes
4) Make directories for assembling the montage and archiving shots.
5) Install ImageMagik
sudo apt-get install imagemagick
6) Test: try it out and run the script (ctrl-C to quit).
sudo python ~/scripts/photobooth/photo_booth.py
If it's glowing, push the button.
7) Set script to run automatically.
If the step above works, then make the script run automatically at startup. This will be allow the booth to operate without an external computer or network.
sudo nano /etc/rc.local
Now, add the line
above the "exit 0" line
^X to exit, save the changes
Restart the RPi
sudo shutdown -r 0
The script should automatically run in the background.
You can get archived photomontages off the RPi by scp'ing from your local terminal:
scp firstname.lastname@example.org:~/PB_archive/* .
Step 6: Have Fun!
As for building an actual booth? Here's an opportunity for you to get crazy creative. You can hang some fabric in a corner. Or here's a good description of how to build one out of PVC: https://www.instructables.com/id/DIY-Portable-Wedding-Photo-Booth/step4/Frame/
Don't forget to supply props.
Please comment and let me know how it goes.
Be sure to have fun!
Thank you to Daniel B for inspiration and clueing me in to dye sublimation printers and ImageMagick code. And thank you to HK, TK, and MM for helping make the booth a total success.