Never crash: trackers and camera solver without expect()
The camera solver, KLT pyramid and subspace (warp stabilizer) tracker expect()ed data-structure invariants: a track point seen in a frame, a solved camera, a pyramid level. A missing value now skips that point/track (or, for finish(), returns a SolveError: "no frame was solved") instead of panicking. Denies the panic lints in the crate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
10644a83aa
commit
bf8962becf
@@ -367,7 +367,7 @@ pub fn smooth_trajectories(tracks: &[Track2D], frames: usize, sigma: f64, rank:
|
||||
let mut ata = vec![0.0; k * k];
|
||||
let mut atb = [vec![0.0; k], vec![0.0; k]];
|
||||
for &c in &cols {
|
||||
let p = tr.at((lo + c) as u32).expect("covered");
|
||||
let Some(p) = tr.at((lo + c) as u32) else { continue };
|
||||
for a in 0..k {
|
||||
for d in 0..2 {
|
||||
atb[d][a] += cmat[a][c] * p[d];
|
||||
@@ -391,8 +391,8 @@ pub fn smooth_trajectories(tracks: &[Track2D], frames: usize, sigma: f64, rank:
|
||||
}
|
||||
dst[d] = x.iter().zip(&chat).map(|(a, b)| a * b).sum();
|
||||
}
|
||||
if ok {
|
||||
out.push((tr.at(t32).expect("seen"), dst));
|
||||
if ok && let Some(p) = tr.at(t32) {
|
||||
out.push((p, dst));
|
||||
}
|
||||
}
|
||||
out
|
||||
|
||||
Reference in New Issue
Block a user