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