MCPcopy Create free account
hub / github.com/MotrixLab/ADHMR / get_bbox

Function get_bbox

ADHMR/lib/utils/preprocessing.py:24–44  ·  view source on GitHub ↗
(joint_img, joint_valid, extend_ratio=1.2)

Source from the content-addressed store, hash-verified

22
23
24def get_bbox(joint_img, joint_valid, extend_ratio=1.2):
25 x_img, y_img = joint_img[:, 0], joint_img[:, 1]
26 x_img = x_img[joint_valid == 1];
27 y_img = y_img[joint_valid == 1];
28 xmin = min(x_img);
29 ymin = min(y_img);
30 xmax = max(x_img);
31 ymax = max(y_img);
32
33 x_center = (xmin + xmax) / 2.;
34 width = xmax - xmin;
35 xmin = x_center - 0.5 * width * extend_ratio
36 xmax = x_center + 0.5 * width * extend_ratio
37
38 y_center = (ymin + ymax) / 2.;
39 height = ymax - ymin;
40 ymin = y_center - 0.5 * height * extend_ratio
41 ymax = y_center + 0.5 * height * extend_ratio
42
43 bbox = np.array([xmin, ymin, xmax - xmin, ymax - ymin]).astype(np.float32)
44 return bbox
45
46
47def sanitize_bbox(bbox, img_width, img_height):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected