Last week I had a wedding :) It was a great party but this is not a blog about entertainment. Since I’m very enthusiastic about DIY and Raspberry i thought — why not build a self made photo booth that instead of instantly printing images is uploading them on special new instagram account that everybody would have access to. I talked with my brother Rafal and we decided that it shouldn’t be a big deal. So this is how we have done it.
First of all was to decide the hardware parts. I had an old SLR Camera Nikon d80. After few tests with USB and its PTP mode I’ve found out about libgphoto2 library and its capabilities. D80 is quite old and have no live preview, so this was the only pitfall. Anyway I decided that without preview final pictures would be even funnier.
Below is the quick relation of garage battlefield.
So final list of hardware parts where
- D80 SLR
- LED light panel
- Some wires (power, usb, gpio, hdmi, etc)
- Soldered battery connection with external Power Supply
- Big button to take pictures
- Rasperry PI with brand new NOOBS
- Wooden box
- Wooden parts to hold everything together
- Square LCD display with HDMI
In terms of putting in all together it wasn’t hard for some parts — a power for LED panel, LCD display and raspberry PI, but was for the others. Since D80 is quite old, addons like permanent power supply was almost impossible to get, unachievable in such short notice. Rafał had to solder the battery connection with external power supply based on diagrams from google images. Last piece of art was to connect button through Raspberry GPIO and to put it all together so that it does not fall apart during the party. Everything was inside big wooden box pictured below.
Front panel was cut with CNC machine with written instruction and bespoke holes for SLR camera, button and LCD display.
I thought that I wasn’t a first person that came with that idea, so i search the open source community i came across great python script by Balthasar Reuter. I had to amend some logic and graphic layout, but this wasn’t a hard task, much harder was that i had never ever used python before.
Instagram script with Paulo Coelho quotes.
Uploading picture thought Instargram API is not allowed. For commercial project i wouldn’t never ever try to bypass this restriction, yet this was just one day party personal event. There are lot of hacky script in github that did this so I’ve copy the method from one of them and added some funny functionality — each uploaded photo was having a caption with random quote of Paulo Coelho. You can get all the quotes from my github repository (linked below).
Python photobooth and uploading scripts were separated so i needed a simplest way to synchronize them. I’ve come with idea
- Once picture is done its being placed in to_upload folder
- When watch script finds a first file in to_upload folder it moves it to uploading folder and starts putting it on instagram
- Once picture is uploaded is was moved to uploaded folder
This was part of php instagram script now i needed a way to launch this script every time a new file is being put in “to_upload” folder. Without any dependencies following python script is doing the job.
folder = "to_upload"
application = "php insta.php"
return subprocess.check_output(["ls", folder]).decode('utf-8').strip().split("\n")
drlist1 = get_drlist()
drlist2 = get_drlist()
for file in [f for f in drlist2 if not f in drlist1]:
command = application+" '"+folder+"/"+file+"'"
subprocess.Popen(["/bin/bash", "-c", command])
This was quite a surprise but Raspbian wasn’t respecting some standard techniques Iuse for default Linux startup script like services or putting shell script in init.d folder. In te resources section I’m linking an article “Run a Program On Your Raspberry Pi At Startup” yet none of this 5 methods actually worked on my system. What did worked in amending ~/.config/lxsession/LXDE-pi file. There I had to put commands to run two python scripts
- photobooth script
- watch script
Below are sample pictures taken during the wedding. Note the quotes :D
- Python photobooth script by Balthasar Reuter
- Run a Program On Your Raspberry Pi At Startup
- Raspberry PI Forum Exchange thread “Execute script on start-up”
- Example PHP Instagram upload script
- Raspery PI with brand new NOOBS
- All my scripts in github repository
Photo booth story. How programming is fun after work (during my wedding). was originally published in Qunabu Interactive on Medium, where people are continuing the conversation by highlighting and responding to this story.