feat(calib3d): implement camera undistortion, perspective warping, and fundamental matrix estimation (#76)#78
Merged
kalwalt merged 10 commits intoJul 7, 2026
Conversation
…d fundamental matrix estimation (#76) - Add init_undistort_rectify_map for radial/tangential distortion - Add find_fundamental_mat supporting FM_8POINT and FM_RANSAC with Sampson distance - Add remap and warp_perspective with bilinear/nearest interpolation - Add SIMD-accelerated remapping in SimdElement
Add rectification.rs demonstrating camera undistortion mapping and perspective warping using purecv.
7 tasks
960a538 to
9e789d6
Compare
…cation-calibration-76-undistort
kalwalt
added a commit
that referenced
this pull request
Jul 7, 2026
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request: Implement Camera Undistortion and Perspective Warping (#76)
1. PR Summary
This PR implements camera undistortion maps, generic image remapping, perspective warping, and fundamental matrix estimation in pure Rust (
purecv), utilizing Rayon-based parallelism andpulpSIMD dispatching.2. Detailed Description
Key Features Implemented:
SIMD-Accelerated Remapping (
src/core/simd.rs):simd_remap_bilinear_rowandsimd_remap_nearest_rowto theSimdElementtrait.f32,f64, andu8usingpulp::Arch::new().dispatch(...)auto-vectorization when thesimdfeature is active.Geometric Transformations (
src/imgproc/geometric.rs):remapusing Rayon-based row parallelism (par_chunks_exact_mut), falling back to scalar loops when SIMD routines are not available. It correctly interpolates borders usingborder_interpolate.warp_perspectivewith its own backward homography mapping to perform perspective transformations directly without intermediate map allocation.Camera Undistortion (
src/calib3d/undistort.rs):init_undistort_rectify_mapto compute undistortion and rectification maps (equivalent to OpenCV'sinitUndistortRectifyMap).Epipolar Geometry (
src/calib3d/fundamental.rs):find_fundamental_matsupporting two estimation methods:FundamentalMatMethod::FM_8POINT: Normalized 8-Point algorithm solving the linear systemFundamentalMatMethod::FM_RANSAC: Robust estimator selecting random samples of 8 correspondences, evaluating inliers using Sampson distance, and refitting the model using all found inliers.Example Application (
examples/rectification.rs):butterfly.jpg, compute undistortion mapping, remap, warp perspective, and save the results.3. Review Checklist
General
cargo fmt).Code Quality & Parity
PureCvError.unsafeblocks used.Testing
cargo test).4. Risk Assessment
fundamental.rs,undistort.rs,geometric.rs) accompanied by tests.5. Test Coverage
warp_perspective.remap.6. Visual Aids
Coordinate Transformation Pipeline:
graph TD A[Undistorted Pixels u, v] --> B[Normalized Space x, y] B --> C[Apply Rotation R] C --> D[Radial Distortion k1-k6] C --> E[Tangential Distortion p1-p2] D & E --> F[Distorted Space x_dist, y_dist] F --> G[Project using Camera Matrix fx, fy, cx, cy] G --> H[Final Map Coordinates map1, map2] H --> I[Remap Source Image]7. Size Recommendations
Although the PR is large (~1800 lines), it consists almost entirely of new, self-contained submodules (
geometric.rs,undistort.rs,fundamental.rs) and their corresponding tests. We recommend merging this PR in its entirety since these modules are closely coupled for camera calibration/rectification.8. Review Automation