pub struct VTMotionEstimationSession { /* private fields */ }VTMotionEstimationSession only.Expand description
A reference to a Video Toolbox motion-estimation session.
A motion-estimation session supports two CVPixelBuffers of the same size and type, and returns motion vectors in
the form of a CVPixelBuffer. The session is a reference-counted CF object. To create a motion-estimation session,
call VTMotionEstimationSessionCreate; then you can optionally configure the session using VTSessionSetProperty.
To create motion-estimations, call VTMotionEstimationSessionCreateMotionEstimation. When you are done with the
session, you should call VTMotionEstimationSessionInvalidate to tear it down and CFRelease to release the
session object reference.
See also Apple’s documentation
Implementations§
Source§impl VTMotionEstimationSession
impl VTMotionEstimationSession
Sourcepub unsafe fn create(
allocator: Option<&CFAllocator>,
motion_vector_processor_selection_options: Option<&CFDictionary>,
width: u32,
height: u32,
motion_estimation_session_out: NonNull<*mut VTMotionEstimationSession>,
) -> i32
pub unsafe fn create( allocator: Option<&CFAllocator>, motion_vector_processor_selection_options: Option<&CFDictionary>, width: u32, height: u32, motion_estimation_session_out: NonNull<*mut VTMotionEstimationSession>, ) -> i32
Creates a session you use to generate a pixel buffer of motion vectors from two pixel buffers.
The function creates a session for computing motion vectors between two pixel buffers.
- Parameters:
- allocator: An allocator for the session. Pass NULL to use the default allocator.
- motionVectorProcessorSelectionOptions: Available creation options are:
- term
kVTMotionEstimationSessionCreationOption_MotionVectorSize: Size of the search block. - term
kVTMotionEstimationSessionCreationOption_UseMultiPassSearch: Use multiple passes to detect true motion. - term
kVTMotionEstimationSessionCreationOption_Label: Label used for logging and resource tracking. - width: The width of frames in pixels.
- height: The height of frames in pixels.
- motionEstimationSessionOut: Points to a variable to receive the new motion-estimation session.
§Safety
motion_vector_processor_selection_optionsgenerics must be of the correct type.motion_estimation_session_outmust be a valid pointer.
Sourcepub unsafe fn copy_source_pixel_buffer_attributes(
&self,
attributes_out: NonNull<*const CFDictionary>,
) -> i32
pub unsafe fn copy_source_pixel_buffer_attributes( &self, attributes_out: NonNull<*const CFDictionary>, ) -> i32
Copies the attributes for source pixel buffers expected by motion-estimation session.
This function provides a CFDictionary of attributes that you must release. Use this function to query
VTMotionEstimationSession for the native source attributes. If you provide an input CVPixelBuffer that is
not compatible with the attributes that this function returns, VTMotionEstimationSession automatically
converts the input pixel buffer into a compatible pixel buffer for processing.
- Parameters:
- session: The motion-estimation session.
- attributesOut: Points to a variable to receive the attributes dictionary.
§Safety
attributes_out must be a valid pointer.
Sourcepub unsafe fn invalidate(&self)
pub unsafe fn invalidate(&self)
Tears down a motion-estimation session.
When you are done with a motion-estimation session you created, call this function to tear
it down and then CFRelease to release the session object reference. When a motion-estimation session’s retain count
reaches zero, the system automatically invalidates it, but because multiple parties may retain sessions, it can be
hard to predict when this happens. Calling this function ensures a deterministic, orderly teardown.
Source§impl VTMotionEstimationSession
impl VTMotionEstimationSession
Sourcepub unsafe fn estimate_motion_vectors(
&self,
reference_image: &CVPixelBuffer,
current_image: &CVPixelBuffer,
motion_estimation_frame_flags: VTMotionEstimationFrameFlags,
additional_frame_options: Option<&CFDictionary>,
output_handler: VTMotionEstimationOutputHandler,
) -> i32
Available on crate features block2 and objc2-core-video only.
pub unsafe fn estimate_motion_vectors( &self, reference_image: &CVPixelBuffer, current_image: &CVPixelBuffer, motion_estimation_frame_flags: VTMotionEstimationFrameFlags, additional_frame_options: Option<&CFDictionary>, output_handler: VTMotionEstimationOutputHandler, ) -> i32
block2 and objc2-core-video only.Creates a new pixel buffer that contains motion vectors between the input pixel buffers.
The motion-estimation session compares the reference frame to the current frame, and generates motion vectors in
the form of a CVPixelBuffer.
-
Parameters:
-
session: The motion-estimation session.
-
referenceImage: The reference image.
-
currentImage: The current image.
-
motionEstimationFrameFlags: A bit field with per-frame options. See
kVTMotionEstimationFrameFlags_CurrentBufferWillBeNextReferenceBuffer. -
additionalFrameOptions: A way to pass additional information that doesn’t fit in
motionEstimationFrameFlags; currently the system expects it to beNULL. -
outputHandler: The block invoked by the syetem when the processing request is completed. If the
VTMotionEstimationSessionCreateMotionEstimationcall returns an error, the system does not invoke the block. -
Returns: If the call was successful, returns
noErr; otherwise, returns an error code, such askVTMotionEstimationNotSupportedErr.
§Safety
additional_frame_optionsgenerics must be of the correct type.output_handlermust be a valid pointer.
Sourcepub unsafe fn complete_frames(&self) -> i32
pub unsafe fn complete_frames(&self) -> i32
Directs the motion-estimation session to emit all pending frames and waits for completion.
Directs the motion-estimation session to emit all pending frames, then waits for all outstanding requests to complete, then returns.
Methods from Deref<Target = CFType>§
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: ConcreteType,
Available on crate feature VTSession only.
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: ConcreteType,
VTSession only.Attempt to downcast the type to that of type T.
This is the reference-variant. Use CFRetained::downcast if you
want to convert a retained type. See also ConcreteType for more
details on which types support being converted to.
Sourcepub fn retain_count(&self) -> usize
Available on crate feature VTSession only.
pub fn retain_count(&self) -> usize
VTSession only.Get the reference count of the object.
This function may be useful for debugging. You normally do not use this function otherwise.
Beware that some things (like CFNumbers, small CFStrings etc.) may
not have a normal retain count for optimization purposes, and can
return usize::MAX in that case.
Trait Implementations§
Source§impl AsRef<AnyObject> for VTMotionEstimationSession
impl AsRef<AnyObject> for VTMotionEstimationSession
Source§impl AsRef<CFType> for VTMotionEstimationSession
impl AsRef<CFType> for VTMotionEstimationSession
Source§impl Borrow<AnyObject> for VTMotionEstimationSession
impl Borrow<AnyObject> for VTMotionEstimationSession
Source§impl Borrow<CFType> for VTMotionEstimationSession
impl Borrow<CFType> for VTMotionEstimationSession
Source§impl Debug for VTMotionEstimationSession
impl Debug for VTMotionEstimationSession
Source§impl Deref for VTMotionEstimationSession
impl Deref for VTMotionEstimationSession
Source§impl Hash for VTMotionEstimationSession
impl Hash for VTMotionEstimationSession
Source§impl Message for VTMotionEstimationSession
impl Message for VTMotionEstimationSession
Source§impl RefEncode for VTMotionEstimationSession
impl RefEncode for VTMotionEstimationSession
Source§const ENCODING_REF: Encoding
const ENCODING_REF: Encoding
Source§impl Type for VTMotionEstimationSession
impl Type for VTMotionEstimationSession
Source§fn retain(&self) -> CFRetained<Self>where
Self: Sized,
fn retain(&self) -> CFRetained<Self>where
Self: Sized,
Source§fn as_concrete_TypeRef(&self) -> &Self
fn as_concrete_TypeRef(&self) -> &Self
core-foundation crate.Source§unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
core-foundation crate. Read moreSource§fn as_CFTypeRef(&self) -> &CFType
fn as_CFTypeRef(&self) -> &CFType
core-foundation crate.Source§unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
core-foundation crate. Read more