This function convert the pose encoding into `intrinsic` and `extrinsic` Args: poses_pred: B T 8 Return: Intrinsic B T 3 3 Extrinsic B T 4 4
(poses_pred,
H_resize, W_resize, resolution=336)
| 964 | |
| 965 | |
| 966 | def pose_enc2mat(poses_pred, |
| 967 | H_resize, W_resize, resolution=336): |
| 968 | """ |
| 969 | This function convert the pose encoding into `intrinsic` and `extrinsic` |
| 970 | |
| 971 | Args: |
| 972 | poses_pred: B T 8 |
| 973 | Return: |
| 974 | Intrinsic B T 3 3 |
| 975 | Extrinsic B T 4 4 |
| 976 | """ |
| 977 | B, T, _ = poses_pred.shape |
| 978 | focal_pred = poses_pred[:, :, -1].clone() |
| 979 | pos_quat_preds = poses_pred[:, :, :7].clone() |
| 980 | pos_quat_preds = pos_quat_preds.view(B*T, -1) |
| 981 | # get extrinsic |
| 982 | c2w_rot = quaternion_to_matrix(pos_quat_preds[:, 3:]) |
| 983 | c2w_tran = pos_quat_preds[:, :3] |
| 984 | c2w_traj = torch.eye(4)[None].repeat(B*T, 1, 1).to(poses_pred.device) |
| 985 | c2w_traj[:, :3, :3], c2w_traj[:, :3, 3] = c2w_rot, c2w_tran |
| 986 | c2w_traj = c2w_traj.view(B, T, 4, 4) |
| 987 | # get intrinsic |
| 988 | fxs, fys = focal_pred*resolution, focal_pred*resolution |
| 989 | intrs = torch.eye(3).to(c2w_traj.device).to(c2w_traj.dtype)[None, None].repeat(B, T, 1, 1) |
| 990 | intrs[:,:,0,0], intrs[:,:,1,1] = fxs, fys |
| 991 | intrs[:,:,0,2], intrs[:,:,1,2] = W_resize/2, H_resize/2 |
| 992 | |
| 993 | return intrs, c2w_traj |
| 994 | |
| 995 | def _sqrt_positive_part(x: torch.Tensor) -> torch.Tensor: |
| 996 | """ |
no test coverage detected