MCPcopy
hub / github.com/zju3dv/4K4D / get_pytorch3d_camera_params

Function get_pytorch3d_camera_params

easyvolcap/utils/fcds_utils.py:207–223  ·  view source on GitHub ↗
(batch: dotdict)

Source from the content-addressed store, hash-verified

205
206
207def get_pytorch3d_camera_params(batch: dotdict):
208 # Extract pytorc3d camera parameters from batch input
209 # R and T are applied on the right (requires a transposed R from OpenCV camera format)
210 # Coordinate system is different from that of OpenCV (cv: right down front, 3d: left up front)
211 # However, the correction has to be down on both T and R... (instead of just R)
212 C = -batch.R.mT @ batch.T # B, 3, 1
213 R = batch.R.clone()
214 R[..., 0, :] *= -1 # flip x row
215 R[..., 1, :] *= -1 # flip y row
216 T = (-R @ C)[..., 0] # c2w back to w2c
217 R = R.mT # applied left (left multiply to right multiply, god knows why...)
218
219 H = batch.meta.H[0].item() # !: BATCH
220 W = batch.meta.W[0].item() # !: BATCH
221 K = get_pytorch3d_ndc_K(batch.K, H, W)
222
223 return H, W, K, R, T, C
224
225# TODO: Remove pcd_t and with_t semantics, this is a legacy API
226

Callers 4

render_pytorchMethod · 0.90
test_pytorch3d_renderingFunction · 0.90

Calls 2

get_pytorch3d_ndc_KFunction · 0.85
cloneMethod · 0.80

Tested by 3

test_pytorch3d_renderingFunction · 0.72