objc2-vision 0.3.2

Bindings to the Vision framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

/// Tracking level options to favor speed or location accuracy. The VNRequestTrackingLevelFast is the default option used by trackers.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/vision/vnrequesttrackinglevel?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct VNRequestTrackingLevel(pub NSUInteger);
impl VNRequestTrackingLevel {
    #[doc(alias = "VNRequestTrackingLevelAccurate")]
    pub const Accurate: Self = Self(0);
    #[doc(alias = "VNRequestTrackingLevelFast")]
    pub const Fast: Self = Self(1);
}

unsafe impl Encode for VNRequestTrackingLevel {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for VNRequestTrackingLevel {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// A base class for all tracking requests.
    ///
    /// Since this class is not meant to be directly instantiated, no initializers are available.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/vision/vntrackingrequest?language=objc)
    #[unsafe(super(VNImageBasedRequest, VNRequest, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "VNRequest")]
    pub struct VNTrackingRequest;
);

#[cfg(feature = "VNRequest")]
extern_conformance!(
    unsafe impl NSCopying for VNTrackingRequest {}
);

#[cfg(feature = "VNRequest")]
unsafe impl CopyingHelper for VNTrackingRequest {
    type Result = Self;
}

#[cfg(feature = "VNRequest")]
extern_conformance!(
    unsafe impl NSObjectProtocol for VNTrackingRequest {}
);

#[cfg(feature = "VNRequest")]
impl VNTrackingRequest {
    extern_methods!(
        #[cfg(feature = "VNObservation")]
        /// The observation object that defines a region to track. Providing an observation not returned from a tracker (e.g. user-defined, or from a detector) begins a new tracker for the sequence. Providing an observation that was returned from a tracker continues the use of that tracker, to track the region to the next frame. In general, unless documented in the request's documentation, the rectangle must be defined in normalized coordinates (both dimensions normalized to [0,1] with the origin at the lower-left corner).
        #[unsafe(method(inputObservation))]
        #[unsafe(method_family = none)]
        pub unsafe fn inputObservation(&self) -> Retained<VNDetectedObjectObservation>;

        #[cfg(feature = "VNObservation")]
        /// Setter for [`inputObservation`][Self::inputObservation].
        #[unsafe(method(setInputObservation:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setInputObservation(&self, input_observation: &VNDetectedObjectObservation);

        /// Tracking level allows tuning tracking algorithm to prefer speed (VNRequestTrackingLevelFast) vs. tracking object location accuracy (VNRequestTrackingLevelAccurate). This property has no effect on general purpose object tracker (VNTrackObjectRequest) revision 2 (VNTrackObjectRequestRevision2)
        #[unsafe(method(trackingLevel))]
        #[unsafe(method_family = none)]
        pub unsafe fn trackingLevel(&self) -> VNRequestTrackingLevel;

        /// Setter for [`trackingLevel`][Self::trackingLevel].
        #[unsafe(method(setTrackingLevel:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setTrackingLevel(&self, tracking_level: VNRequestTrackingLevel);

        /// This property allows marking the last frame for tracking using current tracker. If set to YES, the results for this frame will be processed and returned and the current tracker will be released to the pool of available trackers
        #[unsafe(method(isLastFrame))]
        #[unsafe(method_family = none)]
        pub unsafe fn isLastFrame(&self) -> bool;

        /// Setter for [`isLastFrame`][Self::isLastFrame].
        #[unsafe(method(setLastFrame:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setLastFrame(&self, last_frame: bool);

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[cfg(feature = "block2")]
        /// # Safety
        ///
        /// `completion_handler` must be a valid pointer or null.
        #[unsafe(method(initWithCompletionHandler:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCompletionHandler(
            this: Allocated<Self>,
            completion_handler: VNRequestCompletionHandler,
        ) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "VNRequest")]
impl VNTrackingRequest {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}