Transform cameras using an SE(3) matrix. Args: matrix: 4x4 SE(3) matrix camtoworlds: Nx4x4 array of camera-to-world matrices Returns: Nx4x4 array of transformed camera-to-world matrices
(matrix, camtoworlds)
| 113 | |
| 114 | |
| 115 | def transform_cameras(matrix, camtoworlds): |
| 116 | """Transform cameras using an SE(3) matrix. |
| 117 | |
| 118 | Args: |
| 119 | matrix: 4x4 SE(3) matrix |
| 120 | camtoworlds: Nx4x4 array of camera-to-world matrices |
| 121 | |
| 122 | Returns: |
| 123 | Nx4x4 array of transformed camera-to-world matrices |
| 124 | """ |
| 125 | assert matrix.shape == (4, 4) |
| 126 | assert len(camtoworlds.shape) == 3 and camtoworlds.shape[1:] == (4, 4) |
| 127 | camtoworlds = np.einsum("nij, ki -> nkj", camtoworlds, matrix) |
| 128 | scaling = np.linalg.norm(camtoworlds[:, 0, :3], axis=1) |
| 129 | camtoworlds[:, :3, :3] = camtoworlds[:, :3, :3] / scaling[:, None, None] |
| 130 | return camtoworlds |
| 131 | |
| 132 | |
| 133 | def normalize(camtoworlds, points=None): |