From 83e2cadd9dadc01f154e8d041cef7cb80d4efec6 Mon Sep 17 00:00:00 2001 From: ploedige Date: Mon, 16 Jan 2023 02:34:26 +0000 Subject: [PATCH] website now shows rectangle around barcode --- website/app.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/website/app.py b/website/app.py index d39a72c..2d494b8 100644 --- a/website/app.py +++ b/website/app.py @@ -19,8 +19,12 @@ def stream(camera_index): decode_frame = imutils.resize(raw_frame, width=800) barcodes = pyzbar.decode(decode_frame) for barcode in barcodes: + (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) + 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) jpg2bytes = jpg.tobytes() yield b'--frame\r\nContent-Type: image/jpeg\r\n\r\n' + jpg2bytes + b'\r\n\r\n'