def render_bboxes_image(bboxes, output_width, output_height, input_width, input_height):
'''
Render the bounding boxes (bboxes) on an image of size (output_width, output_height),
where the bounding box coordinates exist between (0,0) and (input_width, input_height).
'''
output_image = np.zeros((output_height, output_width), dtype=np.uint8)
w_scale = output_width/input_width
h_scale = output_height/input_height
for min_x, min_y, max_x, max_y in bboxes:
pt1 = (int(min_x*w_scale), int(min_y*h_scale))
pt2 = (int(max_x*w_scale), int(max_y*h_scale))
cv2.rectangle(output_image,pt1, pt2, 255, cv2.FILLED)
return output_image
评论列表
文章目录