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

Function gen_trans_from_patch_cv

HMR-Scorer/common/utils/preprocessing.py:165–198  ·  view source on GitHub ↗
(c_x, c_y, src_width, src_height, dst_width, dst_height, scale, rot, inv=False)

Source from the content-addressed store, hash-verified

163
164
165def gen_trans_from_patch_cv(c_x, c_y, src_width, src_height, dst_width, dst_height, scale, rot, inv=False):
166 # augment size with scale
167 src_w = src_width * scale
168 src_h = src_height * scale
169 src_center = np.array([c_x, c_y], dtype=np.float32)
170
171 # augment rotation
172 rot_rad = np.pi * rot / 180
173 src_downdir = rotate_2d(np.array([0, src_h * 0.5], dtype=np.float32), rot_rad)
174 src_rightdir = rotate_2d(np.array([src_w * 0.5, 0], dtype=np.float32), rot_rad)
175
176 dst_w = dst_width
177 dst_h = dst_height
178 dst_center = np.array([dst_w * 0.5, dst_h * 0.5], dtype=np.float32)
179 dst_downdir = np.array([0, dst_h * 0.5], dtype=np.float32)
180 dst_rightdir = np.array([dst_w * 0.5, 0], dtype=np.float32)
181
182 src = np.zeros((3, 2), dtype=np.float32)
183 src[0, :] = src_center
184 src[1, :] = src_center + src_downdir
185 src[2, :] = src_center + src_rightdir
186
187 dst = np.zeros((3, 2), dtype=np.float32)
188 dst[0, :] = dst_center
189 dst[1, :] = dst_center + dst_downdir
190 dst[2, :] = dst_center + dst_rightdir
191
192 if inv:
193 trans = cv2.getAffineTransform(np.float32(dst), np.float32(src))
194 else:
195 trans = cv2.getAffineTransform(np.float32(src), np.float32(dst))
196
197 trans = trans.astype(np.float32)
198 return trans
199
200
201def process_db_coord(joint_img, joint_cam, joint_valid, do_flip, img_shape, flip_pairs, img2bb_trans, rot,

Callers 1

generate_patch_imageFunction · 0.70

Calls 1

rotate_2dFunction · 0.70

Tested by

no test coverage detected