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

Function generate_patch_image

ADHMR/lib/utils/preprocessing.py:121–140  ·  view source on GitHub ↗
(cvimg, bbox, scale, rot, do_flip, out_shape)

Source from the content-addressed store, hash-verified

119
120
121def generate_patch_image(cvimg, bbox, scale, rot, do_flip, out_shape):
122 img = cvimg.copy()
123 img_height, img_width, img_channels = img.shape
124
125 bb_c_x = float(bbox[0] + 0.5 * bbox[2])
126 bb_c_y = float(bbox[1] + 0.5 * bbox[3])
127 bb_width = float(bbox[2])
128 bb_height = float(bbox[3])
129
130 if do_flip:
131 img = img[:, ::-1, :]
132 bb_c_x = img_width - bb_c_x - 1
133
134 trans = gen_trans_from_patch_cv(bb_c_x, bb_c_y, bb_width, bb_height, out_shape[1], out_shape[0], scale, rot)
135 img_patch = cv2.warpAffine(img, trans, (int(out_shape[1]), int(out_shape[0])), flags=cv2.INTER_LINEAR)
136 img_patch = img_patch.astype(np.float32)
137 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,
138 inv=True)
139
140 return img_patch, trans, inv_trans
141
142
143def rotate_2d(pt_2d, rot_rad):

Callers 1

augmentationFunction · 0.70

Calls 1

gen_trans_from_patch_cvFunction · 0.70

Tested by

no test coverage detected