Calculate the transformation matrix under the constraint of unbiased. Paper ref: Huang et al. The Devil is in the Details: Delving into Unbiased Data Processing for Human Pose Estimation (CVPR 2020). Args: theta (float): Rotation angle in degrees. size_input (np.ndarray)
(theta, size_input, size_dst, size_target)
| 304 | |
| 305 | |
| 306 | def get_warp_matrix(theta, size_input, size_dst, size_target): |
| 307 | """Calculate the transformation matrix under the constraint of unbiased. |
| 308 | Paper ref: Huang et al. The Devil is in the Details: Delving into Unbiased |
| 309 | Data Processing for Human Pose Estimation (CVPR 2020). |
| 310 | |
| 311 | Args: |
| 312 | theta (float): Rotation angle in degrees. |
| 313 | size_input (np.ndarray): Size of input image [w, h]. |
| 314 | size_dst (np.ndarray): Size of output image [w, h]. |
| 315 | size_target (np.ndarray): Size of ROI in input plane [w, h]. |
| 316 | |
| 317 | Returns: |
| 318 | matrix (np.ndarray): A matrix for transformation. |
| 319 | """ |
| 320 | theta = np.deg2rad(theta) |
| 321 | matrix = np.zeros((2, 3), dtype=np.float32) |
| 322 | scale_x = size_dst[0] / size_target[0] |
| 323 | scale_y = size_dst[1] / size_target[1] |
| 324 | matrix[0, 0] = math.cos(theta) * scale_x |
| 325 | matrix[0, 1] = -math.sin(theta) * scale_x |
| 326 | matrix[0, 2] = scale_x * (-0.5 * size_input[0] * math.cos(theta) + |
| 327 | 0.5 * size_input[1] * math.sin(theta) + |
| 328 | 0.5 * size_target[0]) |
| 329 | matrix[1, 0] = math.sin(theta) * scale_y |
| 330 | matrix[1, 1] = math.cos(theta) * scale_y |
| 331 | matrix[1, 2] = scale_y * (-0.5 * size_input[0] * math.sin(theta) - |
| 332 | 0.5 * size_input[1] * math.cos(theta) + |
| 333 | 0.5 * size_target[1]) |
| 334 | return matrix |
| 335 | |
| 336 | |
| 337 | def warp_affine_joints(joints, mat): |