VTMotionEstimationSession

Struct VTMotionEstimationSession 

Source
pub struct VTMotionEstimationSession { /* private fields */ }
Available on crate feature 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

Source

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_options generics must be of the correct type.
  • motion_estimation_session_out must be a valid pointer.
Source

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.

Source

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

Source

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

Available on crate features 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 be NULL.

  • outputHandler: The block invoked by the syetem when the processing request is completed. If the VTMotionEstimationSessionCreateMotionEstimation call returns an error, the system does not invoke the block.

  • Returns: If the call was successful, returns noErr; otherwise, returns an error code, such as kVTMotionEstimationNotSupportedErr.

§Safety
  • additional_frame_options generics must be of the correct type.
  • output_handler must be a valid pointer.
Source

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>§

Source

pub fn downcast_ref<T>(&self) -> Option<&T>
where T: ConcreteType,

Available on crate feature 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.

Source

pub fn retain_count(&self) -> usize

Available on crate feature 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

Source§

fn as_ref(&self) -> &AnyObject

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<CFType> for VTMotionEstimationSession

Source§

fn as_ref(&self) -> &CFType

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<VTMotionEstimationSession> for VTMotionEstimationSession

Source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<AnyObject> for VTMotionEstimationSession

Source§

fn borrow(&self) -> &AnyObject

Immutably borrows from an owned value. Read more
Source§

impl Borrow<CFType> for VTMotionEstimationSession

Source§

fn borrow(&self) -> &CFType

Immutably borrows from an owned value. Read more
Source§

impl ConcreteType for VTMotionEstimationSession

Source§

fn type_id() -> CFTypeID

Get the CoreFoundation type identifier for motion-estimation session type.

Source§

impl Debug for VTMotionEstimationSession

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for VTMotionEstimationSession

Source§

type Target = CFType

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Hash for VTMotionEstimationSession

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Message for VTMotionEstimationSession

Source§

fn retain(&self) -> Retained<Self>
where Self: Sized,

Increment the reference count of the receiver. Read more
Source§

impl PartialEq for VTMotionEstimationSession

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl RefEncode for VTMotionEstimationSession

Source§

const ENCODING_REF: Encoding

The Objective-C type-encoding for a reference of this type. Read more
Source§

impl Type for VTMotionEstimationSession

Source§

fn retain(&self) -> CFRetained<Self>
where Self: Sized,

Increment the reference count of the receiver. Read more
Source§

fn as_concrete_TypeRef(&self) -> &Self

👎Deprecated: this is redundant
Helper for easier transition from the core-foundation crate.
Source§

unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>
where Self: Sized,

👎Deprecated: use CFRetained::retain
Helper for easier transition from the core-foundation crate. Read more
Source§

fn as_CFTypeRef(&self) -> &CFType
where Self: AsRef<CFType>,

👎Deprecated: this is redundant (CF types deref to CFType)
Helper for easier transition from the core-foundation crate.
Source§

unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>
where Self: Sized,

👎Deprecated: use CFRetained::from_raw
Helper for easier transition from the core-foundation crate. Read more
Source§

impl Eq for VTMotionEstimationSession

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.
Source§

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