pub struct FlowField {
pub vectors: Vec<FlowVector>,
pub width: u32,
pub height: u32,
pub block_size: u32,
}Expand description
A dense optical flow field covering a frame on a block grid.
Fields§
§vectors: Vec<FlowVector>Flat storage, row-major over block rows × block columns.
width: u32Frame width in pixels.
height: u32Frame height in pixels.
block_size: u32Block size in pixels (each cell in the grid covers this many pixels).
Implementations§
Source§impl FlowField
impl FlowField
Sourcepub fn set(&mut self, x: u32, y: u32, flow: FlowVector)
pub fn set(&mut self, x: u32, y: u32, flow: FlowVector)
Set the flow vector at block position (x, y).
x is the block column, y is the block row.
Does nothing if the indices are out of range.
Sourcepub fn get(&self, x: u32, y: u32) -> Option<&FlowVector>
pub fn get(&self, x: u32, y: u32) -> Option<&FlowVector>
Get the flow vector at block position (x, y).
Returns None if the indices are out of range.
Sourcepub fn block_cols(&self) -> u32
pub fn block_cols(&self) -> u32
Number of block columns.
Sourcepub fn block_rows(&self) -> u32
pub fn block_rows(&self) -> u32
Number of block rows.
Sourcepub fn avg_magnitude(&self) -> f32
pub fn avg_magnitude(&self) -> f32
Average magnitude of all flow vectors weighted by confidence.
Returns 0.0 when the field is empty or all confidences are zero.
Sourcepub fn dominant_direction(&self) -> (f32, f32)
pub fn dominant_direction(&self) -> (f32, f32)
Dominant (average) direction as (dx, dy), confidence-weighted.
Returns (0.0, 0.0) when the field is empty or all confidences are zero.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FlowField
impl RefUnwindSafe for FlowField
impl Send for FlowField
impl Sync for FlowField
impl Unpin for FlowField
impl UnsafeUnpin for FlowField
impl UnwindSafe for FlowField
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.