in models/01_YoloV5/01_Pytorch/processing.py [0:0]
def draw_cv2(self, image, bboxes, scores, cids):
"""Draw the detection boxes on the given image"""
# Box coordinates are normalised, convert to absolute and clip to image boundaries
h, w = image.shape[:2]
bboxes[:, (0, 2)] *= w
bboxes[:, (1, 3)] *= h
bboxes[:, (0, 2)] = np.clip(bboxes[:, (0, 2)], 0, w-1)
bboxes[:, (1, 3)] = np.clip(bboxes[:, (1, 3)], 0, h-1)
for bbox, score, cid in zip(bboxes.astype(int), scores, cids.astype(int)):
label = f'{self.class_names[cid]} {score:.2f}'
self.draw_box(image, bbox, label=label, color=self.colors[cid])