From 7d1b878c30b89faf3d49ee5d56dbbdc1499e2475 Mon Sep 17 00:00:00 2001 From: Sam Hos Date: Mon, 6 Jan 2025 16:11:03 +0100 Subject: [PATCH] fix yolo image boxes --- src/Python/flask/web/app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Python/flask/web/app.py b/src/Python/flask/web/app.py index e9c414c..334e643 100644 --- a/src/Python/flask/web/app.py +++ b/src/Python/flask/web/app.py @@ -28,7 +28,7 @@ def on_message(client, userdata, message): yolo_results = [] for result in results: for box in result.boxes: - class_id = int(box.cls.item()) # Convert to integer + class_id = int(box.cls.item()) # Convert to integer class_name = yolo_classes[class_id] yolo_results.append({ "class": class_name, @@ -36,7 +36,7 @@ def on_message(client, userdata, message): "bbox": box.xyxy.tolist() }) # Draw bounding box on the image - x1, y1, x2, y2 = map(int, box.xyxy) + x1, y1, x2, y2 = map(int, box.xyxy[0]) cv2.rectangle(latest_image, (x1, y1), (x2, y2), (0, 255, 0), 2) cv2.putText(latest_image, f"{class_name} {box.conf.item():.2f}", (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.9, (0, 255, 0), 2)