Skip to main content

TrackerContext

Struct TrackerContext 

Source
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

Source

pub fn new() -> Self

Creates an empty context. Buffers grow to fit on the first prepare / track call and are reused thereafter.

Source

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).

Source

pub fn prev_pyramid(&self) -> &[GrayImage]

The previous-frame pyramid built by the last prepare.

Source

pub fn next_pyramid(&self) -> &[GrayImage]

The next-frame pyramid built by the last prepare.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Default for TrackerContext

Source§

fn default() -> TrackerContext

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.