-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
48 lines (35 loc) · 906 Bytes
/
main.py
File metadata and controls
48 lines (35 loc) · 906 Bytes
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
from motor import rotate
from time import sleep
import subprocess
import request
import os
from ult_wave import get_dist
from request import save_dist
classes = [
'can',
'glass',
'plastic',
'pet_clean'
# 'pet_label'
]
cls = -1
capture_interval = 10
def measure_capacity():
"""
measure capacity for each trash can
:return:
"""
if __name__ == "__main__":
while True:
image_path = 'image.jpg'
subprocess.call(['fswebcam', '-r', '640x640', '--no-banner', image_path])
with open(image_path, 'rb') as image_file:
response = request.send_image(image_file)
print(response.text)
cls = response.text
if cls in classes:
rotate(cls)
save_dist(get_dist(), cls)
request.ask_ecop()
os.remove(image_path)
sleep(capture_interval)