def bbox_transform_inv(bbox):
"""convert a bbox of form [xmin, ymin, xmax, ymax] to [cx, cy, w, h]. Works
for numpy array or list of tensors.
"""
with tf.variable_scope('bbox_transform_inv') as scope:
xmin, ymin, xmax, ymax = bbox
out_box = [[]]*4
width = xmax - xmin + 1.0
height = ymax - ymin + 1.0
out_box[0] = xmin + 0.5*width
out_box[1] = ymin + 0.5*height
out_box[2] = width
out_box[3] = height
return out_box
评论列表
文章目录