Skip to content

Instantly share code, notes, and snippets.

@SpaceVoyager
Created February 11, 2018 17:11
Show Gist options
  • Save SpaceVoyager/4a607f0ad3de76e2e870fbc150eb9baf to your computer and use it in GitHub Desktop.
Save SpaceVoyager/4a607f0ad3de76e2e870fbc150eb9baf to your computer and use it in GitHub Desktop.
faceid_test.py
import requests
import photos
import speech
import ui
from PIL import Image
def button_tapped(sender):
myphoto = photos.capture_image()
myphoto.resize((800, 600))
myphoto.save('test.jpg')
photo_viewer.image = ui.Image('test.jpg')
files = {'photo': open('test.jpg')}
url = 'http://www.arborcodemy.com:5035/whoisit'
reponse = requests.post(url, files = files)
result = reponse.json()
speech.say('I think', 'en_US', 0.3)
speech.say('This is ' + result['predicted face'], 'en_US', 0.4)
view = ui.View() # [1]
view.name = 'Face Recognizer' # [2]
view.background_color = 'white'
view.present('fullscreen') # [3]
button = ui.Button(title='Take Photo') # [4]
# [6]
button.action = button_tapped # [7]
button.border_width = 1
button.corner_radius = 4
button.width = 200
button.height = 50
button.x = view.width*0.5 - button.width*0.5
button.y = view.height * 0.9
photo_viewer = ui.ImageView()
photo_viewer.width = 800
photo_viewer.height = 600
photo_viewer.x = view.width*0.5 - photo_viewer.width*0.5
photo_viewer.y = 10
photo_viewer.border_width = 5
photo_viewer.border_color = 'purple'
view.add_subview(button)
view.add_subview(photo_viewer) # [8]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment