MCPcopy Create free account
hub / github.com/chhankyao/visdb / generate_patch_image

Function generate_patch_image

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

Source from the content-addressed store, hash-verified

141
142
143def generate_patch_image(cvimg, cvdp_img, bbox, scale, rot, do_flip, out_shape):
144 img = cvimg.copy()
145 dp_img = cvdp_img.copy()
146 img_height, img_width, img_channels = img.shape
147
148 bb_c_x = float(bbox[0] + 0.5*bbox[2])
149 bb_c_y = float(bbox[1] + 0.5*bbox[3])
150 bb_width = float(bbox[2])
151 bb_height = float(bbox[3])
152
153 if do_flip:
154 img = img[:, ::-1, :]
155 dp_img = dp_img[:, ::-1, :]
156 bb_c_x = img_width - bb_c_x - 1
157
158 trans = gen_trans_from_patch_cv(bb_c_x, bb_c_y, bb_width, bb_height, out_shape[1], out_shape[0], scale, rot)
159 img_patch = cv2.warpAffine(img, trans, (int(out_shape[1]), int(out_shape[0])), flags=cv2.INTER_LINEAR).astype(np.float32)
160 dp_img_patch = cv2.warpAffine(dp_img, trans, (int(out_shape[1]), int(out_shape[0])), flags=cv2.INTER_NEAREST).astype(np.uint8)
161 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, inv=True)
162
163 return img_patch, dp_img_patch, trans, inv_trans
164
165
166def rotate_2d(pt_2d, rot_rad):

Callers 2

demo.pyFile · 0.90
augmentationFunction · 0.85

Calls 1

gen_trans_from_patch_cvFunction · 0.85

Tested by

no test coverage detected