Skip to content

Commit

Permalink
Switched to 7-point algorithm.
Browse files Browse the repository at this point in the history
Exclude points matches with low stdev.
  • Loading branch information
zlogic committed Jul 23, 2023
1 parent 7d35c57 commit 91075c5
Show file tree
Hide file tree
Showing 7 changed files with 198 additions and 165 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spade = { version = "2.2", default_features = false }
wgpu = { version = "0.16", default-features = false, features = ["wgsl"] }
pollster = { version = "0.3", default-features = false }
bytemuck = { version = "*", features = ["derive"] }
roots = { version = "0.0.8", default-features = false }

[profile.release]
strip = true
Expand Down
10 changes: 9 additions & 1 deletion src/correlation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ use std::sync::atomic::{AtomicUsize, Ordering};

type Point = (usize, usize);

// TODO 0.17 Improve performance with feature-rich images.
const THRESHOLD: f32 = 0.80;
const KERNEL_SIZE: usize = 7;
const KERNEL_SIZE: usize = 15;
const KERNEL_WIDTH: usize = KERNEL_SIZE * 2 + 1;
const KERNEL_POINT_COUNT: usize = KERNEL_WIDTH * KERNEL_WIDTH;
const MIN_STDEV: f32 = 3.0;

#[derive(Debug)]
pub struct PointData<const KPC: usize> {
Expand Down Expand Up @@ -64,6 +66,9 @@ impl KeypointMatching {
Some(it) => it,
None => return vec![],
};
if data1.stdev < MIN_STDEV {
return vec![];
}
let points2 = points2;
points2
.iter()
Expand All @@ -73,6 +78,9 @@ impl KeypointMatching {
Some(it) => it,
None => return None,
};
if data2.stdev < MIN_STDEV {
return None;
}
correlate_points(data1, data2)
.filter(|corr| *corr > THRESHOLD)
.map(|_| (*p1, *p2))
Expand Down
2 changes: 1 addition & 1 deletion src/crosscorrelation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rayon::prelude::*;
use std::{cell::RefCell, error, ops::Range, sync::atomic::AtomicUsize, sync::atomic::Ordering};

const SCALE_MIN_SIZE: usize = 64;
const KERNEL_SIZE: usize = 7;
const KERNEL_SIZE: usize = 5;
const KERNEL_WIDTH: usize = KERNEL_SIZE * 2 + 1;
const KERNEL_POINT_COUNT: usize = KERNEL_WIDTH * KERNEL_WIDTH;

Expand Down
2 changes: 1 addition & 1 deletion src/fast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const FAST_CIRCLE_PIXELS: [(i8, i8); 16] = [
const KERNEL_SIZE: usize = 3;
// TODO: update to match results from previous C version
const FAST_THRESHOLD: u8 = 15;
const KEYPOINT_SCALE_MIN_SIZE: usize = 256;
const KEYPOINT_SCALE_MIN_SIZE: usize = 512;
const FAST_NUM_POINTS: usize = 12;
const FAST_CIRCLE_LENGTH: usize = FAST_CIRCLE_PIXELS.len() + FAST_NUM_POINTS - 1;

Expand Down
Loading

0 comments on commit 91075c5

Please sign in to comment.