MCPcopy Create free account
hub / github.com/Vegetebird/GraphMLP / convert_bbox_to_z

Function convert_bbox_to_z

demo/lib/sort/sort.py:33–45  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

31
32
33def convert_bbox_to_z(bbox):
34 """
35 Takes a bounding box in the form [x1,y1,x2,y2] and returns z in the form
36 [x,y,s,r] where x,y is the centre of the box and s is the scale/area and r is
37 the aspect ratio
38 """
39 w = bbox[2] - bbox[0]
40 h = bbox[3] - bbox[1]
41 x = bbox[0] + w / 2.
42 y = bbox[1] + h / 2.
43 s = w * h # scale is just area
44 r = w / float(h)
45 return np.array([x, y, s, r]).reshape((4, 1))
46
47
48def convert_x_to_bbox(x, score=None):

Callers 2

__init__Method · 0.85
updateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected