MCPcopy Create free account
hub / github.com/Robbyant/lingbot-map / projective_transform

Function projective_transform

lingbot_map/utils/geometry.py:362–395  ·  view source on GitHub ↗

map points from ii->jj

(
    poses, depths, intrinsics, ii, jj, jacobian=False, return_depth=False
)

Source from the content-addressed store, hash-verified

360 return intrinsics[...,None,None,:].unbind(dim=-1)
361
362def projective_transform(
363 poses, depths, intrinsics, ii, jj, jacobian=False, return_depth=False
364):
365 """map points from ii->jj"""
366
367 # inverse project (pinhole)
368 X0, Jz = iproj(depths[:, ii], intrinsics[:, ii], jacobian=jacobian)
369
370 # transform
371 Gij = poses[:, jj] * poses[:, ii].inv()
372
373 # Gij.data[:, ii == jj] = torch.as_tensor(
374 # [-0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0], device="cuda"
375 # )
376 X1, Ja = actp(Gij, X0, jacobian=jacobian)
377
378 # project (pinhole)
379 x1, Jp = proj(X1, intrinsics[:, jj], jacobian=jacobian, return_depth=return_depth)
380
381 # exclude points too close to camera
382 valid = ((X1[..., 2] > MIN_DEPTH) & (X0[..., 2] > MIN_DEPTH)).float()
383 valid = valid.unsqueeze(-1)
384
385 if jacobian:
386 # Ji transforms according to dual adjoint
387 Jj = torch.matmul(Jp, Ja)
388 Ji = -Gij[:, :, None, None, None].adjT(Jj)
389
390 Jz = Gij[:, :, None, None] * Jz
391 Jz = torch.matmul(Jp, Jz.unsqueeze(-1))
392
393 return x1, valid, (Ji, Jj, Jz)
394
395 return x1, valid
396
397
398def induced_flow(poses, disps, intrinsics, ii, jj):

Callers 1

induced_flowFunction · 0.85

Calls 3

iprojFunction · 0.85
actpFunction · 0.85
projFunction · 0.85

Tested by

no test coverage detected