Skip to content

Commit 3804aae

Browse files
committed
minor adjustments to pipeline
1 parent 5a2852c commit 3804aae

File tree

5 files changed

+59
-55
lines changed

5 files changed

+59
-55
lines changed

examples/ba/olsson.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ fn main() -> Result<()> {
2828
let ahlströmer = "Jonas_Ahlströmer";
2929
let fountain = "fountain";
3030
let vasa = "vasa_statue"; // transposed features
31-
let ninjo = "nijo";
31+
let nijo = "nijo";
3232
let de_guerre = "de_guerre";
3333
let fort_channing = "Fort_Channing_gate";
3434
let park_gate = "park_gate";
3535
let kronan = "kronan";
3636
let round_church = "round_church";
3737

38-
let olsen_dataset_name = fort_channing;
38+
let olsen_dataset_name = fountain;
3939
let olsen_data_path = format!("{}/Olsson/{}/",runtime_conf.dataset_path,olsen_dataset_name);
4040

4141
let feature_skip_count = 1;
@@ -67,10 +67,14 @@ fn main() -> Result<()> {
6767
// let paths = vec!(vec!(5,6));
6868
// let root_id = 4;
6969

70-
// fountain
70+
// nijo
7171
// let paths = vec!(vec!(5,6,7,8));
7272
// let root_id = 4;
7373

74+
// fountain
75+
let paths = vec!(vec!(5,6,7,8));
76+
let root_id = 4;
77+
7478
// park gate
7579
// let paths = vec!(vec!(5,6,7,8));
7680
// let root_id = 4;
@@ -85,18 +89,18 @@ fn main() -> Result<()> {
8589
// let root_id = 4;
8690

8791
// Fort Channing
88-
let paths = vec!(vec!(8,10));
89-
let root_id = 7;
92+
// let paths = vec!(vec!(8,10));
93+
// let root_id = 7;
9094

91-
// Round Church
92-
// let paths = vec!(vec!(7,8,10,11,12,13,14,15,16));
95+
// // Round Church
96+
// let paths = vec!(vec!(7,8,10,11,12,13));
9397
// let root_id = 5;
9498

9599

96100
//TODO: implement switch for loftr matches!
97101
let (match_map, camera_map, image_width, image_height) = olsen_data.get_data_for_sfm(root_id, &paths, positive_principal_distance, invert_focal_length, invert_y, transpose_features, feature_skip_count, olsen_dataset_name);
98102
let mut ba_config_fundamental = BAConfig::new(root_id, &paths, None, camera_map, &match_map,
99-
BifocalType::FUNDAMENTAL, Triangulation::LOST, 1.0, 2.0e0, false, image_width, image_height);
103+
BifocalType::FUNDAMENTAL, Triangulation::LOST, 1.0, 1.0e0, image_width, image_height);
100104
let mut ba_config_fundamental = filter_config(&mut ba_config_fundamental,1e5, false, refince_rotation_via_rcd, Triangulation::LOST);
101105

102106
for (key, pose) in ba_config_fundamental.pose_map().iter() {

examples/ba/synthetic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ fn main() -> Result<()> {
120120

121121
//TODO: Add GT Landmarks
122122
let mut ba_config_fundamental = BAConfig::new(root_id, &paths, pose_map_gt_option , camera_map, &match_map,
123-
BifocalType::FUNDAMENTAL, Triangulation::LOST, 1.0, 2e0, false, image_width, image_height);
123+
BifocalType::FUNDAMENTAL, Triangulation::LOST, 1.0, 1e0, image_width, image_height);
124124
let mut sfm_config_fundamental = filter_config(&mut ba_config_fundamental, 3e5, false, true, Triangulation::LOST);
125125

126126
let initial_z = sfm_config_fundamental.pose_map().get(&camera_id_pairs[0]).unwrap().translation.z;

src/image/pyramid/ba/ba_octave.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

22
use std::collections::HashMap;
3-
use plotters::coord::combinators::IntoLinspace;
43

54
use crate::image::features::Feature;
65

src/sfm/bundle_adjustment/ba_config/filtering.rs

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -93,47 +93,54 @@ pub fn filter_config<C: Camera<Float> + Clone, Feat: Feature> (
9393
println!("After DUAL Outlier: SFM Config Max Reprojection Error 2): {}, Min Reprojection Error: {}", max_reprojection_error_outlier_dual, min_reprojection_error_outlier_dual);
9494
}
9595

96-
if refine_rotation_via_rcd {
97-
let new_pose_map = refine_rotation_by_rcd(root, &paths, &pose_map);
98-
let path_pairs = conversions::compute_path_id_pairs(root, &paths);
99-
let mut new_landmark_map = compute_landmark_maps(&path_pairs, &new_pose_map, &match_map, &camera_map, triangulation);
100-
let mut new_reprojection_error_map =
101-
compute_reprojection_maps(
102-
&path_pairs,
103-
&new_landmark_map,
104-
&new_pose_map,
105-
&match_norm_map,
106-
&camera_norm_map
107-
);
108-
let keys = landmark_map.keys().map(|k| *k).collect::<Vec<_>>();
109-
for key in keys {
110-
let new_reprojection_errors = new_reprojection_error_map.get(&key).unwrap();
111-
let current_reprojection_errors = reprojection_error_map.get_mut(&key).unwrap();
112-
113-
if new_reprojection_errors.mean() < current_reprojection_errors.mean() {
114-
landmark_map.insert(key, new_landmark_map.remove(&key).unwrap());
115-
reprojection_error_map
116-
.insert(key, new_reprojection_error_map.remove(&key).unwrap());
117-
pose_map.insert(key, new_pose_map.get(&key).unwrap().clone());
118-
}
119-
}
120-
abs_pose_map = conversions::compute_absolute_poses_for_root(root, &paths_pairs, &pose_map);
121-
if run_outlier_detection_pipeline {
122-
let new_rejected_camera_ids = reject_landmark_outliers(
123-
&mut landmark_map,
124-
&mut reprojection_error_map,
125-
&mut match_map,
126-
&mut match_norm_map,
127-
landmark_cutoff_thresh,
128-
);
129-
rejected_camera_ids.extend(new_rejected_camera_ids.iter());
130-
assert!(!rejected_camera_ids.contains(&root));
13196

97+
let new_pose_map = match refine_rotation_via_rcd {
98+
true => refine_rotation_by_rcd(root, &paths, &pose_map),
99+
false => pose_map.clone()
100+
};
101+
102+
// We re-triangulate regardless of rcd because matches, landmarks may have been removed by the outlier rejection
103+
let path_pairs = conversions::compute_path_id_pairs(root, &paths);
104+
let mut new_landmark_map = compute_landmark_maps(&path_pairs, &new_pose_map, &match_map, &camera_map, triangulation);
105+
let mut new_reprojection_error_map =
106+
compute_reprojection_maps(
107+
&path_pairs,
108+
&new_landmark_map,
109+
&new_pose_map,
110+
&match_norm_map,
111+
&camera_norm_map
112+
);
113+
114+
let keys = landmark_map.keys().map(|k| *k).collect::<Vec<_>>();
115+
for key in keys {
116+
let new_reprojection_errors = new_reprojection_error_map.get(&key).unwrap();
117+
let current_reprojection_errors = reprojection_error_map.get_mut(&key).unwrap();
118+
119+
if new_reprojection_errors.mean() < current_reprojection_errors.mean() {
120+
landmark_map.insert(key, new_landmark_map.remove(&key).unwrap());
121+
reprojection_error_map
122+
.insert(key, new_reprojection_error_map.remove(&key).unwrap());
123+
pose_map.insert(key, new_pose_map.get(&key).unwrap().clone());
132124
}
133-
let (min_reprojection_error_refined, max_reprojection_error_refined) =
134-
compute_reprojection_ranges(&reprojection_error_map);
135-
println!("After Rotation: BA Config Max Reprojection Error 2): {}, Min Reprojection Error: {}", max_reprojection_error_refined, min_reprojection_error_refined);
136125
}
126+
abs_pose_map = conversions::compute_absolute_poses_for_root(root, &paths_pairs, &pose_map);
127+
if run_outlier_detection_pipeline {
128+
let new_rejected_camera_ids = reject_landmark_outliers(
129+
&mut landmark_map,
130+
&mut reprojection_error_map,
131+
&mut match_map,
132+
&mut match_norm_map,
133+
landmark_cutoff_thresh,
134+
);
135+
rejected_camera_ids.extend(new_rejected_camera_ids.iter());
136+
assert!(!rejected_camera_ids.contains(&root));
137+
138+
}
139+
let (min_reprojection_error_refined, max_reprojection_error_refined) =
140+
compute_reprojection_ranges(&reprojection_error_map);
141+
println!("After Rotation: BA Config Max Reprojection Error 2): {}, Min Reprojection Error: {}", max_reprojection_error_refined, min_reprojection_error_refined);
142+
143+
137144

138145
for (k,v) in match_map.iter(){
139146
println!("Final matches for Cam {:?} : {}",k,v.len());

src/sfm/bundle_adjustment/ba_config/mod.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ impl<C: Camera<Float> + Clone, Feat: Feature>
5757
triangulation: Triangulation,
5858
perc_tresh: Float,
5959
epipolar_thresh: Float,
60-
run_outlier_detection_pipeline: bool,
6160
image_width: usize,
6261
image_height: usize
6362
) -> BAConfig<C, Feat> {
@@ -70,15 +69,10 @@ impl<C: Camera<Float> + Clone, Feat: Feature>
7069
&matches_with_tracks
7170
));
7271

72+
//TODO: add option to set windows size > 2 ( 2 is implicit at the moment)
7373
let mut match_map =
7474
Self::generate_match_map_with_landmark_ids(root, &paths, matches_with_tracks);
7575

76-
77-
let disparity_map = Self::compute_disparity_map(root, &paths, &match_map);
78-
if run_outlier_detection_pipeline {
79-
//TODO: tie this to min angular distance. Currently it also triggers on Z-only motion
80-
//reject_matches_via_disparity(disparity_map, &mut match_map, disparity_cutoff_thresh);
81-
}
8276

8377
//TODO: Move this out to a prior stage
8478
let feature_map_per_cam = Self::generate_features_per_cam(&match_map);

0 commit comments

Comments
 (0)