Skip to content

[Bug Report] Perspective-depth conversion ignores camera intrinsic skew #9236

Backlog

Description

@sylvesterkaczmarek

Describe the bug

orthogonalize_perspective_depth uses focal lengths and principal points but ignores the skew entry K[0, 1]. For a conventional upper-triangular calibration matrix with nonzero skew, the normalized camera ray is consequently wrong. This also affects unproject_depth(..., is_ortho=False), which relies on this conversion.

Reproduction

import torch
from isaaclab.utils.math import orthogonalize_perspective_depth

depth = torch.ones((3, 4), dtype=torch.float64)
K = torch.tensor([[4., 1.5, 0.7], [0., 3., 1.], [0., 0., 1.]], dtype=torch.float64)
u, v = torch.meshgrid(torch.arange(4, dtype=depth.dtype), torch.arange(3, dtype=depth.dtype), indexing='xy')
pixels = torch.stack((u, v, torch.ones_like(u))).reshape(3, -1)
rays = torch.linalg.solve(K, pixels)
expected = (rays[2] / torch.linalg.vector_norm(rays, dim=0)).reshape_as(depth)
torch.testing.assert_close(orthogonalize_perspective_depth(depth, K), expected)

Expected: orthogonal depth equals perspective range times the normalized ray's optical-axis component. The existing calculation is correct for zero-skew intrinsics but fails this check for nonzero skew.

System Info

main at 3dbc052, macOS ARM64, Python 3.12, PyTorch 2.12.0. CPU reproduction without Isaac Sim.

Additional context

Recover the normalized y coordinate first, then subtract the skew contribution when recovering x. No matrix inverse or additional dependency is needed. A batched regression uses an independent NumPy linear-system reference for both skewed and zero-skew intrinsics. It fails on main and passes after the correction; the full math test file reports 123 passed, 3 skipped.

Checklist

  • Checked for similar issues and open PRs.
  • Reproduced without Isaac Sim.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions