objc2-cinematic 0.3.2

Bindings to the Cinematic 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::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
#[cfg(feature = "objc2-core-media")]
use objc2_core_media::*;
#[cfg(feature = "objc2-core-video")]
use objc2_core_video::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-metal")]
use objc2_metal::*;

use crate::*;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/cinematic/cnboundsprediction?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct CNBoundsPrediction;
);

extern_conformance!(
    unsafe impl NSCopying for CNBoundsPrediction {}
);

unsafe impl CopyingHelper for CNBoundsPrediction {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for CNBoundsPrediction {}
);

impl CNBoundsPrediction {
    extern_methods!(
        #[cfg(feature = "objc2-core-foundation")]
        /// bounds of the detected object in normalized coordinates where (0.0, 0.0) is the upper left corner, and (1.0, 1.0) is the lower right
        #[unsafe(method(normalizedBounds))]
        #[unsafe(method_family = none)]
        pub unsafe fn normalizedBounds(&self) -> CGRect;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`normalizedBounds`][Self::normalizedBounds].
        #[unsafe(method(setNormalizedBounds:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setNormalizedBounds(&self, normalized_bounds: CGRect);

        /// the probability that a well-defined object is within the bounds — a number between 0.0 and 1.0.
        #[unsafe(method(confidence))]
        #[unsafe(method_family = none)]
        pub unsafe fn confidence(&self) -> c_float;

        /// Setter for [`confidence`][Self::confidence].
        #[unsafe(method(setConfidence:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setConfidence(&self, confidence: c_float);
    );
}

/// Methods declared on superclass `NSObject`.
impl CNBoundsPrediction {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern_class!(
    /// Converts a normalized point or rectangle into a detection track that tracks an object over time.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/cinematic/cnobjecttracker?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct CNObjectTracker;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for CNObjectTracker {}
);

impl CNObjectTracker {
    extern_methods!(
        /// Indicates whether the current device supports object detection and tracking.
        #[unsafe(method(isSupported))]
        #[unsafe(method_family = none)]
        pub unsafe fn isSupported() -> bool;

        #[cfg(feature = "objc2-metal")]
        /// Create a new detection track builder.
        /// - Parameters:
        /// - commandQueue: the command queue of a metal device to which commands should be submitted to perform work
        #[unsafe(method(initWithCommandQueue:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCommandQueue(
            this: Allocated<Self>,
            command_queue: &ProtocolObject<dyn MTLCommandQueue>,
        ) -> Retained<Self>;

        #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-video"))]
        /// Find the bounds of an object at the given point. Can be used to convert a normalized point in an image to a rectangle that can be used to start tracking.
        /// - Parameters:
        /// - point: location of object in image in normalized coordinates where (0.0, 0.0) is the upper left corner, and (1.0, 1.0) is the lower right
        /// - sourceImage: pixel buffer containing the image
        /// - Returns: A prediction, which includes bounds that can be used to start tracking, or `nil` if no discernible object is detected.
        #[unsafe(method(findObjectAtPoint:sourceImage:))]
        #[unsafe(method_family = none)]
        pub unsafe fn findObjectAtPoint_sourceImage(
            &self,
            point: CGPoint,
            source_image: &CVPixelBuffer,
        ) -> Option<Retained<CNBoundsPrediction>>;

        #[cfg(all(
            feature = "objc2-core-foundation",
            feature = "objc2-core-media",
            feature = "objc2-core-video"
        ))]
        /// Start creating a detection track to track an object within the given bounds.
        /// - Parameters:
        /// - time: the presentation time of the first frame in the detection track
        /// - normalizedBounds: the bounds of the object to track in normalized coordinates where (0.0, 0.0) is the upper left corner, and (1.0, 1.0) is the lower right
        /// - sourceImage: image buffer containing the image
        /// - sourceDisparity: disparity buffer containing depth information
        /// - Returns: whether the object can be tracked
        /// - Note: if the object can be tracked, a detection is added to the detection track being built
        #[unsafe(method(startTrackingAt:within:sourceImage:sourceDisparity:))]
        #[unsafe(method_family = none)]
        pub unsafe fn startTrackingAt_within_sourceImage_sourceDisparity(
            &self,
            time: CMTime,
            normalized_bounds: CGRect,
            source_image: &CVPixelBuffer,
            source_disparity: &CVPixelBuffer,
        ) -> bool;

        #[cfg(all(feature = "objc2-core-media", feature = "objc2-core-video"))]
        /// Continue tracking an object for which tracking has started, and add a new detection to the detection track being built.
        /// - Parameters:
        /// - time: the presentation time of the frame to be added to the detection track
        /// - Returns: a prediction of where the object is in the source image
        #[unsafe(method(continueTrackingAt:sourceImage:sourceDisparity:))]
        #[unsafe(method_family = none)]
        pub unsafe fn continueTrackingAt_sourceImage_sourceDisparity(
            &self,
            time: CMTime,
            source_image: &CVPixelBuffer,
            source_disparity: &CVPixelBuffer,
        ) -> Option<Retained<CNBoundsPrediction>>;

        #[cfg(feature = "CNDetectionTrack")]
        /// Finish constructing the detection track and return it.
        /// - Returns: a detection track which tracks the object
        #[unsafe(method(finishDetectionTrack))]
        #[unsafe(method_family = none)]
        pub unsafe fn finishDetectionTrack(&self) -> Retained<CNDetectionTrack>;

        /// Reset the builder to construct a new detection track.
        #[unsafe(method(resetDetectionTrack))]
        #[unsafe(method_family = none)]
        pub unsafe fn resetDetectionTrack(&self);

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

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}