MCPcopy Create free account
hub / github.com/D-Robotics/rdk_model_zoo / draw_boxes

Function draw_boxes

utils/py_utils/visualize.py:51–64  ·  view source on GitHub ↗

Draw bounding boxes with class names and scores.

(image: np.ndarray, boxes: np.ndarray, cls_ids: np.ndarray,
               scores: np.ndarray, class_names: list, colors: list)

Source from the content-addressed store, hash-verified

49# ==============================================================================
50
51def draw_boxes(image: np.ndarray, boxes: np.ndarray, cls_ids: np.ndarray,
52 scores: np.ndarray, class_names: list, colors: list) -> np.ndarray:
53 """Draw bounding boxes with class names and scores."""
54 for box, cls_id, score in zip(boxes, cls_ids, scores):
55 x1, y1, x2, y2 = map(int, box)
56 color = colors[cls_id % len(colors)]
57 name = class_names[cls_id] if cls_id < len(class_names) else str(cls_id)
58 label = f"{name} {score:.2f}"
59
60 cv2.rectangle(image, (x1, y1), (x2, y2), color, thickness=2)
61 cv2.putText(image, label, (x1, max(y1 - 5, 0)),
62 fontFace=cv2.FONT_HERSHEY_SIMPLEX,
63 fontScale=0.5, color=color, thickness=1)
64 return image
65
66
67def draw_masks(image: np.ndarray, boxes: np.ndarray, masks: list,

Callers 2

draw_detection_resultsFunction · 0.85
draw_seg_yolo26Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected