(cvimg, bbox, scale, rot, do_flip, out_shape)
| 132 | |
| 133 | |
| 134 | def 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 | |
| 156 | def rotate_2d(pt_2d, rot_rad): |
no test coverage detected