Posted in Raspberry PI | 43 comments

A DIY photo booth for events that takes photos and uploads an animated gif to a Tumblr account.

Quickstart

If you are just looking for the nitty gritty, consider looking at the code on GitHub, the how to photos on Flickr, and the results on Tumblr.

Intro

This post begins with a story. My wife started grad school in the Fall of 2012 at the Cooperstown Graduate Program. We moved to Cooperstown, NY in the summer of 2012. Given the two-year program, it gave me a two-year duration for a photo project. I decided to use the iPhone app PocketBooth to take photo strips of people that we would meet in those two years. Of course this was before the word “selfie” was used all the time. It turned into a fun project. I printed the strips and hung them in our house as the number grew. Then, on the night of graduation, I brought the exhibit to their reception. It went over very well. I then posted the photos online on Flickr.

Overall I was happy with the project. I was constantly surprised at how easy it was to get people to smile and let loose in front of a camera when it’s a photo booth. However, it was very time intensive. I had to take my phone out of my pocket, open the app, take the photo strips, save the strips to my computer, print out the strips, cut the strips, and then hang them on the exhibit. Part of the beauty of the original photo booths is they were automated.

So then I decided to make an automated photo booth for my wife’s graduation reception—a bit of a guerrilla exhibit. It sounded like fun. I had been playing around with the Raspberry Pi for a bit, so this seemed like a great use for the camera module.

The Plan

Original sketch of the idea

Original sketch of the idea

So the goal was to make an easy to use photo booth for guests at an event. Then turn the photos into an animated gif and automatically post it online for easy sharing.

I began with a notebook sketch of the idea, algorithm, and construction. See here. Then I researched other photo booths out there for inspiration. Then I started wiring, coding, and testing. Once I had the parts working, then I built the enclosure.

Here is the basic algorithm:

Idea Algorithm

Algorithm idea sketch

  • Setup
    • Set the device on top of a camera tripod and point it at a good location for guests to stand
    • Make sure there will be good lighting on the guests
    • Power up the device
    • Light up all the lights on the front for a bit to show that it’s running, then turn them off
    • Await a button press
  • Big button press
    • Once the button is pressed, blink the first light for a few seconds, telling the guests to get ready
    • Show the real time video preview on the screen
    • Take four pictures
    • Light up the “Pose” light
    • Take a photo and save as a .jpg with a timestamp in the filename
    • Repeat four times
  • Process the images
    • Turn off the preview monitor
    • Blink the “Uploading” light
    • Combine the four jpgs into a new animated gif (consider adding a footer to all the pics)
    • Upload to Tumblr (since Tumblr natively handles animated gifs)
    • Stop blinking the light
  • Done
    • Light the “Done” light for a few seconds
    • Replay the images on the screen a few times for instant gratification of the guests
    • Await another button press
  • Shutdown
    • Have another button in the system, and if it is pressed shutdown the Raspberry Pi safely. Light all the LEDs first as a clue to when it’s safe to turn off the system.
  • Exit (optional)
    • Have a third button in the system, if it is pressed exit the python program but don’t shutdown the Raspberry Pi. I used this a lot when developing the code, but it’s not necessary if you aren’t tweaking the code often.

The Parts

View from the rear showing the guts, including the Raspberry Pi

View from the rear showing the guts, including the Raspberry Pi

Here is a basic parts list without the enclosure:

Here is an optional parts list, some things that are really nice to add:

Setup the Raspberry Pi

Raspberry Pi Graphical Interface -- Photo by Gary Higgins (https://www.flickr.com/photos/meccanohig/8104338921/)

Raspberry Pi Graphical Interface — Photo by Gary Higgins

If you are new to the Raspberry Pi, there are lots of good tutorials to get you started. But here are some quick links on what’s needed for this project.

Install noobs on the SD card.

Setup the WiFi.

If you are using the Bluetooth keyboard and mouse combo, here are some instructions for setup.

Somehow you’ll want to move files to and from the Raspberry Pi. If you have a Mac, this is the easiest way. This looks good on a PC, but I’ve never tried it.

I’d recommend doing most of the configuration using a large external monitor. When you’re ready to move to the small screen, note that I ran into errors getting the composite video working. I found that I needed to edit a config file.

sudo nano /boot/config.txt

Comment out the line

# hdmi_force_hotplug=1

I ended up figuring out some other settings to get the video looking decent on the low resolution monitor.

start_x=1
gpu_mem=128
framebuffer_width=800
framebuffer_height=480
overscan_left=5
overscan_right=5
overscan_top=1
overscan_bottom=1
disable_overscan=1
sdtv_aspect=3
disable_camera_led=1

If you haven’t already, setup the Raspberry Pi to automatically boot into the GUI desktop.

Change the background image with a right-click. Chose art for a message to give the users as they approach the device. You can download mine here if you want. I found the texture here.

Hide the mouse cursor.

Disable the screensaver.

GPIO, LEDs, and Buttons

Solderless breadboard with the circuit

Solderless breadboard with the circuit

One of the cool things about the Raspberry Pi is you can wire your own inputs and outputs. This is all done through the GPIO.

I first worked out the circuit using a solderless breadboard. You can see the schematic below or the wiring diagram. Then I moved the bits to the perma-proto board and got my soldering iron out.

Breadboard schematic

Breadboard schematic

Wiring diagram

Wiring diagram

Taking Photos

Raspberry Pi Camera Module and laser etched front face plate

Raspberry Pi Camera Module and laser etched front face plate

First, with the system turned off, plug-in the camera. Then boot it back up. You’ll need to follow the initial setup instructions.

I decided to use PiCamera to control the camera with Python. Install PiCamera.

Creating the Animated Gif

I first tried ImageMagick, but had some issues with the jpg delegate. I then used GraphicsMagick instead. It works great. Read the installation instruction here for Unix. But the following should work.

sudo apt-get install graphicsmagick

Once GraphicsMagick is installed, you can test it with the following code. It will combine all the jpgs in the current directory.

gm convert -delay 100 *.jpg joined.gif

Uploading to Tumblr

I tried a few different ways to upload to Tumblr. They work, but are slow. I didn’t want the guests waiting too long. Instead I used a technique of sending the animated gif to Tumblr via email. Then Tumblr will automatically post the file. You will need to know your secret tumblr autopost email address.

The Final Code

You can download the code at GitHub. If you have not used GitHub before, check out this link. There are a few values for variables that you will need to replace with your special information. Save the code wherever you want. I put it in the folder named /home/pi/photobooth/. If you are not comfortable using the command line, learn more here.

While I was developing the code, I used little snippits focusing on specific elements. If you want those, they are here:

  • cameratest – take a photo using python but not picamera
  • videotest – likewise with a camera
  • previewtest – using picamera, put a live preview on the screen
  • continuoustest – it’s too slow to take photos one-by-one, each with a new focus and light level test. Instead, try shooting in continuous mode using picamera.
  • displayjpg – after taking the photos and uploading the animated gif, it’s nice to show it on the screen. I couldn’t get the pi to show the animated gif, but we could cheat by showing the jpgs. This code starts that. It’s a bit tricky.
  • gpio_test – once you get all the pieces put together, try running this to see if they all work.
  • gpio_buttons – here I was testing using the buttons–two of them with a event detection
  • gpio_cleanup – when I was testing, I sometimes that the code quite unexpectedly. I used this code to cleanup the GPIO for the next time I try running something.
  • internettest – I had an issue where the python program quit when my iPhone hotspot momentarily dropped it’s internet connection. This code tests if there there is an internet connection before uploading and has some error handling. It could probably use some more work.
  • tumblr_test – here I’m testing uploading to tumblr directly. It works, but it takes a about two minutes to complete even on a good internet connection. That’s not a useful timeframe with a line of people waiting to use the device. I could have built a queue system on a different thread that uploads files one-by-one. Instead I decided to send the file to post via email. Then Tumblr can take the time to process the files and post them.
  • email_test – here I’m testing sending an email with an attachment

Just change the filename from a .txt file to a .py file, move it to your Pi, and run it with code similar to:

sudo python filename.py

After getting the photobooth code on your Raspberry Pi, set it to automatically run the python code at startup by editing the /etc/rc.local file.

sudo nano /etc/rc.local

I found I need sudo at the beginning, otherwise the GPIO buttons and lights don’t work.

sudo python /home/pi/photobooth/photobooth.py&

Enclosure

Photo booth enclosure

Photo booth enclosure

I decided to build my photo booth case out of wood. I’m not the best carpenter, so it’s a little rough. I won’t go through every step. Take a look at the photos and decide how to build your own case. Here are some ideas I learned in my process:

  • Originally I planned to cut a groove in the outside pieces of wood to hold the front plate in place. I don’t own the right power tools to make this happen and could not borrow any in the time I needed for my deadline. So I changed the plan a little bit. It works.
  • If you design your own cover, you’ll need the dimensions of the camera, Raspberry Pi mount, the Ethernet mount, and the USB mount.
  • If you want to download and modify my design files, here they are.
  • I don’t have a hackerspace near me, so I could not use a laser cutter to make the front plate or the back plate. So I ordered them from Ponoko. The process was really easy. I’m very happy with the results, except for the color contrast on the wood. I ordered size P2, 2.7mm thick bamboo and size P2, 3.0 mm thick acrylic.

Future Ideas

Here are a few ideas that I might work on if I were to make another one. If you solve any of them, please let me know.

  • Use a version of Linux that boots up faster.
  • Build a better power circuit so that there is only one power adapter.
  • Make a better connection to the camera tripod. It’s a little wobbly. It might work better with more metal-on-metal contact. Or just set it on a tall table instead of a tripod.
  • I tried using this over a shared hotspot from my iPhone. It wasn’t quite enough speed. I could explain to people that it takes a while to upload, and it was fine. But really WiFi or Ethernet is the way to go.

Enjoy

See my final pics here: drumminhands.tumblr.com. If you build one, post your link in the comments below. If you have any questions about this, also post in the comments below. Have fun with it.

And if you make one similar, please send me photos or post them in the comments below. I’d love to see other iterations in use.

Iterations

See what other folks have done: