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

Function generate_patch_image

HMR-Scorer/common/utils/preprocessing.py:134–153  ·  view source on GitHub ↗
(cvimg, bbox, scale, rot, do_flip, out_shape)

Source from the content-addressed store, hash-verified

132
133
134def generate_patch_image(cvimg, bbox, scale, rot, do_flip, out_shape):
135 img = cvimg.copy()
136 img_height, img_width, img_channels = img.shape
137
138 bb_c_x = float(bbox[0] + 0.5 * bbox[2])
139 bb_c_y = float(bbox[1] + 0.5 * bbox[3])
140 bb_width = float(bbox[2])
141 bb_height = float(bbox[3])
142
143 if do_flip:
144 img = img[:, ::-1, :]
145 bb_c_x = img_width - bb_c_x - 1
146
147 trans = gen_trans_from_patch_cv(bb_c_x, bb_c_y, bb_width, bb_height, out_shape[1], out_shape[0], scale, rot)
148 img_patch = cv2.warpAffine(img, trans, (int(out_shape[1]), int(out_shape[0])), flags=cv2.INTER_LINEAR)
149 img_patch = img_patch.astype(np.float32)
150 inv_trans = gen_trans_from_patch_cv(bb_c_x, bb_c_y, bb_width, bb_height, out_shape[1], out_shape[0], scale, rot,
151 inv=True)
152
153 return img_patch, trans, inv_trans
154
155
156def rotate_2d(pt_2d, rot_rad):

Callers 2

augmentationFunction · 0.70
augmentation_segFunction · 0.70

Calls 1

gen_trans_from_patch_cvFunction · 0.70

Tested by

no test coverage detected