ferredefossez
Posts: 1
Joined: Wed May 08, 2019 7:19 pm

photobooth error

Wed May 08, 2019 7:21 pm

Hallo,

Ik wil een photobooth maken, het programma vind je hieronder maar als ik het programma doe lopen, krijg ik een foutmelding(errors) kan iemand eens kijken wat er mis loopt...

programma:
from picamera import PiCamera # Hiermee wordt de camera ingelezen
from gpiozero import Button # Hiermee worden de knoppen ingelezen langs GPIO's
from overlay_functions import * # hier importeren we een ander Pyton programma dat er voor zorgt dat er overlay's kunnen gebruikt worden
from time import gmtime, strftime # Hiermee laden we een timer om af te tellen bij het nemen van de foto
from guizero import App, PushButton, Text, Picture # zonder dit te importeren kunnen we geen foto's of knoppen weergeven op de GUI
from twython import Twython
from auth import (consumer_key,consumer_secret,access_token,access_token_secret)

# dit is de method die er voor zorgt dat de volgende overlay wordt getoond
def next_overlay():
global overlay
overlay = next(all_overlays)
preview_overlay(camera, overlay)

# dit is de method van de knop die de foto neemt
def take_picture():
global output
output = strftime("/home/pi/RasPhotoPi/foto/image-%d-%m %H:%M.png", gmtime())
time.sleep(3)
camera.capture(output)
camera.stop_preview()
remove_overlays(camera) # deze lijn moet bewerkt worden ?
output_overlay(output, overlay) # deze lijn moet bewerkt worden ?

# Sla een kleinere gif op
size = 400, 400
gif_img = Image.open(output)
gif_img.thumbnail(size, Image.ANTIALIAS)
gif_img.save(latest_photo, 'gif')

# de foto op de GUI moet deze foto zijn
your_pic.set(latest_photo)

# hier staat de method wanneer je op de kop nieuwe foto klikt van de GUI
def new_picture():
camera.start_preview(alpha=128)
preview_overlay(camera, overlay)

# hier staat de method wanneer je op de knop tweet klikt van de GUI
def send_tweet():
twitter = Twython(
consumer_key,
consumer_secret,
access_token,
access_token_secret
)

# de tweet versturen
message = "Dit is een leuk feest!"
with open(output, 'rb') as photo:
twitter.update_status_with_media(status=message, media=photo)

# de gegevens van de knoppen
next_overlay_btn = Button(23)
next_overlay_btn.when_pressed = next_overlay
take_pic_btn = Button(25)
take_pic_btn.when_pressed = take_picture


# hier staan de instellingen van de camera, ook die van het touchscreenscherm dat we niet gebruiken
camera = PiCamera()
camera.resolution = (800, 480)
camera.hflip = True

# start van de voorbeeld camera
camera.start_preview(alpha=128)

# stel de bestandnaam in
output = ""
# extra gegevens die nodig zijn tijdens het volledige programma
latest_photo = '/home/pi/RasPhotoPi/foto/latest.gif'

app = App("The RasPhotoPi", 800, 480)
#app.tk.attributes("-fullscreen", True)
message = Text(app, "we zagen jou!")
your_pic = Picture(app, latest_photo, grid= [2,0,1,2])
new_pic = PushButton(app, new_picture, text="nieuwe foto")
tweet_pic = PushButton(app, send_tweet, text="Tweet foto")
app.display()


foutmelding:

de camera start op maar toch deze boodschap:


raceback (most recent call last):
File "/home/pi/.local/lib/python3.5/site-packages/guizero/utilities.py", line 149, in _setup_image
self._open_image_source()
File "/home/pi/.local/lib/python3.5/site-packages/guizero/utilities.py", line 182, in _open_image_source
self._tk_image = PhotoImage(file=self._image_source)
File "/usr/lib/python3.5/tkinter/__init__.py", line 3406, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw)
File "/usr/lib/python3.5/tkinter/__init__.py", line 3362, in __init__
self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: couldn't open "/home/pi/RasPhotoPi/foto/latest.gif": no such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/pi/Bureaublad/RasPhotoPi/programma v1 af.py", line 76, in <module>
your_pic = Picture(app, latest_photo, grid= [2,0,1,2])
File "/home/pi/.local/lib/python3.5/site-packages/guizero/Picture.py", line 18, in __init__
super(Picture, self).__init__(master, tk, description, grid, align, visible, enabled, width, height)
File "/home/pi/.local/lib/python3.5/site-packages/guizero/base.py", line 618, in __init__
self.resize(width, height)
File "/home/pi/.local/lib/python3.5/site-packages/guizero/Picture.py", line 79, in resize
self._load_image()
File "/home/pi/.local/lib/python3.5/site-packages/guizero/Picture.py", line 34, in _load_image
self._image = utils.GUIZeroImage(self._image_source, self._width, self._height)
File "/home/pi/.local/lib/python3.5/site-packages/guizero/utilities.py", line 92, in __init__
self._setup_image()
File "/home/pi/.local/lib/python3.5/site-packages/guizero/utilities.py", line 160, in _setup_image
raise_error(error_text)
File "/home/pi/.local/lib/python3.5/site-packages/guizero/utilities.py", line 326, in raise_error
raise GUIZeroException(error_message)
guizero.utilities.GUIZeroException:
------------------------------------------------------------
*** GUIZERO ERROR ***
Image import error - 'couldn't open "/home/pi/RasPhotoPi/foto/latest.gif": no such file or directory'
Check the file path and image type is GIF/PNG


hartelijke dank

ferre

Return to “Nederlands”