From 22bb578913cfa177dea5d0f31f87ba19f2770702 Mon Sep 17 00:00:00 2001 From: ploedige Date: Tue, 17 Jan 2023 10:29:44 +0000 Subject: [PATCH] webapp that implements barcode and indication_driver --- website/app.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/website/app.py b/website/app.py index 2d494b8..2531cde 100644 --- a/website/app.py +++ b/website/app.py @@ -5,14 +5,20 @@ from imutils.video import VideoStream from pyzbar import pyzbar import time +import sys +sys.path.append("..") +from TREx.indication_driver import IndicationDriver + app = Flask(__name__) vs = VideoStream(src=0).start() time.sleep(2) frame = None +indication_driver = IndicationDriver() def stream(camera_index): global frame + global indication_driver while True: raw_frame = vs.read() stream_frame = imutils.resize(raw_frame, width=400) @@ -22,7 +28,12 @@ def stream(camera_index): (x, y, w, h) = barcode.rect cv2.rectangle(decode_frame, (x, y), (x + w, y + h), (0, 0, 255), 2) barcode_data = barcode.data.decode("utf-8") - print(barcode_data) + if barcode_data == "X000UP6UQN": + print(f"{barcode_data}: CAN") + indication_driver.indicate("CAN") + else: + print(barcode_data) + indication_driver.clear() cv2.putText(decode_frame, barcode_data, (x, y -10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0,0,255), 2) stream_frame = imutils.resize(decode_frame, width=400) ret, jpg = cv2.imencode('.jpg', stream_frame)