MCPcopy Create free account
hub / github.com/JasonLSC/GSCodec_Studio / transform_cameras

Function transform_cameras

examples/datasets/normalize.py:115–130  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

113
114
115def 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
133def normalize(camtoworlds, points=None):

Callers 3

__init__Method · 0.85
normalizeFunction · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected