Introduction: Yet Another Raspberry Pi Photo Booth
Recently, my company (cubitux) had the opportunity to participate to a contest to present a photo booth solution to a client. Because I'm an open-source fan, I picked Raspberry Pi technology and started creating something around it.
Everything runs with a customized Raspbian - Desktop Edition (Special Linux flavor for Raspberry Pi)
An already made SD card image is available on the following GitHub repository: https://github.com/phenelle/RPi_Photoboth/tree/mas...
However, this guide will show all the steps that we did to customize our Raspbian and make it very close to an embedded system...
Step 1: Required Hardware Component
- Raspberry Pi 2 / 3 (https://www.adafruit.com/product/3055)
- An empty SD card - 8GB (https://www.adafruit.com/product/2767)
- Pi Camera module v2 - 8 mega pixel (https://www.adafruit.com/product/3099)
- 7" inch official Raspberry Pi LCD touch screen (https://www.adafruit.com/product/2718)
- Stand for Raspberry Pi 7" Touchscreen Display (https://www.adafruit.com/product/3187)
- A screw driver to fix the LCD screen on the stand
A keyboard (I prefer that over a touch screen virtual keyboard, however, both options are available...)
Total hardware requirements cost around: $182 USD
Note: I suggest getting hardware from the Adafruit Industries because they highly support open source technologies, and also provide nice and fast support
At this point, you should have a working Raspberry Pi with Raspbian Desktop and a working Camera module enabled.
You can test the Camera module by following this manual: https://www.raspberrypi.org/learning/getting-start...
Step 2: Splash Screen Customization
Everyone who runs Raspberry Pi knows that, when the device boot, the raspberry images shows up with bunch of ugly text lines (boot message).
Because the photo booth was design to be use by the public, we changed the default "start screen" to hide those information and we replaced them with a nice image. (Long story short, the text messages still output somewhere, but we display an image above it)
As root, go to "raspi-config":
- Enable "Console Autologin"
- Disable "Splash Screen" (we use different method than plymouthd)
Based on the following guide (http://www.raspberry-projects.com/pi/pi-operating-...)
- Create a 800 x 480 splash screen images. (We placed our image in /etc/splash.jpg)
- Edit /boot/cmdline.txt and change the line "console=tty1" to "console=null"
- Edit /boot/cmdline.txt and add "logo.nologo quiet" at the end of the command line
- Edit /boot/config.txt and add "disable_splash=1" at the end of the file
- Create a startup script (/etc/init.d/splash)
- Call "sudo insserv /etc/init.d/splash"
Dont worry, the console is still there. If you press "enter" or move to different terminal (for ex, ALT + F3), you will see the shell and be able to run X.
At this point, the device should boot and show the splash screen instead of the default (raspberry image + init text message)
Step 3: Install 3rd Party Applications
To make this work, we will install a little custom website that will be used as graphical interface (GUI) for the user. (Web is an awesome lightweight technology that can be easily created and customized...)
Therefor, we need will need apache webserver, PHP and "uv4l" (UV4L is used to stream the webcam live to the user and take pictures)
The following commands should install all them nicely:
curl http://www.linux-projects.org/listing/uv4l_repo/l... | sudo apt-key add -
sudo sh -c 'echo "deb http://www.linux-projects.org/listing/uv4l_repo/r... jessie main" >> /etc/apt/sources.list.d/uv4l.list '
sudo apt-get update && sudo apt-get -y upgrade
sudo apt-get -y install php5 libapache2-mod-php5 uv4l uv4l-raspicam uv4l-raspicam-extras uv4l-webrtc wkhtmltopdf
(more documentation to install UV4L available here: https://www.linux-projects.org/uv4l/installation/ )
You might need to give permission to the apache user to use "video / webcam" hardware
In order to do that, add the user "www-data" to the group "video". The following command should do the trick...
- sudo usermod -G video www-data
Now, start apache and make sure it persist on reboot:
- sudo /etc/init.d/apache2 start
- sudo /etc/init.d/uv4l_raspicam start
To test that apache is installed and working, open the following URL from within your RPi: http://127.0.0.1/
To test that uv4l is installed, open the following URL from within your RPi: http://127.0.0.1:8080
(as shown on the screenshot)
Now, make this persistant when device reboot:
- sudo update-rc.d apache2 enable
- sudo update-rc.d uv4l_raspicam enable
Reboot your device, and test that both apache and uv4l are started...
Step 4: Deploy Photobooth Website Application
Open a shell and type the following command:
# Install various tools for splash screen
sudo apt-get install xscreensaver feh
# Remove default homepage
sudo mv /var/www/html/index.html /var/www/html/index.html.orig
# Clone repository
# Move all site's content to the /var/www/html folder
sudo mv RPi_Photoboth/source/www/* /var/www/html/
# Allow apache to create files in the "snaps" folder
sudo chown www-data:www-data /var/www/html/img/snaps
The default website installed on the Pi should now show the RPi Booth web application
You can now configure various settings of the "config.php" (such as SMTP, Virtual Keyboard, etc...)
Now if you reboot, everything should work nicely!
I hope you enjoy this tutorial
Step 5: Create Custom Auto-login Procedure at Startup
Now that we have all in place, we need to customize the RPi, so it will automatically run X and open that website for us.
To do that, I enabled "shell auto-login" on the RPi. And I create 2 specials files: .xinitrc and .bashrc,,,
This file is parsed everytime a shells open.
This file is parsed everytime X runs
The idea here is to run X with special options... (not the defaut Gnome interface)
Have a look at the Github repo to see what are the options to make:
We have a be nice policy.
Please be positive and constructive.