Takes a bounding box in the form [x1,y1,x2,y2] and returns z in the form [x,y,s,r] where x,y is the centre of the box and s is the scale/area and r is the aspect ratio.
(bbox)
| 369 | |
| 370 | @staticmethod |
| 371 | def convert_bbox_to_z(bbox): |
| 372 | """Takes a bounding box in the form [x1,y1,x2,y2] and returns z in the form |
| 373 | [x,y,s,r] where x,y is the centre of the box and s is the scale/area and r is |
| 374 | the aspect ratio.""" |
| 375 | w = bbox[2] - bbox[0] |
| 376 | h = bbox[3] - bbox[1] |
| 377 | x = bbox[0] + w / 2.0 |
| 378 | y = bbox[1] + h / 2.0 |
| 379 | s = w * h # scale is just area |
| 380 | r = w / float(h) |
| 381 | return np.array([x, y, s, r]).reshape((4, 1)) |
| 382 | |
| 383 | |
| 384 | class SORTBase(metaclass=abc.ABCMeta): |