$ show danini/magsac
MAGSAC is a C++ library with Python bindings (pymagsac) implementing robust model fitting algorithms for computer vision, including homography, fundamental matrix, essential matrix, rigid transformation, and 2D line estimation. The core algorithm is a template class `MAGSAC<DatumType, ModelEstimator>` that supports sigma-consensus and MAGSAC++ scoring, with interchangeable sampling strategies (uniform, PROSAC, P-NAPSAC, NG-RANSAC, AR-Sampler) and adaptive inlier selection. The Python API mirrors the C++ functionality via pybind11, accepting numpy arrays for point correspondences and returning estimated models with inlier masks. The repository also includes benchmark datasets and Jupyter notebook examples demonstrating usage. While the library is primarily a software package, it contains research-grade data and notebooks, giving it a hybrid character. The code is well-architected with clean separation of concerns, though it has minor maintenance risks such as memory management caveats and limited platform support (Linux/Windows only).
The LLM identified 4 files worth highlighting for reuse:
Core template class `MAGSAC` that implements the MAGSAC and MAGSAC++ algorithms. It is parameterized on datum type and model estimator, making it reusable across different geometric problems (homography, fundamental matrix, etc.). The class encapsulates sigma-consensus scoring, iterative refinement, and sampler management. This component is self-contained and could be extracted for other robust estimation tasks with minimal modification.
Adaptive inlier selector that determines the optimal inlier set without a fixed threshold, based on the concept of most similar points. It is a standalone algorithm that can be reused in any robust estimation pipeline where threshold-free inlier selection is desired.
Defines `ModelScore` struct for storing scoring metrics (e.g., inlier count, residual distribution) used during sigma-consensus. This is a lightweight, reusable component that can be adapted for custom scoring functions in other estimation frameworks.
Pybind11 bindings exposing the C++ MAGSAC functions to Python. Demonstrates clean mapping of numpy arrays to C++ vectors and provides a reusable pattern for wrapping template-heavy C++ libraries for Python consumption.