1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
//! # Inlier - Robust Estimation with RANSAC
//!
//! `inlier` is a Rust port of the C++ SupeRANSAC library, providing robust estimation
//! algorithms for geometric models using RANSAC and its variants.
//!
//! ## Quick Start
//!
//! The easiest way to use `inlier` is through the high-level API functions:
//!
//! ```rust
//! use inlier::{estimate_homography, RansacSettings};
//! use nalgebra::DMatrix;
//!
//! // Create point correspondences
//! let points1 = DMatrix::from_row_slice(4, 2, &[0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0]);
//! let points2 = DMatrix::from_row_slice(4, 2, &[1.0, 1.0, 2.0, 1.0, 2.0, 2.0, 1.0, 2.0]);
//!
//! // Estimate homography
//! let result = estimate_homography(&points1, &points2, 1.0, None).unwrap();
//! println!("Found {} inliers", result.inliers.len());
//! ```
//!
//! ## Extending the Library
//!
//! `inlier` is designed to be extensible. You can implement custom estimators, samplers,
//! scoring strategies, optimizers, and more by implementing the provided traits.
//!
//! ### Core Extension Traits
//!
//! The library is built around several key traits that you can implement:
//!
//! - **[`Estimator`](core::Estimator)**: Implement this to add support for new geometric models
//! - **[`Sampler`](core::Sampler)**: Implement this to create custom sampling strategies
//! - **[`Scoring<M>`](core::Scoring)**: Implement this to define custom scoring methods
//! - **[`LocalOptimizer<M, S>`](core::LocalOptimizer)**: Implement this for custom optimization strategies
//! - **[`TerminationCriterion<S>`](core::TerminationCriterion)**: Implement this for custom stopping criteria
//! - **[`InlierSelector<M>`](core::InlierSelector)**: Implement this for custom inlier pre-selection
//! - **[`NeighborhoodGraph`](samplers::NeighborhoodGraph)**: Implement this for spatial neighborhood structures
//!
//! ### Example: Custom Estimator
//!
//! ```rust
//! use inlier::core::Estimator;
//! use inlier::types::DataMatrix;
//!
//! // Define your model type
//! #[derive(Clone)]
//! struct MyModel {
//! // Your model parameters
//! }
//!
//! // Implement the Estimator trait
//! struct MyEstimator;
//!
//! impl Estimator for MyEstimator {
//! type Model = MyModel;
//!
//! fn sample_size(&self) -> usize {
//! 3 // Minimum number of points needed
//! }
//!
//! fn is_valid_sample(&self, data: &DataMatrix, sample: &[usize]) -> bool {
//! // Check if the sample is geometrically valid
//! sample.len() >= self.sample_size()
//! }
//!
//! fn estimate_model(&self, data: &DataMatrix, sample: &[usize]) -> Vec<Self::Model> {
//! // Estimate model from minimal sample
//! vec![MyModel {}]
//! }
//!
//! fn is_valid_model(
//! &self,
//! model: &Self::Model,
//! data: &DataMatrix,
//! sample: &[usize],
//! threshold: f64,
//! ) -> bool {
//! // Validate the estimated model
//! true
//! }
//! }
//! ```
//!
//! ### Example: Custom Sampler
//!
//! ```rust
//! use inlier::core::Sampler;
//! use inlier::types::DataMatrix;
//!
//! struct MySampler {
//! // Your sampler state
//! }
//!
//! impl Sampler for MySampler {
//! fn sample(
//! &mut self,
//! data: &DataMatrix,
//! sample_size: usize,
//! out_indices: &mut [usize],
//! ) -> bool {
//! // Implement your sampling strategy
//! // Return true if successful, false otherwise
//! true
//! }
//!
//! fn update(
//! &mut self,
//! sample: &[usize],
//! sample_size: usize,
//! iteration: usize,
//! score_hint: f64,
//! ) {
//! // Update sampler state based on iteration results
//! }
//! }
//! ```
//!
//! ### Example: Custom Scoring
//!
//! ```rust
//! use inlier::core::Scoring;
//! use inlier::types::DataMatrix;
//!
//! struct MyModel {
//! // Your model
//! }
//!
//! #[derive(Clone, PartialOrd, PartialEq)]
//! struct MyScore(f64);
//!
//! struct MyScoring {
//! threshold: f64,
//! }
//!
//! impl Scoring<MyModel> for MyScoring {
//! type Score = MyScore;
//!
//! fn threshold(&self) -> f64 {
//! self.threshold
//! }
//!
//! fn score(
//! &self,
//! data: &DataMatrix,
//! model: &MyModel,
//! inliers_out: &mut Vec<usize>,
//! ) -> Self::Score {
//! // Compute score and populate inliers
//! MyScore(0.0)
//! }
//! }
//! ```
//!
//! ## Modules
//!
//! - **[`api`](api)**: High-level API functions for common estimation tasks
//! - **[`core`](core)**: Core traits and the main `SuperRansac` pipeline
//! - **[`estimators`](estimators)**: Built-in estimators for geometric models
//! - **[`samplers`](samplers)**: Built-in sampling strategies
//! - **[`scoring`](scoring)**: Built-in scoring strategies
//! - **[`models`](models)**: Geometric model types
//! - **[`settings`](settings)**: Configuration types for RANSAC pipelines
//! - **[`bundle_adjustment`](bundle_adjustment)**: Numerical optimization routines
// Re-export high-level API
pub use ;
// Re-export core traits for easy access
pub use ;
// Re-export settings for convenience
pub use RansacSettings;