From 9c7c7740304382bde723153481a5c872d145afb8 Mon Sep 17 00:00:00 2001 From: Sam Hos Date: Mon, 6 Jan 2025 15:26:00 +0100 Subject: [PATCH] change boxing and text error of YOLO --- src/Python/flask/web/app.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Python/flask/web/app.py b/src/Python/flask/web/app.py index 4e97afc..872da43 100644 --- a/src/Python/flask/web/app.py +++ b/src/Python/flask/web/app.py @@ -26,14 +26,14 @@ def on_message(client, userdata, message): for result in results: for box in result.boxes: yolo_results.append({ - "class": box.cls, - "confidence": box.conf, + "class": box.cls.item(), + "confidence": box.conf.item(), "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"{box.cls} {box.conf:.2f}", (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.9, (0, 255, 0), 2) + cv2.putText(latest_image, f"{box.cls.item()} {box.conf.item():.2f}", (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.9, (0, 255, 0), 2) # Create an MQTT client instance mqtt_client = mqtt.Client()