MCPcopy Create free account
hub / github.com/ZhengdiYu/SignAvatars / generate_patch_image

Function generate_patch_image

common/utils/preprocessing.py:112–131  ·  view source on GitHub ↗
(cvimg, bbox, scale, rot, do_flip, out_shape)

Source from the content-addressed store, hash-verified

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

Callers 1

augmentationFunction · 0.85

Calls 2

gen_trans_from_patch_cvFunction · 0.85
copyMethod · 0.80

Tested by

no test coverage detected