-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
81 lines (64 loc) · 2.06 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import requests, os, sys
from picamera import PiCamera
from time import sleep
import pygame
from gpiozero import Button
button=Button(3)
pygame.init()
shirt = pygame.mixer.Sound('shirt2.wav')
shoes = pygame.mixer.Sound('shoes2.wav')
luggage = pygame.mixer.Sound('luggageandbags2.wav')
dress = pygame.mixer.Sound('dress2.wav')
t_shirt = pygame.mixer.Sound('tshirt2.wav')
skirt = pygame.mixer.Sound('skirt2.wav')
coat = pygame.mixer.Sound('coat2.wav')
jeans = pygame.mixer.Sound('jeans2.wav')
beep = pygame.mixer.Sound('beep-01a.wav')
camera = PiCamera()
while True:
model_id = '91b79f93-6365-4d62-b023-da62d5d1b6b9'
api_key = '5ruwcBCMTfRRzb2666dUTvVVucSXr1ej'
image_path = '/home/pi/Desktop/MagicMirror/currentimage.jpg'
url = 'https://app.nanonets.com/api/v2/ObjectDetection/Model/' + model_id + '/LabelFile/'
data = {'file': open(image_path, 'rb'), 'modelId': ('', model_id)}
button.wait_for_press()
print("The button was pressed!")
sleep(5)
camera.resolution = (3280,2464)
camera.capture("/home/pi/Desktop/MagicMirror/currentimage.jpg")
beep.play()
response = requests.post(url, auth=requests.auth.HTTPBasicAuth(api_key, ''), files=data)
response_text = response.text
#print(response_text)
#Coat Footwear Luggage Shoes Skirt T-Shirt Dress Jeans Shirt
type_index = response_text.find("label") + 8
clothing = response_text[type_index:type_index+3]
if (clothing == "Shi"):
shirt.play()
print("9")
elif (clothing == "Foo"):
shoes.play()
print("8")
elif (clothing == "Lug"):
luggage.play()
print("7")
elif (clothing == "Sho"):
shoes.play()
print("6")
elif (clothing == "Ski"):
skirt.play()
print("5")
elif (clothing == "T-S"):
t_shirt.play()
print("4")
elif (clothing == "Dre"):
dress.play()
print("3")
elif (clothing == "Jea"):
jeans.play()
print("1")
elif (clothing == "Coa"):
coat.play()
print("2")
else: print("error")
sleep(5)