map points from ii->jj
(
poses, depths, intrinsics, ii, jj, jacobian=False, return_depth=False
)
| 360 | return intrinsics[...,None,None,:].unbind(dim=-1) |
| 361 | |
| 362 | def 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 | |
| 398 | def induced_flow(poses, disps, intrinsics, ii, jj): |
no test coverage detected