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
use serde::{Deserialize, Serialize};
/// Configuration for self-undistort estimation.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default)]
pub struct SelfUndistortConfig {
/// Enable self-undistort refinement.
pub enable: bool,
/// Search range for lambda: [lambda_min, lambda_max].
pub lambda_range: [f64; 2],
/// Maximum function evaluations for the 1D optimizer.
pub max_evals: usize,
/// Minimum number of markers with both inner+outer edge points required.
pub min_markers: usize,
/// Relative improvement threshold: accept only if
/// `(baseline - optimum) / baseline > improvement_threshold`.
pub improvement_threshold: f64,
/// Minimum absolute objective improvement required to apply the model.
///
/// This prevents applying when the objective is near numerical noise floor.
pub min_abs_improvement: f64,
/// Trim fraction for robust aggregation of per-marker objective values.
///
/// `0.1` means drop 10% low and 10% high scores before averaging.
pub trim_fraction: f64,
/// Minimum |lambda| required for applying the model.
///
/// Very small lambda values are effectively identity and are treated as
/// "no correction" even if relative improvement is non-zero.
pub min_lambda_abs: f64,
/// Reject solutions that land too close to lambda-range boundaries.
pub reject_range_edge: bool,
/// Relative margin of the lambda range treated as unstable boundary area.
pub range_edge_margin_frac: f64,
/// Minimum decoded-ID correspondences needed for homography validation.
pub validation_min_markers: usize,
/// Minimum absolute homography self-error improvement (pixels) required.
pub validation_abs_improvement_px: f64,
/// Minimum relative homography self-error improvement required.
pub validation_rel_improvement: f64,
}
impl Default for SelfUndistortConfig {
fn default() -> Self {
Self {
enable: false,
lambda_range: [-8e-7, 8e-7],
max_evals: 40,
min_markers: 6,
improvement_threshold: 0.01,
min_abs_improvement: 1e-4,
trim_fraction: 0.1,
min_lambda_abs: 5e-9,
reject_range_edge: true,
range_edge_margin_frac: 0.02,
validation_min_markers: 24,
validation_abs_improvement_px: 0.05,
validation_rel_improvement: 0.03,
}
}
}