Skip to content
Snippets Groups Projects
Commit 67954aa1 authored by Jeyan Kanagaratnam's avatar Jeyan Kanagaratnam
Browse files

Replace main.py

parent 5cb8b101
No related branches found
No related tags found
No related merge requests found
......@@ -19,7 +19,7 @@ import subprocess
# All in seconds
POLL_INTERVAL = 1
MAX_IDLE_RESCANS = 10
MAX_IDLE_RESCANS = 30
MAX_IDLE_DEPOSIT = 30
......@@ -171,22 +171,8 @@ def main():
if rescan_count >= MAX_IDLE_RESCANS:
print("Product scan timed out after 30 attempted rescans.")
try:
camera.stop_preview()
camera.close()
env = os.environ.copy()
subprocess.run(["python3","Object_detection_picamera.py"],
cwd="/home/pi/tensorflow1/models/research/object_detection",
env=env)
camera = init_camera()
with open("/home/pi/detected_object.txt","r") as f:
result = f.read().strip()
print("Object detected:", result)
except Exception as e:
print("error:",e)
i2c.setText(messages[customer.locale]["STATE_IDLE_MESSAGE"])
time.sleep(5)
customer = None
customer_id = None
......@@ -206,6 +192,21 @@ def main():
i2c.setText(messages[customer.locale]["STATE_PRODUCT_NOT_FOUND_MESSAGE"])
time.sleep(5)
print('Attempting object detection')
camera.stop_preview()
camera.close()
env = os.environ.copy()
subprocess.run(["python3","Object_detection_picamera.py"],
cwd="/home/pi/tensorflow1/models/research/object_detection",
env=env)
camera = init_camera()
with open("/home/pi/detected_object.txt","r") as f:
result = f.read().strip()
print("Object detected:", result)
else:
i2c.buzz()
......@@ -242,6 +243,6 @@ def main():
finally:
camera.stop_preview()
if __name__ == '__main__':
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment