pub struct MotionDetector { /* private fields */ }Expand description
GPU-accelerated motion detector.
Compares successive frames to detect and quantify pixel-level motion.
The first call to analyze returns a zero-motion result because
there is no previous frame to compare against.
Implementations§
Source§impl MotionDetector
impl MotionDetector
Sourcepub fn new(
sensitivity: Sensitivity,
region_count_x: u32,
region_count_y: u32,
) -> Self
pub fn new( sensitivity: Sensitivity, region_count_x: u32, region_count_y: u32, ) -> Self
Create a new MotionDetector.
§Arguments
sensitivity- Detection sensitivity level.region_count_x- Number of sub-regions horizontally (minimum 1).region_count_y- Number of sub-regions vertically (minimum 1).
Sourcepub fn analyze(
&mut self,
frame: &[u8],
width: u32,
height: u32,
) -> Result<MotionAnalysis>
pub fn analyze( &mut self, frame: &[u8], width: u32, height: u32, ) -> Result<MotionAnalysis>
Analyze motion between the previous frame and the current frame.
On the first call (no previous frame), returns a MotionAnalysis
with all metrics at zero. On subsequent calls the current frame is
compared against the previously stored frame.
§Arguments
frame- Raw pixel data (single channel / luma expected for best results; multi-channel frames work but all bytes are compared).width- Frame width in pixels.height- Frame height in pixels.
§Errors
Returns GpuError::InvalidDimensions if width * height == 0.
Returns GpuError::InvalidBufferSize if a previous frame was stored
with a different size.
Sourcepub fn region_count(&self) -> u32
pub fn region_count(&self) -> u32
Return the total number of motion analysis regions (x * y).
Auto Trait Implementations§
impl Freeze for MotionDetector
impl RefUnwindSafe for MotionDetector
impl Send for MotionDetector
impl Sync for MotionDetector
impl Unpin for MotionDetector
impl UnsafeUnpin for MotionDetector
impl UnwindSafe for MotionDetector
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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