I'm running a photo-booth project with python 2.7.9 and by kivy software built may I know why everytime after Press run it doesn't displayed anything but just a black-screen and I need to reboot again else it will just stucked in the Black-screen of death. Anyone can help??Thanks
Coding:
from __future__ import print_function
import os, time, sys
import Image
import kivy
kivy.require('1.11.0')
from kivy.uix.button import Button
from kivy.uix.gridlayout import GridLayout
from kivy.uix.image import Image as kivyImage
from kivy.clock import Clock
from kivy.graphics import Color, Rectangle
# Some variables
photoPath = "/home/pi/Desktop/CameraP/NewImage.jpg"
photoName = time.strftime("%Y%m%d%H%M%S") + "_NewImage.jpg"
photoResize = 512, 384
photoTitle = "Kiehl's Photo Booth!"
# Callback function for photo button
def photo_callback(obj):
# Define filename with timestamp
photoName = time.strftime("%Y%m%d%H%M%S") + "_NewImage.jpg"
# Take photo using "raspistill"
os.system("sudo raspistill -p '144,48,512,384' --vflip -w 800 -h 600 -o " + photoPath + photoName)
# Resize the high res photo to create thumbnail
Image.open(photoPath + photoName).resize(photoResize,Image.ANTIALIAS).save(photoPath + "thumbnail.jpg")
class MyApp(App):
# Display the latest thumbnail
photo = kivyImage(source="/home/pi/Desktop/CameraP/thumbnail.jpg")
def build(self):
# Set up the layout
photobox = GridLayout(cols=3, spacing=10, padding=10)
# Create the UI objects (and bind them to callbacks, if necessary)
photoButton = Button(text="photo", size_hint=(.20, 1)) # Button: 5% width, 100% height
photoButton.bind(on_press=photo_callback) # when pressed, trigger the photo_callback function
# Periodically refresh the displayed photo using the callback function
Clock.schedule_interval(self.callback, 1)
# Add the UI elements to the layout
photobox.add_widget(photoButton)
photobox.add_widget(self.photo)
return photobox
# Callback for thumbnail refresh
def callback(self, instance):
self.photo.reload()
if __name__ == '__main__':
MyApp().run()