批量将长方形方框转换为正方形
def rect2square(boxes):
h = boxes[:, 3] - boxes[:, 1]
w = boxes[:, 2] - boxes[:, 0]
l = np.maximum(w, h)
boxes[:, 0] = boxes[:, 0] + w * 0.5 - l * 0.5
boxes[:, 1] = boxes[:, 0] + h * 0.5 - l * 0.5
boxes[:, 2:4] = boxes[:, 0:2] + np.transpose(np.tile(l, (2, 1)))
return boxes