Skip to content

Add native OpenCV lens-distortion rendering for the Newton renderer - #1

Draft
AntoineRichard wants to merge 1 commit into
liorbenhorin:liorbenhorin/opencv-lens-distortion-camerasfrom
AntoineRichard:liorbenhorin-newton-distortion
Draft

AntoineRichard wants to merge 1 commit into
liorbenhorin:liorbenhorin/opencv-lens-distortion-camerasfrom
AntoineRichard:liorbenhorin-newton-distortion

Conversation

@AntoineRichard

Copy link
Copy Markdown

Description

Stacked on isaac-sim#6608. That PR added the renderer-agnostic OpenCV lens-distortion camera cfg (OpenCvPinholeDistortionCfg / OpenCvFisheyeDistortionCfg on PinholeCameraCfg.distortion) and wired the RTX/OVRTX consumption path, leaving Newton as a documented no-op that warned and rendered undistorted. This PR implements the Newton consumption path so a calibrated camera reproduces in Newton the same distortion RTX already applies.

Base branch: liorbenhorin/opencv-lens-distortion-cameras (PR isaac-sim#6608) so the diff here shows only the Newton changes. Retarget to develop once isaac-sim#6608 merges.

How

Newton's tiled camera renders by tracing an explicit per-pixel ray field, so distortion is applied at ray-generation time rather than by changing Newton itself:

  • New opencv_distortion_rays.py: two @wp.kernel ray generators that invert the OpenCV forward model per output pixel — pinhole (rational radial k1..k6 + tangential p1,p2 + thin-prism s1..s4) and fisheye (equidistant k1..k4) — recovering the undistorted camera-space ray. The OpenCV→OpenGL axis conversion matches Newton's own pinhole ray kernel.
  • newton_warp_renderer.py: RenderData captures spawn.distortion and, when present, builds the distorted ray field via _build_distortion_rays(); the pinhole path is unchanged otherwise. The prior prepare_cameras warning no-op is removed.
  • apply_lens_distortion=False mutes the coefficients while keeping the calibrated fx/fy/cx/cy, matching the RTX/OVRTX behavior.

No Newton-package change and no new dependencies.

Testing

Validated end-to-end on an RTX 5090 against the Newton commit pinned in this branch:

  • test/renderers/test_opencv_distortion_rays.py — 7 kit-less CPU Warp tests (round-trip inversion vs. a NumPy forward model, off-center principal point, zero-coefficient identity).
  • test/sensors/test_camera_opencv_distortion_newton.py — 3 GPU Newton-render tests (distorted vs. muted and fisheye vs. pinhole distance_to_camera maps differ meaningfully; intrinsics readback matches the authored non-square, off-center calibration). Skips cleanly without newton/CUDA.

All 10 pass; all content pre-commit hooks pass.

Type of change

  • New feature (non-breaking change which adds functionality)

The camera OpenCV lens-distortion model (spawn.distortion) was consumed
only by the RTX/OVRTX path; the Newton warp renderer logged a warning and
rendered a centered, square-pixel pinhole. Implement the Newton path so a
calibrated camera reproduces in Newton the same distortion RTX already
applies.

Newton's tiled camera renders by tracing an explicit per-pixel ray field,
so the distortion is applied at ray-generation time: two Warp kernels
invert the OpenCV forward model (pinhole rational radial + tangential +
thin-prism, and fisheye equidistant) per output pixel to recover the
undistorted ray direction, honoring the calibrated non-square, off-center
fx/fy/cx/cy. apply_lens_distortion=False mutes the coefficients while
keeping the intrinsics, matching the RTX/OVRTX behavior. No Newton-package
change is required.
@liorbenhorin

Copy link
Copy Markdown
Owner

@AntoineRichard Let's merge this since it works and passes on my end as well - later when the Newton camera utils will get finalised we port over, but this is now being request by Lab team to include newton support as part of the PR

StafaH added a commit to isaac-sim/IsaacLab that referenced this pull request Sep 20, 2026
## Description

PR #6608 introduced renderer-agnostic OpenCV camera calibration configs
and native RTX/OVRTX rendering. The Newton path was intentionally left
as a documented no-op that emitted a warning and rendered using a
centered, square-pixel pinhole projection.

This PR completes backend parity by making `NewtonWarpRenderer` consume
the same OpenCV calibration and generate distorted per-pixel camera
rays.

## This PR adds native OpenCV lens-distortion rendering to Newton:

- **OpenCV pinhole:** Adds a Warp kernel that inverts the OpenCV forward
model per pixel using fixed-point iteration. It supports rational radial
(`k1..k6`), tangential (`p1`, `p2`), and thin-prism (`s1..s4`)
distortion - conritbuted by @AntoineRichard in
liorbenhorin#1
- **OpenCV fisheye:** Uses Newton’s native
`compute_camera_rays_fisheye_opencv` helper rather than maintaining a
duplicate Isaac Lab implementation.
- **Calibrated intrinsics:** Both paths honor `fx/fy/cx/cy`, including
non-square focal lengths and an off-center principal point.
- **Disabled distortion:** `apply_lens_distortion=False` mutes the
coefficients while retaining the calibrated intrinsics, matching
RTX/OVRTX behavior.
- **Renderer behavior:** Replaces the previous Newton warning/no-op path
with distortion-aware ray generation.
- **Tests:** Adds CPU unit tests for pinhole ray generation and CUDA
integration tests for pinhole rendering, fisheye rendering, and
intrinsic-matrix readback.

This is a stacked follow-up to #6608. It does not change the public
camera configuration or USD authoring path introduced there; it only
adds Newton renderer consumption of the existing model.

## Release backport

- [x] <!-- backport-active-release --> Backport this pull request to the
active release branch after it merges into `develop`

## Images
<img width="1920" height="2146" alt="image222"
src="https://github.com/user-attachments/assets/57764c1a-3be9-4c75-8609-62534834a465"
/>


## Checklist

- [x] I have read and understood the [contribution
guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html)
- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] I have added a changelog fragment under
`source/<pkg>/changelog.d/` for every touched package (do **not** edit
`CHANGELOG.rst` or bump `extension.toml` — CI handles that)
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there

---------

Co-authored-by: Kelly Guo <[email protected]>
Co-authored-by: Mustafa H <[email protected]>
isaaclab-bot Bot pushed a commit to isaac-sim/IsaacLab that referenced this pull request Sep 20, 2026
## Description

PR #6608 introduced renderer-agnostic OpenCV camera calibration configs
and native RTX/OVRTX rendering. The Newton path was intentionally left
as a documented no-op that emitted a warning and rendered using a
centered, square-pixel pinhole projection.

This PR completes backend parity by making `NewtonWarpRenderer` consume
the same OpenCV calibration and generate distorted per-pixel camera
rays.

## This PR adds native OpenCV lens-distortion rendering to Newton:

- **OpenCV pinhole:** Adds a Warp kernel that inverts the OpenCV forward
model per pixel using fixed-point iteration. It supports rational radial
(`k1..k6`), tangential (`p1`, `p2`), and thin-prism (`s1..s4`)
distortion - conritbuted by @AntoineRichard in
liorbenhorin#1
- **OpenCV fisheye:** Uses Newton’s native
`compute_camera_rays_fisheye_opencv` helper rather than maintaining a
duplicate Isaac Lab implementation.
- **Calibrated intrinsics:** Both paths honor `fx/fy/cx/cy`, including
non-square focal lengths and an off-center principal point.
- **Disabled distortion:** `apply_lens_distortion=False` mutes the
coefficients while retaining the calibrated intrinsics, matching
RTX/OVRTX behavior.
- **Renderer behavior:** Replaces the previous Newton warning/no-op path
with distortion-aware ray generation.
- **Tests:** Adds CPU unit tests for pinhole ray generation and CUDA
integration tests for pinhole rendering, fisheye rendering, and
intrinsic-matrix readback.

This is a stacked follow-up to #6608. It does not change the public
camera configuration or USD authoring path introduced there; it only
adds Newton renderer consumption of the existing model.

## Release backport

- [x] <!-- backport-active-release --> Backport this pull request to the
active release branch after it merges into `develop`

## Images
<img width="1920" height="2146" alt="image222"
src="https://github.com/user-attachments/assets/57764c1a-3be9-4c75-8609-62534834a465"
/>


## Checklist

- [x] I have read and understood the [contribution
guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html)
- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] I have added a changelog fragment under
`source/<pkg>/changelog.d/` for every touched package (do **not** edit
`CHANGELOG.rst` or bump `extension.toml` — CI handles that)
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there

---------

Co-authored-by: Kelly Guo <[email protected]>
Co-authored-by: Mustafa H <[email protected]>

(cherry picked from commit a68caff)

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants