hello !
i am trying to build a photobooth app with a raspberry pi connected to a HDMI screen:
i created a function who take a photo and another function who print it. Both function are controlled with physical push buttons connected to the raspberry via GPIO:
the photo function:
def photo_callback():
# Define filename with timestamp
photoName = time.strftime("%Y%m%d%H%M%S") + "_photobooth.jpg"
GPIO.output(DoneLedPin, GPIO.LOW)
GPIO.output(waitLedPin, GPIO.HIGH)
....
....
Image.open(photoPath + photoName).resize(photoNotResize, Image.ANTIALIAS).save(photoPath + "wallpaper.jpg")
the print function:
def print_callback():
# Rotate the thumbnail for printing
Image.open(photoPath + "thumbnail.jpg").transpose(0).save(photoPath + "thumbnail-rotated.jpg")
printer.begin(90) # Warmup time
printer.setTimes(40000, 2000) # Set print and feed times
printer.justify('C') # Center alignment
#printer.printImage(Image.open(photoPath + "line-top.png"), True)
printer.feed(2)
printer.setSize('S')
printer.println(photoTitle)
#printer.printImage(Image.open(photoPath + "line-bottom.png"), True)
printer.feed(2) # Add a blank line
printer.printImage(Image.open(photoPath + "thumbnail-rotated.jpg"), True) # Specify image to print
....
....
Everything is working great with a physical button (connected to the Raspberry PI with GPIO) with this loop:
while True:
input_state = GPIO.input(buttonPhotoPin)
if input_state == False:
print('Photo')
photo_callback()
time.sleep(2)
print_callback()
time.sleep(0.2)
I wanted to display the last taken picture on a HDMI display using
Kivy. I found an
example with a
video but can't find a way to use it correctly myself: I don't want any interface buttons displayed on the screen, rather just the last picture (wallpaper.jpg) and that's it.
class MyApp(App):
# Display the latest thumbnail
photo = kivyImage(source="/home/pi/photobooth/wallpaper.jpg")
if __name__ == '__main__':
MyApp().run()
I have problem on displaying the picture on the display and making my "while" loop working together:
With this code, just the while loop ist working - the last picture is not working with kivy:
while True:
input_state = GPIO.input(buttonPhotoPin)
if input_state == False:
print('Photo')
photo_callback()
time.sleep(2)
print_callback()
time.sleep(0.2)
class MyApp(App):
# Display the latest thumbnail
photo = kivyImage(source="/home/pi/photobooth/wallpaper.jpg")
if __name__ == '__main__':
MyApp().run()
i tried to insert the
while loop in the kivy code, but here, just the image is displayed and i can't get the physical button to work:
class MyApp(App):
# Display the latest thumbnail
photo = kivyImage(source="/home/pi/photobooth/wallpaper.jpg")
while True:
input_state = GPIO.input(buttonPhotoPin)
if input_state == False:
print('Photo')
photo_callback()
time.sleep(2)
print_callback()
time.sleep(0.2)
if __name__ == '__main__':
MyApp().run()
tl;dr: I only manage to make the last picture displayed OR take a photo and print it, but not both. what am i doing wrong?
i made researches and think i have to define a special function (the push button function) and call it in a certain way in Kivy, but i can't find how.
thank you in advance for your help!
greetings
alrick