pub struct FlowField {
pub width: u32,
pub height: u32,
pub vectors: Vec<FlowVector>,
}Expand description
Dense optical flow field.
Contains one FlowVector per pixel of the image.
Fields§
§width: u32Width of the source image.
height: u32Height of the source image.
vectors: Vec<FlowVector>Per-pixel flow vectors in row-major order.
Implementations§
Source§impl FlowField
impl FlowField
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 pixel (x, y), or None if out of bounds.
Sourcepub fn mean_magnitude(&self) -> f32
pub fn mean_magnitude(&self) -> f32
Compute the mean magnitude of all flow vectors.
Sourcepub fn warp_frame(&self, target: &[u8]) -> Result<Vec<u8>>
pub fn warp_frame(&self, target: &[u8]) -> Result<Vec<u8>>
Warp the target frame backwards using this flow field to produce a
motion-compensated intermediate frame.
For each output pixel p, samples target[p - flow(p)] using
bilinear interpolation. Pixels that map outside target are filled
with black (zero).
§Arguments
target– RGBA pixel data for the frame to warp.
§Errors
Returns an error if target does not match the flow field dimensions.
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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 more