From 9584d43ede883f0980c6cc689e413840cd40eca7 Mon Sep 17 00:00:00 2001 From: Adrien Pre Date: Sat, 31 Oct 2020 10:57:35 +0100 Subject: [PATCH] fix wrong case in live_yolo_opencv.py --- machine-learning/object-detection/live_yolo_opencv.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/machine-learning/object-detection/live_yolo_opencv.py b/machine-learning/object-detection/live_yolo_opencv.py index 1a67f116..4ad3fe9e 100644 --- a/machine-learning/object-detection/live_yolo_opencv.py +++ b/machine-learning/object-detection/live_yolo_opencv.py @@ -76,9 +76,10 @@ x, y = boxes[i][0], boxes[i][1] w, h = boxes[i][2], boxes[i][3] # draw a bounding box rectangle and label on the image - color = [int(c) for c in colors[class_ids[i]]] + + color = [int(c) for c in COLORS[class_ids[i]]] cv2.rectangle(image, (x, y), (x + w, y + h), color=color, thickness=thickness) - text = f"{labels[class_ids[i]]}: {confidences[i]:.2f}" + text = f"{LABEL[class_ids[i]]}: {confidences[i]:.2f}" # calculate text width & height to draw the transparent boxes as background of the text (text_width, text_height) = cv2.getTextSize(text, cv2.FONT_HERSHEY_SIMPLEX, fontScale=font_scale, thickness=thickness)[0] text_offset_x = x @@ -97,4 +98,4 @@ break cap.release() -cv2.destroyAllWindows() \ No newline at end of file +cv2.destroyAllWindows()