Skip to content

Commit

Permalink
Use percentages instead of absolute RANSAC D.
Browse files Browse the repository at this point in the history
Some images have too many matches and too much noise, so need a higher
threshold.

Also, tweaked P3P parameters.
  • Loading branch information
zlogic committed Jun 1, 2024
1 parent aeaa596 commit 6230660
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/triangulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ const TRACKS_RADIUS_DENOMINATOR: usize = 1000;
const PERSPECTIVE_SCALE_THRESHOLD: f64 = 0.0001;
const RANSAC_N: usize = 3;
const RANSAC_K: usize = 100_000;
const RANSAC_INLIERS_T: f64 = 25.0 / 1000.0;
const RANSAC_T: f64 = 75.0 / 1000.0;
const RANSAC_D: usize = 100;
const RANSAC_D_EARLY_EXIT: usize = 100_000;
const RANSAC_INLIERS_T: f64 = 50.0 / 1000.0;
const RANSAC_T: f64 = 50.0 / 1000.0;
const RANSAC_D_PERCENT: usize = 70;
const RANSAC_D_PERCENT_EARLY_EXIT: usize = 95;
const RANSAC_CHECK_INTERVAL: usize = 1000;
// Lower this value to get more points (especially on far distance).
const MIN_ANGLE_BETWEEN_RAYS: f64 = (0.5 / 180.0) * std::f64::consts::PI;
Expand Down Expand Up @@ -1084,6 +1084,9 @@ impl PerspectiveTriangulation {
}
};

let ransac_d = RANSAC_D_PERCENT * linked_tracks.len() / 100;
let ransac_d_early_exit = RANSAC_D_PERCENT_EARLY_EXIT * linked_tracks.len() / 100;

for _ in 0..ransac_outer {
let (camera, count, error) = (0..RANSAC_CHECK_INTERVAL)
.par_bridge()
Expand Down Expand Up @@ -1133,13 +1136,13 @@ impl PerspectiveTriangulation {
.reduce(|| best_result.to_owned(), reduce_best_result);

best_result = (camera, count, error);
if count >= RANSAC_D_EARLY_EXIT {
if count >= ransac_d_early_exit {
break;
}
}

let count = best_result.1;
if count > RANSAC_D {
if count > ransac_d {
Some(best_result.0)
} else {
None
Expand Down

0 comments on commit 6230660

Please sign in to comment.