r/computervision • • 15d ago

Showcase I built a 100% pure-Rust implementation of SIFT, RANSAC homography, and image stitching (zero OpenCV/C++ FFI dependencies)

Hi r/computervision,

If you have ever had to bundle OpenCV into a Docker container, deploy to an embedded target, or compile across platforms without wrestling with CMake and C++ shared library dependencies, you know how heavy the toolchain friction can be.

To make classic feature extraction lightweight and portable, I built pure-sift: an open-source, 100% pure-Rust library implementing Lowe's SIFT (Scale-Invariant Feature Transform, US6711293B1 patent expired in 2020), 2D Similarity RANSAC, 4-Point DLT Planar Homography, and an automated image stitcher with zero OpenCV or C++ dependencies.

Technical Implementation:

  • SIFT Scale Space:
    • Octave pyramid generation with separable 1D Gaussian kernels.
    • Difference-of-Gaussians (DoG) scale-space extrema detection across 26-neighborhood volumes.
    • 3D quadratic Taylor-expansion sub-pixel and sub-scale localization (< 0.12 px error).
    • Hessian edge-ratio filtering ➡️ (r <= 10.0) using the trace and determinant to discard flat edges.
    • Secondary orientation peak splitting (peaks within 80% generate extra keypoints).
    • 128-dimensional illumination-invariant gradient descriptors, parallelized via Rayon.
  • Robust Feature Matching & Geometry:
    • Lowe’s ratio test (threshold 0.75) for 128-D Euclidean nearest-neighbor matching.
    • 2-point 2D Similarity RANSAC (rotation, scale, translation).
    • 4-point Direct Linear Transform (DLT) 3x3 Homography RANSAC with horizon validation ➡️ (det(H) > 0).
    • Bilinear feather-blended panoramic stitcher.
  • Visual Catalog & Retrieval:
    • 128-bit compact Hamming binary hash index + geometric RANSAC reranking for image identification.
  • Portability:
    • Zero unsafe code (#![forbid(unsafe_code)]).
    • Core math and image processing compile cleanly with --no-default-features for embedded, static binary, or WebAssembly (WASM) environments.

Dual-licensed under MIT or Apache-2.0.

I would love to get your feedback, hear about your edge cases, and see what benchmarks you would like to see compared to OpenCV's implementation!

18 Upvotes

2 comments sorted by

2

u/loss182 9d ago

Very nice work! Tried your web demo with some agricultural drone images with low overlap (20%) and it was able to tie the images together nicely! Looking forward for the future development of this!
Later I will try to run it locally with the full resolution image to see how fast it runs

1

u/HorsePuzzleheaded803 8d ago

Thanks so much for trying it out - really awesome to hear it held up on agricultural drone imagery! Low overlap (20%) + repetitive crop textures is a genuinely tough case for feature matching, so that's great validation.

When you test the full-res images locally, definitely run a release build (cargo build --release), the web demo runs single-threaded in WASM, whereas the native CLI uses Rayon across all CPU cores (blur, extrema detection, descriptors, and matching) and should be dramatically faster.

./target/release/pure-sift align img1.jpg img2.jpg -o aligned.png

Would love to hear what timings and results you get on full-res drone frames — multi-image panorama stitching with exposure compensation and multi-band blending is also on the roadmap, so real-world drone feedback is super valuable!