Making Media Making Devices

Updated: Sep 22, 2019

For class, my partner Son and I, made a gif photo booth using a Raspberry Pi and then added a GUI interface.


Components:

Raspberry Pi 3 B+

Raspberry Pi Camera Module

16 GB Micro SD Card



Steps:

We set up the basic components of the Raspberry Pi and the camera Module and connected it to a monitor.


We consulted the Raspberrypi.org resources to create a time-lapse animation for a series of 15 photos, creating a gif. This required setting up ImageMagick on the Terminal using the command line.


Next we used Thonny to write the following code in Python:


from picamera import PiCamera

from os import system


camera = PiCamera()


for i in range(15):

camera.capture('image{0:04d}.jpg'.format(i))


system('convert -delay 10 -loop 0 image*.jpg animation.gif')

print('done')


At first, we encountered a few errors. All the photos were saving but we were unable to create a gif out of them. This was because of two reasons:

1. We had to try reinstalling ImageMagick because a few of the packages were lost.

2. We had to make the images save in a new folder because other images that were saved that also contained numbers in the name confused the gif maker.


Once we made these changes, we were able to successfully create a gif photobooth! It took about a minute after the photo series was taken to string them together into a gif.


We then wanted to add a GUI interface to this. To keep things simple, we made it so that it was one photo taken rather than a series of photos.


We implemented the code below:

from guizero import App, Text, PushButton, Picture

from picamera import PiCamera

from time import sleep


myCamera = PiCamera()

app = App(title="hi world")


welcome_message = Text(app, text="Press button to take picture", size = 20, font = "Times New Roman", color = "blue")


def takePhoto():

myCamera.start_preview(alpha=50)

sleep(2)

myCamera.capture("GUIphoto.jpg")

myCamera.stop_preview()

welcome_message.value = "Done"

picture = Picture(app, image="GUIPhoto.jpg")


myScreenButton = PushButton(app, command=takePhoto, text="Press to take photo")


app.display()



This allowed us to take a photo using a button that we created on a GUI interface which would then be displayed on the screen. The only problem we encountered was that when we tried taking another photo, it would not refresh the photo. I would think that the photo would just be replaced by the next photo taken, so maybe there was something wrong with the refresh of the photo?


Attempting to add to this project later on, we experienced a few hurdles:

We were not able to enable the camera as we did before and kept experiencing these errors. Once we enabled the camera and restarted our interface, we still saw these same errors:





Overall, I thought this was a great introduction to Raspberry Pis and I definitely plan to continue working with them!