objc2_vision/generated/
VNGeneratePersonSegmentationRequest.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-media")]
7use objc2_core_media::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12/// Person segmentation level options to favor speed over recognition accuracy.
13/// VNGeneratePersonSegmentationRequestQualityLevelAccurate is the default option.
14///
15/// fast - generates a low accuracy segmentation mask that can be used in streaming scenarios on devices that have a neural engine
16/// balanced - generates a high accuracy segmentation mask
17/// accurate - generates a mask based on the balanced output that includes matting refinement
18/// The request may hold on to previous masks to improve temporal stability.
19///
20/// See also [Apple's documentation](https://developer.apple.com/documentation/vision/vngeneratepersonsegmentationrequestqualitylevel?language=objc)
21// NS_ENUM
22#[repr(transparent)]
23#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
24pub struct VNGeneratePersonSegmentationRequestQualityLevel(pub NSUInteger);
25impl VNGeneratePersonSegmentationRequestQualityLevel {
26    #[doc(alias = "VNGeneratePersonSegmentationRequestQualityLevelAccurate")]
27    pub const Accurate: Self = Self(0);
28    #[doc(alias = "VNGeneratePersonSegmentationRequestQualityLevelBalanced")]
29    pub const Balanced: Self = Self(1);
30    #[doc(alias = "VNGeneratePersonSegmentationRequestQualityLevelFast")]
31    pub const Fast: Self = Self(2);
32}
33
34unsafe impl Encode for VNGeneratePersonSegmentationRequestQualityLevel {
35    const ENCODING: Encoding = NSUInteger::ENCODING;
36}
37
38unsafe impl RefEncode for VNGeneratePersonSegmentationRequestQualityLevel {
39    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
40}
41
42extern_class!(
43    /// Performs person segmentation on an image generating a mask.
44    ///
45    /// See also [Apple's documentation](https://developer.apple.com/documentation/vision/vngeneratepersonsegmentationrequest?language=objc)
46    #[unsafe(super(VNStatefulRequest, VNImageBasedRequest, VNRequest, NSObject))]
47    #[derive(Debug, PartialEq, Eq, Hash)]
48    #[cfg(all(feature = "VNRequest", feature = "VNStatefulRequest"))]
49    pub struct VNGeneratePersonSegmentationRequest;
50);
51
52#[cfg(all(feature = "VNRequest", feature = "VNStatefulRequest"))]
53extern_conformance!(
54    unsafe impl NSCopying for VNGeneratePersonSegmentationRequest {}
55);
56
57#[cfg(all(feature = "VNRequest", feature = "VNStatefulRequest"))]
58unsafe impl CopyingHelper for VNGeneratePersonSegmentationRequest {
59    type Result = Self;
60}
61
62#[cfg(all(feature = "VNRequest", feature = "VNStatefulRequest"))]
63extern_conformance!(
64    unsafe impl NSObjectProtocol for VNGeneratePersonSegmentationRequest {}
65);
66
67#[cfg(all(feature = "VNRequest", feature = "VNStatefulRequest"))]
68impl VNGeneratePersonSegmentationRequest {
69    extern_methods!(
70        #[unsafe(method(new))]
71        #[unsafe(method_family = new)]
72        pub unsafe fn new() -> Retained<Self>;
73
74        #[unsafe(method(init))]
75        #[unsafe(method_family = init)]
76        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
77
78        #[cfg(feature = "block2")]
79        /// # Safety
80        ///
81        /// `completion_handler` must be a valid pointer or null.
82        #[unsafe(method(initWithCompletionHandler:))]
83        #[unsafe(method_family = init)]
84        pub unsafe fn initWithCompletionHandler(
85            this: Allocated<Self>,
86            completion_handler: VNRequestCompletionHandler,
87        ) -> Retained<Self>;
88
89        #[cfg(all(feature = "block2", feature = "objc2-core-media"))]
90        /// # Safety
91        ///
92        /// `completion_handler` must be a valid pointer or null.
93        #[unsafe(method(initWithFrameAnalysisSpacing:completionHandler:))]
94        #[unsafe(method_family = init)]
95        pub unsafe fn initWithFrameAnalysisSpacing_completionHandler(
96            this: Allocated<Self>,
97            frame_analysis_spacing: CMTime,
98            completion_handler: VNRequestCompletionHandler,
99        ) -> Retained<Self>;
100
101        /// The quality level selects which techniques will be used during the person segmentation. There are trade-offs between performance and accuracy.
102        #[unsafe(method(qualityLevel))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn qualityLevel(&self) -> VNGeneratePersonSegmentationRequestQualityLevel;
105
106        /// Setter for [`qualityLevel`][Self::qualityLevel].
107        #[unsafe(method(setQualityLevel:))]
108        #[unsafe(method_family = none)]
109        pub unsafe fn setQualityLevel(
110            &self,
111            quality_level: VNGeneratePersonSegmentationRequestQualityLevel,
112        );
113
114        /// Obtain the collection of supported output pixel formats for the configured request.
115        #[unsafe(method(supportedOutputPixelFormatsAndReturnError:_))]
116        #[unsafe(method_family = none)]
117        pub unsafe fn supportedOutputPixelFormatsAndReturnError(
118            &self,
119        ) -> Result<Retained<NSArray<NSNumber>>, Retained<NSError>>;
120
121        /// Pixel format type of the output buffer. Valid values are kCVPixelFormatType_OneComponent32Float, kCVPixelFormatType_OneComponent16Half, and kCVPixelFormatType_OneComponent8. Default is kCVPixelFormatType_OneComponent8.
122        #[unsafe(method(outputPixelFormat))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn outputPixelFormat(&self) -> OSType;
125
126        /// Setter for [`outputPixelFormat`][Self::outputPixelFormat].
127        #[unsafe(method(setOutputPixelFormat:))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn setOutputPixelFormat(&self, output_pixel_format: OSType);
130
131        #[cfg(feature = "VNObservation")]
132        #[unsafe(method(results))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn results(&self) -> Option<Retained<NSArray<VNPixelBufferObservation>>>;
135    );
136}
137
138/// [Apple's documentation](https://developer.apple.com/documentation/vision/vngeneratepersonsegmentationrequestrevision1?language=objc)
139pub static VNGeneratePersonSegmentationRequestRevision1: NSUInteger = 1;