Skip to content

Add OpenCV-style calib3d module scaffold for Milestone 4#52

Merged
kalwalt merged 9 commits intodevfrom
copilot/implement-functions-milestone-4
May 8, 2026
Merged

Add OpenCV-style calib3d module scaffold for Milestone 4#52
kalwalt merged 9 commits intodevfrom
copilot/implement-functions-milestone-4

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 7, 2026

Description

This PR integrates the new calib3d module, fulfilling Milestone 4 requirements. It introduces functions for camera calibration and 3D geometry processing.

Key Additions

  • Pose Estimation: Iterative DLT with Gauss-Newton refinement (solve_pnp) and RANSAC-based robust estimation (solve_pnp_ransac).
  • Homography: Direct Linear Transformation (DLT) mapped robustly with RANSAC support (find_homography).
  • Geometry Operations: Conversion between rotation vectors and rotation matrices via rodrigues.
  • Linear Algebra: Implements SVD, null-space evaluation, matrix inverses, and pseudo-random number generation via linalg.rs.

Fixes & Improvements Addressed from Review

  • 🛠️ Error Handling Reordering: Prioritized input length validation over minimum point counts to provide clearer error reporting.
  • 🛠️ Numerical Stability: Re-enforced 6-point minimum bounds for DLT PnP calculations to prevent non-unique null space solutions from 4-point underdetermined systems.
  • 🛠️ Focal Length Scaling: Fixed reprojection threshold calculations in RANSAC to normalize thresholds by dividing by focal lengths, rendering them intrinsic-agnostic.
  • 🛠️ Inversion Check: Updated undistort_points to handle mat3_inv singularity and return proper errors rather than silently falling back.
  • ✅ Added comprehensive unit tests to src/calib3d/tests.rs covering SVD, homography, and PnP functionality.
  • ✅ Updated src/lib.rs prelude to export the new calib3d module and Point3f.
  • ✅ Passes cargo fmt and cargo clippy with zero warnings.
  • ✅ All 259 unit tests and 28 documentation tests pass successfully.

Closes #51

@kalwalt
Copy link
Copy Markdown
Member

kalwalt commented May 7, 2026

@copilot create a new module section called calib3d as in OpenCV.

Copilot AI and others added 2 commits May 7, 2026 13:56
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 7, 2026

@copilot create a new module section called calib3d as in OpenCV.

Done: I added a new top-level calib3d module section (OpenCV-style) and structured it with mod.rs, tests.rs, and simd.rs, exported from lib.rs. Addressed in commit 5322aba.

Copilot AI changed the title [WIP] Implement functions for Milestone 4: findHomography, Rodrigues, solvePnP, solvePnPRansac [WIP] Add OpenCV-style calib3d module scaffold for Milestone 4 May 7, 2026
Copilot finished work on behalf of kalwalt May 7, 2026 14:01
@kalwalt kalwalt changed the base branch from main to dev May 7, 2026 19:44
Copilot AI and others added 2 commits May 7, 2026 20:01
Copilot finished work on behalf of kalwalt May 7, 2026 20:07
@kalwalt kalwalt marked this pull request as ready for review May 8, 2026 13:26
@kalwalt kalwalt added calib3d-module enhancement New feature or request rust-code rust Pull requests that update rust code tests labels May 8, 2026
@kalwalt kalwalt changed the title [WIP] Add OpenCV-style calib3d module scaffold for Milestone 4 Add OpenCV-style calib3d module scaffold for Milestone 4 May 8, 2026
Copy link
Copy Markdown
Member

@kalwalt kalwalt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ready to be merged

@kalwalt kalwalt requested a review from Copilot May 8, 2026 16:06
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new OpenCV-style calib3d module to purecv, providing initial pure-Rust implementations for homography estimation, Rodrigues conversions, and PnP pose estimation (including RANSAC), plus tests and an example for Milestone 4.

Changes:

  • Introduces src/calib3d.rs with submodules for homography, geometry, pose, and internal linalg helpers.
  • Exposes find_homography, rodrigues, solve_pnp, and solve_pnp_ransac via the crate prelude.
  • Adds unit tests and a runnable pose-estimation example.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
src/lib.rs Registers calib3d module and re-exports new APIs + Point3f in the prelude.
src/calib3d.rs New top-level calib3d module entry point with submodules and re-exports.
src/calib3d/geometry.rs Implements rodrigues and rotation-vector/matrix conversions.
src/calib3d/homography.rs Implements find_homography via normalized DLT + optional RANSAC.
src/calib3d/linalg.rs Adds internal linear algebra helpers (Jacobi eigen, null-space, 3×3 SVD, RNG).
src/calib3d/pose.rs Implements solve_pnp and solve_pnp_ransac with DLT init + Gauss-Newton refinement.
src/calib3d/simd.rs Adds a placeholder module doc for future SIMD helpers (feature-gated).
src/calib3d/tests.rs Adds unit tests covering linalg, Rodrigues, homography, and PnP.
examples/pose_estimation.rs Adds an example demonstrating solve_pnp + rodrigues usage.

Comment thread src/calib3d/pose.rs
Comment thread src/calib3d/pose.rs Outdated
Comment thread src/calib3d/pose.rs Outdated
Comment thread src/calib3d/pose.rs
Comment thread src/calib3d/pose.rs
Comment thread src/calib3d/pose.rs
Comment thread src/calib3d/homography.rs Outdated
Comment thread src/calib3d/pose.rs Outdated
Comment thread src/calib3d/pose.rs
Comment thread src/calib3d/pose.rs Outdated
kalwalt added 2 commits May 8, 2026 18:57
- Add robust error handling and strict flag checks in PnP
- Enforce 6-point minimum bounds for DLT PnP
- Normalize reprojection thresholds by focal lengths
- Improve singular matrix handling in undistort_points
- Add tests covering SVD, homography, and PnP functionality

Closes #51
@kalwalt kalwalt merged commit 6918fd9 into dev May 8, 2026
3 checks passed
@kalwalt kalwalt deleted the copilot/implement-functions-milestone-4 branch May 9, 2026 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

calib3d-module enhancement New feature or request rust Pull requests that update rust code rust-code tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement functions for Milestone 4: findHomography, Rodrigues, solvePnP, solvePnPRansac

3 participants