-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
57 lines (51 loc) · 1.55 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
import os
from time import sleep
from ctypes import *
#connect to the C file
garbot = CDLL("./gar_bot.so")
#call C function to check connection
garbot.connect()
def main():
#Load the weights into memory
weights_err = garbot.load_weights()
if weights_err == -1:
print("error loading weights")
while True:
#delete files from previous detections
if os.path.exists("one.txt"):
os.remove("one.txt")
if os.path.exists("two.txt"):
os.remove("two.txt")
if os.path.exists("three.txt"):
os.remove("three.txt")
if os.path.exists("four.txt"):
os.remove("four.txt")
#Check if the photo has been sent
if os.path.exists('./garbage.bin'):
#transfer the photo to sdram
photo_err = garbot.load_photo()
if photo_err == -1:
print('error loading photo into mem')
break
#start the neural network and get result
accelerator_result = garbot.start_accelerators()
if accelerator_result == -1:
print('error with hardware acceleration')
#tell the gui through the pipe what the accelerator thinks
print("1-"+str(accelerator_result))
#wait for user to confirm or override the accelerators decision
button = garbot.wait_on_buttons();
print("2-"+str(button))
if (button == 1):
os.mknod("one.txt")
elif (button == 2):
os.mknod("two.txt")
elif (button == 3):
os.mknod("three.txt")
elif (button == 4):
os.mknod("four.txt")
sleep(7)
#remove file so ready for next item
os.remove('garbage.bin')
# print("File removed")
main()