A new crate holding the CPU half of a merge (FR-MRG-10): the grayscale proxy with orientation, the XFeat decoder ported step for step from the reference detectAndCompute, mutual-nearest-neighbour matching, a robust pairwise homography with the focal length read off it, a hand-rolled Levenberg–Marquardt bundle adjustment over every rotation and the focal, the three output projections, and align(), which chains it all and names the frames it could not place rather than guessing (FR-MRG-5). Dependency-free without the xfeat feature — linalg.rs says why the dense algebra is hand-rolled — and tested on synthetic sweeps whose answer is known exactly. The noise test records the single-row degeneracy: one pixel of noise is a tenth of a percent of focal, which is a uniform stretch of the sweep, not a misalignment.
38 lines
1.3 KiB
Rust
38 lines
1.3 KiB
Rust
//! Check the model is a model and not an LFS pointer.
|
|
//!
|
|
//! `models/keypoints/*.onnx` is stored in Git LFS (see `.gitattributes`). A
|
|
//! clone made without git-lfs, or with `GIT_LFS_SKIP_SMUDGE` set, leaves a
|
|
//! ~130-byte text pointer at that path instead of the weights, and
|
|
//! `include_bytes!` would embed it without complaint. Same guard as
|
|
//! `dr-segment`'s, for the same failure.
|
|
|
|
use std::path::Path;
|
|
|
|
const MODEL: &str = "../../models/keypoints/xfeat-1024.onnx";
|
|
|
|
fn main() {
|
|
println!("cargo:rerun-if-changed={MODEL}");
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
|
|
if std::env::var_os("CARGO_FEATURE_EMBEDDED_MODEL").is_none() {
|
|
return;
|
|
}
|
|
|
|
let path = Path::new(MODEL);
|
|
let Ok(bytes) = std::fs::read(path) else {
|
|
panic!(
|
|
"\n\n{MODEL} is missing.\n\
|
|
It ships in Git LFS. Run `git lfs install && git lfs pull`, or build \
|
|
with `--no-default-features` for a geometry-only build.\n"
|
|
);
|
|
};
|
|
|
|
if bytes.starts_with(b"version https://git-lfs.github.com/spec/") {
|
|
panic!(
|
|
"\n\n{MODEL} is a Git LFS pointer, not the model.\n\
|
|
Run `git lfs install && git lfs pull`, or build with \
|
|
`--no-default-features` for a geometry-only build.\n"
|
|
);
|
|
}
|
|
}
|