Skip to content

Commit 42434f9

Browse files
committed
Better rust-doc.
Now discarding images in keypoint_match() if no proper homography is found. keypoint_match() also reports number of skipped images.
1 parent 295eaea commit 42434f9

File tree

3 files changed

+514
-223
lines changed

3 files changed

+514
-223
lines changed

examples/main.rs

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,37 @@ fn main() -> Result<(), StackerError> {
6969
libstacker::KeyPointMatchParameters {
7070
method: opencv::calib3d::RANSAC,
7171
ransac_reproj_threshold: 5.0,
72+
match_ratio: 0.9,
73+
match_keep_ratio: 0.80,
74+
border_mode: opencv::core::BORDER_CONSTANT,
75+
border_value: opencv::core::Scalar::default(),
7276
},
7377
None,
74-
//Some(720.0),
7578
)?;
76-
println!("Calculated keypoint_match() in {:?}", now.elapsed());
79+
let keypoint_match_img_duration = now.elapsed();
80+
println!(
81+
"Calculated keypoint_match() in {:?} dropped frames:{}",
82+
keypoint_match_img_duration, keypoint_match_img.0
83+
);
7784

7885
let now = std::time::Instant::now();
7986
let keypoint_match_img_400 = keypoint_match(
8087
&files,
8188
libstacker::KeyPointMatchParameters {
8289
method: opencv::calib3d::RANSAC,
8390
ransac_reproj_threshold: 5.0,
91+
match_ratio: 0.9,
92+
match_keep_ratio: 0.80,
93+
border_mode: opencv::core::BORDER_CONSTANT,
94+
border_value: opencv::core::Scalar::default(),
8495
},
8596
Some(400.0),
8697
)?;
87-
println!("Calculated keypoint_match(width=400) in {:?}", now.elapsed());
98+
let keypoint_match_400_img_duration = now.elapsed();
99+
println!(
100+
"Calculated keypoint_match(width=400) in {:?} dropped frames:{}",
101+
keypoint_match_400_img_duration, keypoint_match_img_400.0
102+
);
88103

89104
let now = std::time::Instant::now();
90105
let ecc_match_img = libstacker::ecc_match(
@@ -97,7 +112,8 @@ fn main() -> Result<(), StackerError> {
97112
},
98113
None,
99114
)?;
100-
println!("Calculated ecc_match() in {:?}", now.elapsed());
115+
let ecc_match_img_duration = now.elapsed();
116+
println!("Calculated ecc_match() in {:?}", ecc_match_img_duration);
101117

102118
let now = std::time::Instant::now();
103119
let ecc_match_img_400 = libstacker::ecc_match(
@@ -110,13 +126,37 @@ fn main() -> Result<(), StackerError> {
110126
},
111127
Some(400.0),
112128
)?;
113-
println!("Calculated ecc_match(width=400) in {:?}", now.elapsed());
129+
let ecc_match_400_img_duration = now.elapsed();
130+
println!(
131+
"Calculated ecc_match(width=400) in {:?}",
132+
ecc_match_400_img_duration
133+
);
114134

115135
while highgui::wait_key(33)? != 27 {
116-
highgui::imshow("KeyPoint match", &keypoint_match_img)?;
117-
highgui::imshow("ECC match", &ecc_match_img)?;
118-
highgui::imshow("KeyPoint match width 400", &keypoint_match_img_400)?;
119-
highgui::imshow("ECC match width 400", &ecc_match_img_400)?;
136+
highgui::imshow(
137+
format!(
138+
"KeyPoint match (full resolution) [{:?}]",
139+
keypoint_match_img_duration
140+
)
141+
.as_str(),
142+
&keypoint_match_img.1,
143+
)?;
144+
highgui::imshow(
145+
format!("ECC match (full resolution) [{:?}]", ecc_match_img_duration).as_str(),
146+
&ecc_match_img,
147+
)?;
148+
highgui::imshow(
149+
format!(
150+
"KeyPoint match (width 400) [{:?}]",
151+
keypoint_match_400_img_duration
152+
)
153+
.as_str(),
154+
&keypoint_match_img_400.1,
155+
)?;
156+
highgui::imshow(
157+
format!("ECC match (width 400) [{:?}]", ecc_match_400_img_duration).as_str(),
158+
&ecc_match_img_400,
159+
)?;
120160
}
121161
Ok(())
122162
}

0 commit comments

Comments
 (0)