(c_x,
c_y,
src_width,
src_height,
dst_width,
dst_height,
scale,
rot,
inv=False)
| 350 | |
| 351 | |
| 352 | def gen_trans_from_patch_cv(c_x, |
| 353 | c_y, |
| 354 | src_width, |
| 355 | src_height, |
| 356 | dst_width, |
| 357 | dst_height, |
| 358 | scale, |
| 359 | rot, |
| 360 | inv=False): |
| 361 | # augment size with scale |
| 362 | src_w = src_width * scale |
| 363 | src_h = src_height * scale |
| 364 | src_center = np.array([c_x, c_y], dtype=np.float32) |
| 365 | |
| 366 | # augment rotation |
| 367 | rot_rad = np.pi * rot / 180 |
| 368 | src_downdir = rotate_2d(np.array([0, src_h * 0.5], dtype=np.float32), |
| 369 | rot_rad) |
| 370 | src_rightdir = rotate_2d(np.array([src_w * 0.5, 0], dtype=np.float32), |
| 371 | rot_rad) |
| 372 | |
| 373 | dst_w = dst_width |
| 374 | dst_h = dst_height |
| 375 | dst_center = np.array([dst_w * 0.5, dst_h * 0.5], dtype=np.float32) |
| 376 | dst_downdir = np.array([0, dst_h * 0.5], dtype=np.float32) |
| 377 | dst_rightdir = np.array([dst_w * 0.5, 0], dtype=np.float32) |
| 378 | |
| 379 | src = np.zeros((3, 2), dtype=np.float32) |
| 380 | src[0, :] = src_center |
| 381 | src[1, :] = src_center + src_downdir |
| 382 | src[2, :] = src_center + src_rightdir |
| 383 | |
| 384 | dst = np.zeros((3, 2), dtype=np.float32) |
| 385 | dst[0, :] = dst_center |
| 386 | dst[1, :] = dst_center + dst_downdir |
| 387 | dst[2, :] = dst_center + dst_rightdir |
| 388 | |
| 389 | if inv: |
| 390 | trans = cv2.getAffineTransform(np.float32(dst), np.float32(src)) |
| 391 | else: |
| 392 | trans = cv2.getAffineTransform(np.float32(src), np.float32(dst)) |
| 393 | |
| 394 | trans = trans.astype(np.float32) |
| 395 | return trans |
| 396 | |
| 397 | |
| 398 | def process_db_coord_batch_no_valid(joint_img, joint_cam, do_flip, |
no test coverage detected