Introduction: Fear Booth - Raspberry Pi Powered Photo Booth With a Spooky Twist

Happy Halloween!

Fear Booth is a Raspberry Pi powered photo booth that takes your picture like a regular photo booth but only prints it if you look scared! A Fear Level is assigned to every picture based on your facial expression (using OpenCV and DeepFace) so you can compare your scores to others.

I came up with this project because I wanted to create an interactive activity for a Halloween party. I built a photo booth for a different event before and for this event I was aiming for more than just regular pictures, I wanted to add a fun and interactive twist. The idea was to capture people's expressions to make the memories from the party truly stand out!

Supplies

Parts:

3D Printed parts:

  • CameraWindow
  • CRTwindow
  • backCover1
  • backCover2
  • screwCorners
  • boxFront(optional*)
  • boxBack(optional*)
  • boxCombined(optional*)

*If you want to use a 3D-printed box rather than a wooden box

Tools:

  • 3D printer (optional if you can use wood, acrylic, etc. to mount the Raspberry Pi)
  • Drill/Dremel
  • Jigsaw
  • Spray paint

Step 1: Setting Up the Raspberry Pi

Note: You can skip this step if you already have Raspberry Pi OS (64 bit) installed on your system

Installing Raspberry Pi OS

note: you'll need a keyboard, mouse, and monitor to set up your Raspberry Pi

Before we get into the program, we first need to set up our Raspberry Pi. Download the official Raspberry Pi Imager from the following link:

https://www.raspberrypi.com/software/

Attach the SD card to your computer and make sure you select "Raspberry Pi OS (64-bit)", this version will have all the software we need to run our program.

After you've installed the operating system and started your Raspberry Pi, open up the terminal and type:

sudo raspi-config

This will open up the configuration menu, navigate to Interfacing Options, and enable SSH.

Enabling SSH will help us get into the Raspberry Pi remotely so we won't have to use a keyboard, mouse, and monitor every time.

Now our Raspberry Pi is ready for our code!, in the next step, we'll connect the camera and electronics to our Raspberry Pi and test it with the Code.

Step 2: Assembly - Electronics

Webcam

The webcam is directly connected to the Raspberry Pi via USB, I'm using a Logitech webcam but any USB 2.0 webcam should work, try to avoid high-resolution webcams.

CRT TV

Connect the CRT TV via the composite output which can be found on the 3.3mm jack on the Raspberry Pi.

Raspberry Pi GPIO Pins

I've used the physical pin numbering as shown in the diagram below

Adafruit Thermal Printer

PrinterRaspberry Pi 3
GNDGND
TX14
RX15

Arcade Button

ButtonRaspberry Pi 3
GNDGND
Other leg2

Note: some arcade buttons have a build-in light that can be powered directly from the raspberry pi, if this is the case for you you can connect the positive terminal of the light to the 3.3v pin on the raspberry pi.

Now you're done with electronics and are ready for the next step!

Step 3: The Code

We'll be using OpenCV(Open Source Computer Vision Library) for face detection, PIL(Python Image Library) for image processing, python-escpos for interfacing with the thermal printer, and DeepFace for emotion recognition. Let's install these libraries on our Pi,

Install OpenCV

Important Note: The latest Raspberry Pi OS has adopted PEP 668 – Marking Python base environments as “externally managed”. Thus it does not let you install system-wide packages via pip, the use of a virtual environment (venv) is recommended to install these packages. However, using venv led to a lot of issues for this project thus I implemented the "--break-system-packages" tag while installing with pip which is usually not recommended.

To install OpenCV via pip, open a terminal and type:

pip install opencv-python --break-system-packages

this command will install all packages necessary to run OpenCV.

Install DeepFace & PIL

Next, install Deepface by typing:

pip install deepface --break-system-packages

and PIL by:

pip install Pillow --break-system-packages

Install python-escpos

To install python-escpos type;

pip install python-escpos --break-system-packages

now reboot your Pi with;

sudo reboot


FearBooth Code

All the required libraries are installed, now we can now download the project code from Git Hub.

First, navigate to your desktop folder;

cd Desktop

next, install the latest FearBooth code from the repository;

git clone https://github.com/gocivici/FearBooth.git

After navigating into the project folder;

cd FearBooth

you should be able to run the program by;

python main.py

Autostart

for more info and troubleshooting check: https://learn.sparkfun.com/tutorials/how-to-run-a-raspberry-pi-program-on-startup#method-2-autostart

We want to run our script automatically when the Raspberry Pi boots up. To do that we will be using a method called Autostart. With this method, the graphical interface will initialize first and then run our script.

Open the Terminal and type:

mkdir /home/pi/.config/autostart
nano /home/pi/.config/autostart/fearBooth.desktop

Now copy the contents below inside the file you've just created:

[Desktop Entry]
Type=Application
Name=HauntedTV
Exec=/usr/bin/python /home/pi/Desktop/FearBooth/main.py

save, exit with ctrl + x and reboot:

sudo reboot


Step 4: Face Detection & Emotion Recognition (Optional)

In this step, I will go into detail about how I used OpenCV and DeepFace to detect emotions and assign points based on it. You can skip this step if you just want to download and run the code.

Emotion Recognition with DeepFace

There are many Python libraries for detecting facial features for emotion recognition, for this project I chose the open-source DeepFace library as it is lightweight and easy to run on a Raspberry Pi.

DeepFace comes with a strong facial attribute analysis module that can detect anger, fear, sadness, disgust, happiness, and surprise. To use this module you simply call;

predictions = DeepFace.analyze(img,actions=['emotion'])

This variable stores the values for all emotions but in our case we want to access the Fear value, we can do this by;

fearValue = predictions[0]["emotion"]["fear"]

This value is a floating-point number between 0 and 100. You can use this variable to assign any conditions to your liking. For this project, we want to print the picture if the value is above a certain threshold so we are going to compare the value to that number.

For more detailed information visit the DeepFace Repository

Step 5: First Prototype & Test

For the first prototype, I connected the Raspberry Pi to the TV along with the other components. At this stage, the main objective is to test the setup and TV to check if they're working properly.

  • Connect the Raspberry Pi to power and wait for it to boot up.
  • Check if there is a problem with the video feed

Step 6: The Box

Initially, I intended to 3D print the entire box; however, the size limitations of my 3D printer led me to opt for constructing a wooden box instead. If you have a larger printer, you can still proceed with printing the box. I've included the necessary files in the supplies step.


Step 7: Assembly - Wood Box

For the enclosure I found a wood crate which was much cheaper compared to buying plywood and making a box from scratch.

I removed the lid and drew holes based on the template attached. Detailed instructions can be found on the pictures.

Step 8: Painting

I created 3D-printed stencils to paint the letters onto the box. Simply align the stencils as shown in the pictures and use spray paint to paint the letters onto the surface.

Step 9: 3D Printing

There are 8 3D printed parts for this build;

  • CameraWindow: The enclosure for the webcam, you can customize it based on the webcam you use. Can be printed without any support.
  • CRTwindow: The window frame for the CRT TV
  • backCover1: Back cover with vents. requires support with 45 degrees.
  • backCover2: The second part of the back cover with vents. requires support with 45 degrees.
  • screwCorners: Can be printed without any supports
  • boxFront(optional*)
  • boxBack(optional*)
  • boxCombined(optional*)

The printer I used is the Voxelab Aquila with the following settings:

  • Nozzle: 0.4mm
  • infill: %20
  • Filament: ZIRO Translucent PLA



Step 10: Mounting the Raspberry Pi

Step 11: Mounting the TV

Step 12: Final Assembly & Test

With everything mounted, power up the setup. The Raspberry Pi should boot and run the Python script at startup, after a few seconds the TV should turn on, and you should be able to see yourself on the screen.

Next, push the button and strike your pose, the code should detect your face and assign your picture a value. Test the setup by trying different faces and have fun!

If you have any questions ask away! & tell me about your build!

Halloween Contest

Grand Prize in the
Halloween Contest