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
//! The one interface every geometry stage reads correspondences through.
//!
//! In the pipeline the correspondences come from pixelmap. In tests they come from
//! [`crate::synthetic`], which knows the exact answer. Keeping the stages behind this
//! trait is what lets them be tested against ground truth, with the matcher's own
//! limitations taken out of the picture.
use cratePhotoPx;
/// A dense mapping between the two photos of a pair, in [`PhotoPx`] coordinates.
///
/// This is how [`reconstruct`](crate::reconstruct) takes correspondences that did not come
/// from pixelmap. pixelmap's [`Correspondence`](pixelmap::Correspondence) implements it,
/// and that is what [`run`](crate::run) uses.
///
/// # The contract
///
/// - Every point is in the pixels of the photos handed to the pipeline, x to the right and
/// y down, as [`PhotoPx`] describes.
/// - `a_to_b` and `b_to_a` describe one mapping read in two directions, and should agree:
/// a point taken across and back should land near where it started. Where they do not,
/// return `None` rather than a guess. Every stage treats `None` as "no information",
/// and a wrong match does more harm than a missing one.
/// - [`Self::precision_px`] scales every inlier threshold, so it should be honest. Too
/// small rejects good geometry; too large lets bad geometry through.
///
/// ```
/// use pixelmap_multiview::{PairLookup, PhotoPx};
///
/// /// The second photo is the first shifted 12 px to the left.
/// struct Shift;
///
/// impl PairLookup for Shift {
/// fn a_to_b(&self, p: PhotoPx) -> Option<PhotoPx> {
/// Some(PhotoPx::new(p.x() - 12.0, p.y()))
/// }
/// fn b_to_a(&self, p: PhotoPx) -> Option<PhotoPx> {
/// Some(PhotoPx::new(p.x() + 12.0, p.y()))
/// }
/// fn coverage(&self) -> f32 {
/// 1.0
/// }
/// fn native_stride(&self) -> f32 {
/// 4.0
/// }
/// fn precision_px(&self) -> f32 {
/// 0.5
/// }
/// }
/// ```
// A method added here must have a default body, or every implementation outside this
// crate stops compiling.
/// A pair's mapping read in a chosen direction.
///
/// Mappings are stored once per pair, from the lower view id to the higher. This turns
/// one around when a stage needs the other direction.