webapp that implements barcode and indication_driver

This commit is contained in:
paul-loedige 2023-01-17 10:29:44 +00:00
parent ee300ca29f
commit 22bb578913

View File

@ -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")
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)