mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-03 20:04:58 +00:00
change boxing and text error of YOLO
This commit is contained in:
@@ -26,14 +26,14 @@ def on_message(client, userdata, message):
|
|||||||
for result in results:
|
for result in results:
|
||||||
for box in result.boxes:
|
for box in result.boxes:
|
||||||
yolo_results.append({
|
yolo_results.append({
|
||||||
"class": box.cls,
|
"class": box.cls.item(),
|
||||||
"confidence": box.conf,
|
"confidence": box.conf.item(),
|
||||||
"bbox": box.xyxy.tolist()
|
"bbox": box.xyxy.tolist()
|
||||||
})
|
})
|
||||||
# Draw bounding box on the image
|
# 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.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
|
# Create an MQTT client instance
|
||||||
mqtt_client = mqtt.Client()
|
mqtt_client = mqtt.Client()
|
||||||
|
Reference in New Issue
Block a user