pub struct TrackerContext { /* private fields */ }Expand description
Reusable owner of every buffer the tracking hot path touches: both frame pyramids, the Lucas-Kanade scratch, the result vector and the forward-backward intermediates.
Create one per tracking thread and call prepare then
track / track_fb each frame. After the
first (warm-up) frame, a steady-state step with a fixed image size, level
count, window size and point count performs no heap allocation — all
buffers are resized in place. This is the allocation-free path the VIO
front-end runs every frame; the free functions
(calc_optical_flow_ex, calc_optical_flow_fb) are thin convenience
wrappers that allocate their own scratch.
Implementations§
Source§impl TrackerContext
impl TrackerContext
Sourcepub fn prepare(&mut self, prev: &GrayImage, next: &GrayImage, levels: usize)
pub fn prepare(&mut self, prev: &GrayImage, next: &GrayImage, levels: usize)
Builds the previous- and next-frame pyramids into the context’s reusable
buffers. Zero-alloc in steady state (same image size and levels).
Sourcepub fn prev_pyramid(&self) -> &[GrayImage] ⓘ
pub fn prev_pyramid(&self) -> &[GrayImage] ⓘ
The previous-frame pyramid built by the last prepare.
Sourcepub fn next_pyramid(&self) -> &[GrayImage] ⓘ
pub fn next_pyramid(&self) -> &[GrayImage] ⓘ
The next-frame pyramid built by the last prepare.
Sourcepub fn track(
&mut self,
prev_points: &[(f32, f32)],
predicted: Option<&[(f32, f32)]>,
window_size: usize,
max_iterations: usize,
min_eigen_threshold: f32,
) -> &[TrackResult]
pub fn track( &mut self, prev_points: &[(f32, f32)], predicted: Option<&[(f32, f32)]>, window_size: usize, max_iterations: usize, min_eigen_threshold: f32, ) -> &[TrackResult]
Tracks prev_points using the prepared pyramids, returning the results
held inside the context. See calc_optical_flow_ex for the argument
semantics. Allocation-free in steady state.
Sourcepub fn track_fb(
&mut self,
prev_points: &[(f32, f32)],
predicted: Option<&[(f32, f32)]>,
window_size: usize,
max_iterations: usize,
min_eigen_threshold: f32,
fb_threshold: f32,
) -> &[TrackResult]
pub fn track_fb( &mut self, prev_points: &[(f32, f32)], predicted: Option<&[(f32, f32)]>, window_size: usize, max_iterations: usize, min_eigen_threshold: f32, fb_threshold: f32, ) -> &[TrackResult]
Forward-backward consistent tracking using the prepared pyramids. See
calc_optical_flow_fb for semantics. Reuses the context’s scratch and
intermediate point buffers, so it is allocation-free in steady state.