Twelve real frames from the fixture set now align in 4.5 s — 4.4 s of matching, 118 ms of bundle adjustment — where the first run took 51 s and left the first two frames out. The matcher computes each pair's similarity matrix once, across the cores, with a dot product written to vectorise; both nearest-neighbour directions read it. The frames that failed were portrait: fitted into the landscape input they used 512 of 1024 px, and their thin overlap did not survive at half resolution. The same weights are now exported at 768×1024 as well and the detector picks the shape by aspect. The example aligns from embedded previews and draws the set on a cylinder; on the fixture the sweep is 152° at a fitted 47.9 mm against the EXIF's 50, RMS 1.5 px, and the overlaps show no ghosting.
49 lines
1.4 KiB
Rust
49 lines
1.4 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 MODELS: &[&str] = &[
|
|
"../../models/keypoints/xfeat-1024.onnx",
|
|
"../../models/keypoints/xfeat-768.onnx",
|
|
];
|
|
|
|
fn main() {
|
|
for m in MODELS {
|
|
println!("cargo:rerun-if-changed={m}");
|
|
}
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
|
|
if std::env::var_os("CARGO_FEATURE_EMBEDDED_MODEL").is_none() {
|
|
return;
|
|
}
|
|
|
|
for model in MODELS.iter().copied() {
|
|
check(model);
|
|
}
|
|
}
|
|
|
|
fn check(model: &str) {
|
|
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"
|
|
);
|
|
}
|
|
}
|