Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
--output-dir coverage \
--timeout 300 \
--exclude-files "**/tests/*" \
--exclude-files "**/examples/*" \
--ignore-panics

- name: Upload coverage reports to Codecov
Expand Down
16 changes: 16 additions & 0 deletions crates/core/src/kpm/freak/clustering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,22 @@ mod tests {
assert!(bhc.query(&feat).is_err());
}

#[test]
fn test_bhc_build_all_identical() {
// Degenerate input: many identical descriptors. k-medoids distances are
// all zero, so the split is degenerate — exercise that path (#177).
let feat = [42u8; 96];
let owned: Vec<[u8; 96]> = (0..20).map(|_| feat).collect();
let features: Vec<&[u8; 96]> = owned.iter().collect();
let mut bhc = BinaryHierarchicalClustering::new().unwrap();
bhc.build(&features).expect("build over identical features");
let res = bhc.query(&feat).expect("query");
assert!(
!res.is_empty(),
"query of an identical feature must return the leaf members"
);
}

#[test]
fn test_bhc_roundtrip() {
let mut bhc = BinaryHierarchicalClustering::new().unwrap();
Expand Down
32 changes: 32 additions & 0 deletions crates/core/src/kpm/freak/visual_database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,38 @@ mod tests {
);
}

#[test]
fn test_query_from_keyframe_no_match() {
// Deterministic, no image: a db keyframe with all-0x00 descriptors vs a
// query keyframe with all-0xFF descriptors — maximally distant, so the
// ratio test rejects every candidate and try_match_one short-circuits
// (no-match path, #177).
let mk = |desc: u8, n: usize| -> Keyframe {
let mut kf = Keyframe::new(640, 480).unwrap();
for i in 0..n {
let p = FeaturePoint {
x: i as f32,
y: i as f32,
angle: 0.0,
scale: 1.0,
maxima: true,
};
kf.store.add(p, &[desc; 96]).unwrap();
}
kf
};

let mut db = VisualDatabase::new().expect("new");
db.add_keyframe(mk(0x00, 12), 0).expect("add_keyframe");

let matched = db
.query_from_keyframe(mk(0xFF, 12))
.expect("query_from_keyframe");
assert!(!matched, "maximally-distant descriptors must not match");
assert_eq!(db.matched_db_id(), -1);
assert!(db.inliers().is_empty());
}

#[test]
fn test_facade_parity_accessors() {
// Build a tiny keyframe directly (no image pipeline) so the getters are
Expand Down
Loading