Convert quaternion and translation to transformation matrix.
(inputs)
| 55 | return rot |
| 56 | |
| 57 | def get_camera_from_tensor(inputs): |
| 58 | """ |
| 59 | Convert quaternion and translation to transformation matrix. |
| 60 | |
| 61 | """ |
| 62 | if not isinstance(inputs, torch.Tensor): |
| 63 | inputs = torch.tensor(inputs).cuda() |
| 64 | |
| 65 | N = len(inputs.shape) |
| 66 | if N == 1: |
| 67 | inputs = inputs.unsqueeze(0) |
| 68 | # quad, T = inputs[:, :4], inputs[:, 4:] |
| 69 | # # normalize quad |
| 70 | # quad = F.normalize(quad) |
| 71 | # R = quad2rotation(quad) |
| 72 | # RT = torch.cat([R, T[:, :, None]], 2) |
| 73 | # # Add homogenous row |
| 74 | # homogenous_row = torch.tensor([0, 0, 0, 1]).cuda() |
| 75 | # RT = torch.cat([RT, homogenous_row[None, None, :].repeat(N, 1, 1)], 1) |
| 76 | # if N == 1: |
| 77 | # RT = RT[0] |
| 78 | # return RT |
| 79 | |
| 80 | quad, T = inputs[:, :4], inputs[:, 4:] |
| 81 | w2c = torch.eye(4).to(inputs).float() |
| 82 | w2c[:3, :3] = quad2rotation(quad) |
| 83 | w2c[:3, 3] = T |
| 84 | return w2c |
| 85 | |
| 86 | def quadmultiply(q1, q2): |
| 87 | """ |
no test coverage detected