A DIY photo booth for events that takes photos and uploads an animated gif to a Tumblr account.
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.
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:
- 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
- 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
- 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.
Here is a basic parts list without the enclosure:
- Raspberry Pi computer ~$40
- Raspberry Pi camera module ~$30
- SD Card
- I used a 32 GB card with a decent read/write speed
- But an old camera card at least 8GB should be fine
- Power adapter with USB A to Micro B cable ~$10
- 7 inch monitor
- Video cable
- Video power adapter
- You’ll need one unless it’s included in your monitor purchase. I used a variable adapter that I had sitting around.
- A standard USB keyboard you have laying around is just fine. You’ll only need it during configuration, not during usage.
- I use at wireless keyboard/mouse combo, which is nice to leave plugged in even during operation at an event.
- A standard USB mouse is fine, as you’ll just need it during configuration.
- A big button of your favorite color ~$10
- Small perma-protoboard
- GPIO cables ~$10
- Used to connect the GPIO pins to the perma-protoboard
- 4x 220 ohm resisters ~$1
- 4x LED bulbs of your favorite color ~$7 for 25
- 2x push button switches ~$3 for 20
Here is an optional parts list, some things that are really nice to add:
- WiFi adapter ~$12
- Powered USB hub ~$22
- Consider this only during setup. The Raspberry Pi only has two USB ports, and sometimes you may want to use the keyboard, mouse, and WiFi adapter.
- If you want to modify the circuit design at all, a Pi Cobbler, solderless breadboard, and jumper wires
- USB power panel mount ~$4
- It’s nice in the finished product to unplug the power and not have to reach into the enclosure. This is used to power the Raspberry Pi. If you use it, then you’ll also need a standard USB A to B cable. You probably have one sitting around.
- Ethernet panel mount ~$5
- If you’re using a wired connection, which is nice for speed and reliability, then this makes it much easier to connect in the final enclosure. You’ll also need a longer Cat 5 or Cat 6 cable.
- DC power jack ~$4
- USB port panel mount ~$4
- I didn’t add this, but I wish I did. It would make it easier to troubleshoot.
- Extension cable for the camera module ~$5
Setup the Raspberry Pi
Install noobs on the SD card.
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
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. Edit: In the second version of this project, I changed the background to a simple black.
GPIO, LEDs, and Buttons
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.
First, with the system turned off, plug-in the camera. Then boot it back up. You’ll need to follow the initial setup instructions.
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. UPDATE: karnold from the Dallas Museum of Art was kind enough to fix the code for the tumblr upload without using the email process. Instead, it used pytumblr and the tumblr API. Now it is speedy enough to use as the primary means of posting the images.
To install pytumblr, follow these steps:
- Install PIP somewhere on your pi
- In the terminal, navigate to the pip folder you downloaded and moved to the pi. Then run the following code:
sudo python get-pip.py
- Download pytumblr and copy the files somewhere on your pi.
- In the terminal, navigate to pytumblr folder and run this command to install:
sudo python setup.py install
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
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/drumminhands_photobooth.py&
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.
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.
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.
See what other folks have done:
- St. Louis Science Center had their ScienceTechGirls make one.
- @jspotproduction made one with a great CNC enclosure.
- @CongoJoe made one for a wedding.
- Here’s another.
Some folks have been talking about this project. Here are a few. If you have a post about the project, please let me know and I’ll add it here.