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"))]
53unsafe impl NSCopying for VNGeneratePersonSegmentationRequest {}
54
55#[cfg(all(feature = "VNRequest", feature = "VNStatefulRequest"))]
56unsafe impl CopyingHelper for VNGeneratePersonSegmentationRequest {
57    type Result = Self;
58}
59
60#[cfg(all(feature = "VNRequest", feature = "VNStatefulRequest"))]
61unsafe impl NSObjectProtocol for VNGeneratePersonSegmentationRequest {}
62
63#[cfg(all(feature = "VNRequest", feature = "VNStatefulRequest"))]
64impl VNGeneratePersonSegmentationRequest {
65    extern_methods!(
66        #[unsafe(method(new))]
67        #[unsafe(method_family = new)]
68        pub unsafe fn new() -> Retained<Self>;
69
70        #[unsafe(method(init))]
71        #[unsafe(method_family = init)]
72        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
73
74        #[cfg(feature = "block2")]
75        #[unsafe(method(initWithCompletionHandler:))]
76        #[unsafe(method_family = init)]
77        pub unsafe fn initWithCompletionHandler(
78            this: Allocated<Self>,
79            completion_handler: VNRequestCompletionHandler,
80        ) -> Retained<Self>;
81
82        #[cfg(all(feature = "block2", feature = "objc2-core-media"))]
83        #[unsafe(method(initWithFrameAnalysisSpacing:completionHandler:))]
84        #[unsafe(method_family = init)]
85        pub unsafe fn initWithFrameAnalysisSpacing_completionHandler(
86            this: Allocated<Self>,
87            frame_analysis_spacing: CMTime,
88            completion_handler: VNRequestCompletionHandler,
89        ) -> Retained<Self>;
90
91        /// The quality level selects which techniques will be used during the person segmentation. There are trade-offs between performance and accuracy.
92        #[unsafe(method(qualityLevel))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn qualityLevel(&self) -> VNGeneratePersonSegmentationRequestQualityLevel;
95
96        /// Setter for [`qualityLevel`][Self::qualityLevel].
97        #[unsafe(method(setQualityLevel:))]
98        #[unsafe(method_family = none)]
99        pub unsafe fn setQualityLevel(
100            &self,
101            quality_level: VNGeneratePersonSegmentationRequestQualityLevel,
102        );
103
104        /// Obtain the collection of supported output pixel formats for the configured request.
105        #[unsafe(method(supportedOutputPixelFormatsAndReturnError:_))]
106        #[unsafe(method_family = none)]
107        pub unsafe fn supportedOutputPixelFormatsAndReturnError(
108            &self,
109        ) -> Result<Retained<NSArray<NSNumber>>, Retained<NSError>>;
110
111        /// Pixel format type of the output buffer. Valid values are kCVPixelFormatType_OneComponent32Float, kCVPixelFormatType_OneComponent16Half, and kCVPixelFormatType_OneComponent8. Default is kCVPixelFormatType_OneComponent8.
112        #[unsafe(method(outputPixelFormat))]
113        #[unsafe(method_family = none)]
114        pub unsafe fn outputPixelFormat(&self) -> OSType;
115
116        /// Setter for [`outputPixelFormat`][Self::outputPixelFormat].
117        #[unsafe(method(setOutputPixelFormat:))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn setOutputPixelFormat(&self, output_pixel_format: OSType);
120
121        #[cfg(feature = "VNObservation")]
122        #[unsafe(method(results))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn results(&self) -> Option<Retained<NSArray<VNPixelBufferObservation>>>;
125    );
126}
127
128/// [Apple's documentation](https://developer.apple.com/documentation/vision/vngeneratepersonsegmentationrequestrevision1?language=objc)
129pub static VNGeneratePersonSegmentationRequestRevision1: NSUInteger = 1;