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

Function process_bbox

ADHMR/lib/utils/preprocessing.py:61–89  ·  view source on GitHub ↗

保持检测框中心点位置不变调整检测框比例为cfg.input_img_size ration: 扩大检测框大小

(bbox, img_width, img_height, ratio=1.25)

Source from the content-addressed store, hash-verified

59
60
61def process_bbox(bbox, img_width, img_height, ratio=1.25):
62 '''
63 保持检测框中心点位置不变调整检测框比例为cfg.input_img_size
64
65 ration: 扩大检测框大小'''
66 # [DEBUG] input img shape different from smpler-x
67 input_img_shape = (512, 384)
68
69 bbox = sanitize_bbox(bbox, img_width, img_height)
70 if bbox is None:
71 return bbox
72
73 # aspect ratio preserving bbox
74 w = bbox[2]
75 h = bbox[3]
76 c_x = bbox[0] + w / 2.
77 c_y = bbox[1] + h / 2.
78 aspect_ratio = input_img_shape[1] / input_img_shape[0]
79 if w > aspect_ratio * h:
80 h = w / aspect_ratio
81 elif w < aspect_ratio * h:
82 w = h * aspect_ratio
83 bbox[2] = w * ratio
84 bbox[3] = h * ratio
85 bbox[0] = c_x - bbox[2] / 2.
86 bbox[1] = c_y - bbox[3] / 2.
87
88 bbox = bbox.astype(np.float32)
89 return bbox
90
91
92def get_aug_config():

Callers 1

load_dataMethod · 0.90

Calls 1

sanitize_bboxFunction · 0.70

Tested by

no test coverage detected