### Start Peer-to-Peer Connection (visionOS Client) Source: https://developer.apple.com/documentation/visionos/connecting-ipados-and-visionos-apps-over-the-local-network Initiates a peer-to-peer connection by starting a browser on the visionOS app. Ensure the connection state is not already 'connecting' before starting. ```swift struct ClientContentView: View { @Environment(PeerMessagingController>.self) var clientController /// The network task to cancel the `NetworkBrowser`. @State private var networkTask: Task? /// Client has a default random ID. @State private var clientID: Int = Int.random(in: 0...9000) var body: some View { // ... Button("Start browsing for devices with ID: \(clientID.description)") { // As long as the state isn't currently connecting, start the connection. guard clientController.connectionState != .connecting else { return } networkTask = clientController.start(with: clientID.description) } ``` -------------------------------- ### Configure Video Processing Cadence and Start Analysis Source: https://developer.apple.com/documentation/vision/generating-thumbnails-from-videos Sets up the video processing cadence to evaluate approximately 100 frames and starts the analysis process. It also initializes dictionaries to store results. ```swift do { /// The time interval for the video-processing cadence. let interval = CMTime( seconds: totalDuration / framesToEval, preferredTimescale: timeScale ) /// The video-processing cadence to process only 100 frames. let cadence = VideoProcessor.Cadence.timeInterval(interval) /// The stream that adds the aesthetics scores request to the video processor. let aestheticsScoreStream = try await videoProcessor.addRequest(aestheticsScoresRequest, cadence: cadence) /// The stream that adds the image feature-print request to the video processor. let featurePrintStream = try await videoProcessor.addRequest(imageFeaturePrintRequest, cadence: cadence) // Start to analyze the video. videoProcessor.startAnalysis() /// The dictionary to store the timestamp and the aesthetics score. var aestheticsResults: [CMTime: Float] = [:] /// The dictionary to store the timestamp and the feature-print observation. var featurePrintResults: [CMTime: FeaturePrintObservation] = [:] // ... // Solve for the top-rated frames. topFrames = await calculateTopFrames(aestheticsResults: aestheticsResults, featurePrintResults: featurePrintResults) } ``` -------------------------------- ### startScanning() Source: https://developer.apple.com/documentation/visionkit/datascannerviewcontroller Starts the data scanning process. ```APIDOC ## `startScanning()` ### Description Starts the data scanning process. ### Method `startScanning()` ``` -------------------------------- ### Set up Camera Preview Source: https://developer.apple.com/documentation/vision/locating-and-displaying-recognized-text Sets up a live camera capture preview. It checks for camera authorization and handles errors if access is denied. Ensure the app has camera permissions. ```swift CameraPreview(camera: $camera) .task { /// If the app has access to the camera, set up and display a live capture preview. if await camera.checkCameraAuthorization() { didSetup = camera.setup() /// If the app doesn't have access, dismiss the camera and display an error. } else { showAccessError = true showCamera = false } if !didSetup { print("Camera setup failed.") showCamera = false } } ``` -------------------------------- ### Responding to New Recognized Items Source: https://developer.apple.com/documentation/visionkit/datascannerviewcontrollerdelegate Implement this method to get notified when the data scanner starts recognizing new items. A default implementation is provided. ```swift func dataScanner(_ dataScanner: DataScannerViewController, didAdd recognizedItems: [RecognizedItem], allItems: [RecognizedItem]) ``` -------------------------------- ### Get Arm Joint Names Source: https://developer.apple.com/documentation/vision/vnhumanbodypose3dobservation/jointname/rightelbow Provides examples of other arm-related joint names for human pose observation. These can be used to access different parts of the human body skeleton. ```swift static let centerShoulder: VNHumanBodyPose3DObservation.JointName ``` ```swift static let leftShoulder: VNHumanBodyPose3DObservation.JointName ``` ```swift static let rightShoulder: VNHumanBodyPose3DObservation.JointName ``` ```swift static let leftElbow: VNHumanBodyPose3DObservation.JointName ``` ```swift static let leftWrist: VNHumanBodyPose3DObservation.JointName ``` ```swift static let rightWrist: VNHumanBodyPose3DObservation.JointName ``` -------------------------------- ### init(_:) Source: https://developer.apple.com/documentation/vision/videoprocessor/init%28_%3A%29 Creates a video processor to perform framework requests against the video asset you specify. ```APIDOC ## init(_:) ### Description Creates a video processor to perform framework requests against the video asset you specify. ### Method `init(_:)` ### Parameters #### Path Parameters - **videoURL** (URL) - Required - The video asset in a video format that AVFoundation supports. ``` -------------------------------- ### Get Leg Joint Names Source: https://developer.apple.com/documentation/vision/vnhumanbodypose3dobservation/jointname/righthip Provides examples of static properties for various leg joint names within `VNHumanBodyPose3DObservation.JointName`, including left and right hips, knees, and ankles. ```swift static let leftHip: VNHumanBodyPose3DObservation.JointName ``` ```swift static let leftKnee: VNHumanBodyPose3DObservation.JointName ``` ```swift static let rightKnee: VNHumanBodyPose3DObservation.JointName ``` ```swift static let leftAnkle: VNHumanBodyPose3DObservation.JointName ``` ```swift static let rightAnkle: VNHumanBodyPose3DObservation.JointName ``` -------------------------------- ### init(_:) Source: https://developer.apple.com/documentation/vision/animalbodyposeobservation/init%28_%3A%29 Creates an animal body pose observation using a provided VNAnimalBodyPoseObservation. ```APIDOC ## init(_:) ### Description Creates an animal body pose observation. ### Parameters #### Path Parameters - **observation** (VNAnimalBodyPoseObservation) - Description not available. ``` -------------------------------- ### Get Leg Joint Names Source: https://developer.apple.com/documentation/vision/vnanimalbodyposeobservation/jointname/leftfrontelbow This section provides examples of other joint names related to animal body pose observation, including various elbow, knee, and paw joints for both left and right sides, and front and back orientations. ```swift static let leftBackElbow: VNAnimalBodyPoseObservation.JointName ``` ```swift static let rightFrontElbow: VNAnimalBodyPoseObservation.JointName ``` ```swift static let rightBackElbow: VNAnimalBodyPoseObservation.JointName ``` ```swift static let leftBackKnee: VNAnimalBodyPoseObservation.JointName ``` ```swift static let leftFrontKnee: VNAnimalBodyPoseObservation.JointName ``` ```swift static let rightBackKnee: VNAnimalBodyPoseObservation.JointName ``` ```swift static let rightFrontKnee: VNAnimalBodyPoseObservation.JointName ``` ```swift static let leftBackPaw: VNAnimalBodyPoseObservation.JointName ``` ```swift static let leftFrontPaw: VNAnimalBodyPoseObservation.JointName ``` ```swift static let rightBackPaw: VNAnimalBodyPoseObservation.JointName ``` ```swift static let rightFrontPaw: VNAnimalBodyPoseObservation.JointName ``` -------------------------------- ### init(_:) Source: https://developer.apple.com/documentation/visionkit/imageanalysisoverlayview/init%28_%3A%29 Initializes an ImageAnalysisOverlayView with a specified delegate object. ```APIDOC ## init(_:) ### Description Creates an overlay view with the specified delegate object. ### Method Initializer ### Parameters #### Path Parameters - **delegate** (any ImageAnalysisOverlayViewDelegate) - Required - The object that provides details about the interface. ### Request Example @MainActor convenience init(_ delegate: any ImageAnalysisOverlayViewDelegate) ``` -------------------------------- ### VNTrackingRequest - inputObservation Source: https://developer.apple.com/documentation/vision/vntrackingrequest/inputobservation The inputObservation property allows you to specify an initial observation, such as a detected object, to guide the tracking process. Providing a new observation starts a new tracking sequence, while providing an existing one continues tracking the same object. ```APIDOC ## VNTrackingRequest - inputObservation ### Description The observation object defining a region to track. ### Instance Property `inputObservation: VNDetectedObjectObservation { get set }` ### Discussion Providing an observation not returned from a tracker, such as a user-defined observation, 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 specified in the request’s documentation or header file, you must define the rectangle in normalized coordinates, with the origin at the lower-left corner. ### Availability iOS 11.0+ iPadOS 11.0+ Mac Catalyst 13.1+ macOS 10.13+ tvOS 11.0+ visionOS 1.0+ ### See Also - `enum VNRequestTrackingLevel` - `var trackingLevel: VNRequestTrackingLevel` - `var isLastFrame: Bool` ``` -------------------------------- ### Initializer Source: https://developer.apple.com/documentation/vision/humanhandposeobservation/init%28_%3A%29 Creates a human hand pose observation. ```APIDOC ## init(_:) ### Description Creates a human hand pose observation. ### Method Signature ```swift init(_ observation: VNHumanHandPoseObservation) ``` ### Parameters #### Path Parameters - **observation** (VNHumanHandPoseObservation) - Required - The human hand pose observation to initialize with. ``` -------------------------------- ### init(completionHandler:) Source: https://developer.apple.com/documentation/vision/vntrackopticalflowrequest/init%28completionhandler%3A%29 Initializes a new optical flow tracking request with an optional completion handler. ```APIDOC ## init(completionHandler:) ### Description Creates a new request that tracks the optical flow from one image to another, with a system callback on completion. ### Parameters #### Parameters - **completionHandler** (VNRequestCompletionHandler?) - Optional - The callback the system invokes when it completes the request. ### Request Example let request = VNTrackOpticalFlowRequest(completionHandler: { request, error in // Handle completion }) ``` -------------------------------- ### Get Observation Time Range Source: https://developer.apple.com/documentation/vision/vnobservation/timerange Access the time range of a reported observation. Use this property to determine an observation’s start time and duration when evaluating a sequence of image buffers. If the request does not support time ranges, or the time range is unknown, the value is `zero`. ```swift var timeRange: CMTimeRange { get } ``` -------------------------------- ### init(_:) Source: https://developer.apple.com/documentation/vision/vnvideoprocessor/frameratecadence/init%28_%3A%29 Initializes a new frame-based cadence with a specified frame rate. ```APIDOC ## init(_:) ### Description Creates a new frame-based cadence with a frame rate. ### Parameters #### Path Parameters - **frameRate** (Int) - Required - The frame rate at which to process video. ### Request Example init(30) ``` -------------------------------- ### init(_:) Source: https://developer.apple.com/documentation/vision/generateforegroundinstancemaskrequest/init%28_%3A%29 Creates a foreground instance-mask request. This initializer allows for optional revision specification. ```APIDOC ## init(_:) ### Description Creates a foreground instance-mask request. ### Parameters #### Path Parameters - **revision** (GenerateForegroundInstanceMaskRequest.Revision?) - Optional - Specifies the revision for the request. Defaults to nil. ``` -------------------------------- ### Get Ring Tip Joint Name Source: https://developer.apple.com/documentation/vision/humanhandposeobservation/jointname/ringtip Use this case to get the joint name representing the tip of the ring finger. ```swift case ringTip ``` -------------------------------- ### Get thumbMP Joint Name Source: https://developer.apple.com/documentation/vision/humanhandposeobservation/jointname/thumbmp Use this case to get the joint name representing the thumb’s metacarpophalangeal (MP) joint. ```swift case thumbMP ``` -------------------------------- ### Initializer Source: https://developer.apple.com/documentation/vision/humanbodyposeobservation/init%28_%3A%29 Creates a human body pose observation. ```APIDOC ## Initializer ### Description Creates a human body pose observation. ### Signature ```swift init(_ observation: VNHumanBodyPoseObservation) ``` ### Parameters #### Path Parameters - **observation** (VNHumanBodyPoseObservation) - Required - The human body pose observation to initialize with. ``` -------------------------------- ### Initialize CameraSessionManager Source: https://developer.apple.com/documentation/visionos/accessing-the-main-camera Starts an ARKitSession with a CameraFrameProvider to begin receiving camera frame updates. ```swift final class CameraSessionManager { // ... /// Begin reading and rendering the main camera's frames. func run() async { await withTaskGroup(of: Void.self) { group in group.addTask { await self.runCameraFrameProvider() } // ... } } private func runCameraFrameProvider() async { let arkitSession = ARKitSession() // ... let cameraFrameProvider = CameraFrameProvider() try? await arkitSession.run([cameraFrameProvider]) // ... // See the next section for the implementation of `observeCameraFrameUpdates`. await observeCameraFrameUpdates() } } ``` -------------------------------- ### init(targetedCGImage:orientation:options:completionHandler:) Source: https://developer.apple.com/documentation/vision/vntargetedimagerequest/init%28targetedcgimage%3Aorientation%3Aoptions%3Acompletionhandler%3A%29 Creates a new request targeting a Core Graphics image of known orientation, executing the completion handler when done. ```APIDOC ## init(targetedCGImage:orientation:options:completionHandler:) ### Description Creates a new request targeting a Core Graphics image of known orientation, executing the completion handler when done. ### Parameters - **cgImage** (CGImage) - Required - The targeted Core Graphics image. - **orientation** (CGImagePropertyOrientation) - Required - The orientation of the image buffer, based on EXIF specification. The value must be an integer from 1 to 8. - **options** ([VNImageOption : Any]) - Optional - A dictionary with options specifying auxiliary information for the image. - **completionHandler** (VNRequestCompletionHandler?) - Optional - The block to invoke when the request has finished executing. ``` -------------------------------- ### Get Supported Animal Identifiers Source: https://developer.apple.com/documentation/vision/vnrecognizeanimalsrequest/knownanimalidentifiers%28forrevision%3A%29 Use `supportedIdentifiers()` to get a list of animal identifiers the recognition algorithm supports. This method replaces the deprecated `knownAnimalIdentifiers(forRevision:)`. ```swift func supportedIdentifiers() throws -> [VNAnimalIdentifier] ``` -------------------------------- ### Get Supported Revisions for DetectTextRectanglesRequest Source: https://developer.apple.com/documentation/vision/detecttextrectanglesrequest Query the `supportedRevisions` static property to get a collection of all algorithm revisions that the `DetectTextRectanglesRequest` supports. This helps in choosing the appropriate revision for your needs. ```swift let supported = DetectTextRectanglesRequest.supportedRevisions ``` -------------------------------- ### Update Drag Start Position Logic Source: https://developer.apple.com/documentation/visionos/petite-asteroids-building-a-volumetric-visionos-game This Swift function calculates and updates the drag start position, ensuring it remains coplanar with the current drag position. It includes logic for relative drag input, allowing the start position to follow the drag, which enhances the input experience when dragging beyond a certain radius. This function is used by `SingleInputDragGesture`. ```swift func updateDragStartPosition(dragStartPosition: SIMD3, dragPosition: SIMD3, physicsRoot: Entity, useRelativeDragInput: Bool) -> SIMD3 { // Convert the drag start and current position to the local space of the physics root. let dragPositionInPhysicsSpace = physicsRoot.convert(position: dragPosition, from: nil) var dragStartPositionInPhysicsSpace = physicsRoot.convert(position: dragStartPosition, from: nil) // Project the drag start position to an XZ-plane that's parallel to the current drag position. dragStartPositionInPhysicsSpace.y = dragPositionInPhysicsSpace.y // Get the drag translation in the XZ-plane of the local space of the physics root. let dragDelta = (dragPositionInPhysicsSpace - dragStartPositionInPhysicsSpace) // When `useRelativeDragInput` is true, the drag start point will follow behind the current drag position. let dragDistance = length(dragDelta) let dragRadius = GameSettings.dragRadius / GameSettings.scale if useRelativeDragInput && dragDistance > dragRadius { // Move the drag start position so that it follows behind the current drag position so the player doesn't have to move their // input device all the way back to change direction. let normalizedDragDelta = dragDelta / dragDistance dragStartPositionInPhysicsSpace = dragPositionInPhysicsSpace - normalizedDragDelta * dragRadius } // Update the scene-space, drag-start position. return physicsRoot.convert(position: dragStartPositionInPhysicsSpace, to: nil) } ``` -------------------------------- ### init(data:options:) Source: https://developer.apple.com/documentation/vision/vnimagerequesthandler/init%28data%3Aoptions%3A%29 Initializes a VNImageRequestHandler with image data and optional configuration. ```APIDOC ## init(data:options:) ### Description Creates a handler to use for performing requests on an image in a data object. ### Parameters #### Request Body - **imageData** (Data) - Required - Data containing the image to be used for performing the requests. Image content is immutable. - **options** ([VNImageOption : Any]) - Optional - An optional dictionary containing VNImageOption keys to auxiliary image data. ``` -------------------------------- ### init(_:) Source: https://developer.apple.com/documentation/vision/calculateimageaestheticsscoresrequest/init%28_%3A%29 Creates an image aesthetics request. This initializer allows for optional revision specification. ```APIDOC ## init(_:) ### Description Creates an image aesthetics request. ### Parameters #### Path Parameters - **revision** (CalculateImageAestheticsScoresRequest.Revision?) - Optional - Specifies the revision for the request. ### Availability iOS 18.0+ iPadOS 18.0+ Mac Catalyst 18.0+ macOS 15.0+ tvOS 18.0+ visionOS 2.0+ watchOS 27.0+ ### Beta Software This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software. ``` -------------------------------- ### Get supplementaryInterfaceFont - VisionKit Source: https://developer.apple.com/documentation/visionkit/imageanalysisinteraction/supplementaryinterfacefont Use this property to get the font used for the supplementary interface. The font weight is used for image symbols, but the point size is ignored to maintain consistent button sizes. ```swift @MainActor final var supplementaryInterfaceFont: UIFont? { get set } ``` -------------------------------- ### init(_:) Source: https://developer.apple.com/documentation/vision/vnvideoprocessor/timeintervalcadence/init%28_%3A%29 Initializes a new time-based cadence instance with a specified time interval. ```APIDOC ## init(_:) ### Description Creates a new time-based cadence with a time interval. ### Parameters #### Path Parameters - **timeInterval** (CFTimeInterval) - Required - The time interval at which to process video. ### Request Example init(0.5) ``` -------------------------------- ### Setup Preview Layer Source: https://developer.apple.com/documentation/vision/recognizing-objects-in-live-capture Initialize and add an AVCaptureVideoPreviewLayer to the view controller's layer hierarchy to display the camera feed. ```swift previewLayer = AVCaptureVideoPreviewLayer(session: session) previewLayer.videoGravity = AVLayerVideoGravity.resizeAspectFill rootLayer = previewView.layer previewLayer.frame = rootLayer.bounds rootLayer.addSublayer(previewLayer) ``` -------------------------------- ### Get Middle DIP Joint Name Source: https://developer.apple.com/documentation/vision/vnhumanhandposeobservation/jointname/middledip Access the static property `middleDIP` to get the joint name for the middle finger's distal interphalangeal (DIP) joint. This property is available on iOS 14.0 and later. ```swift static let middleDIP: VNHumanHandPoseObservation.JointName ``` -------------------------------- ### init(url:) Source: https://developer.apple.com/documentation/vision/vnvideoprocessor/init%28url%3A%29-94b7 Creates a video processor to perform Vision requests against the specified video asset. ```APIDOC ## init(url:) ### Description Creates a video processor to perform Vision requests against the specified video asset. ### Parameters #### Path Parameters * **videoURL** (URL) - Required - The video asset URL. The specified asset must be a video format supported by AVFoundation. ``` -------------------------------- ### Initialize ImageAnalyzer.Configuration Source: https://developer.apple.com/documentation/visionkit/imageanalyzer/configuration/init%28_%3A%29 Creates a configuration instance by specifying the analysis types to be performed. ```swift init(_ types: ImageAnalyzer.AnalysisTypes) ``` -------------------------------- ### Get a Zero-Radius Circle Source: https://developer.apple.com/documentation/vision/vncircle/zero Use this static property to get a `VNCircle` object representing a circle centered at the origin with a radius of zero. Available on iOS 14.0+, iPadOS 14.0+, macOS 11.0+, tvOS 14.0+, and visionOS 1.0+. ```swift class var zero: VNCircle { get } ``` -------------------------------- ### Get centerShoulder Joint Name Source: https://developer.apple.com/documentation/vision/vnhumanbodypose3dobservation/jointname/centershoulder Use this static property to get the joint name representing the point between the shoulders. Available on iOS 17.0+, iPadOS 17.0+, Mac Catalyst 17.0+, macOS 14.0+, tvOS 17.0+, and visionOS 1.0+. ```swift static let centerShoulder: VNHumanBodyPose3DObservation.JointName ``` -------------------------------- ### Initializer Source: https://developer.apple.com/documentation/vision/pixelbufferobservation/init%28_%3A%29 Creates a pixel buffer observation. ```APIDOC ## init(_:) ### Description Creates a pixel buffer observation. ### Signature ```swift init?(_ observation: VNPixelBufferObservation) ``` ``` -------------------------------- ### Get Right Wrist Joint Name Source: https://developer.apple.com/documentation/vision/vnhumanbodypose3dobservation/jointname/centershoulder Use this static property to get the joint name representing the right wrist. Available on iOS 17.0+, iPadOS 17.0+, Mac Catalyst 17.0+, macOS 14.0+, tvOS 17.0+, and visionOS 1.0+. ```swift static let rightWrist: VNHumanBodyPose3DObservation.JointName ``` -------------------------------- ### init(url:orientation:options:) Source: https://developer.apple.com/documentation/vision/vnimagerequesthandler/init%28url%3Aorientation%3Aoptions%3A%29-70nta Creates a handler to be used for performing requests on an image with known orientation, at the specified URL. ```APIDOC ## init(url:orientation:options:) ### Description Creates a handler to be used for performing requests on an image with known orientation, at the specified URL. ### Parameters - **imageURL** (URL) - Required - A URL pointing to the image to be used for performing the requests. The image must be in a format supported by Image I/O. Image content is immutable. - **orientation** (CGImagePropertyOrientation) - Required - The orientation of the input image. - **options** ([VNImageOption : Any]) - Optional - An optional dictionary containing VNImageOption keys to auxiliary image data. ``` -------------------------------- ### init(recognizedDataTypes:qualityLevel:recognizesMultipleItems:isHighFrameRateTrackingEnabled:isPinchToZoomEnabled:isGuidanceEnabled:isHighlightingEnabled:) Source: https://developer.apple.com/documentation/visionkit/datascannerviewcontroller/init%28recognizeddatatypes%3Aqualitylevel%3Arecognizesmultipleitems%3Aishighframeratetrackingenabled%3Aispinchtozoomenabled%3Aisguidanceenabled%3Aishighlightingenabled%3A%29 Creates a scanner for finding data, such as text and machine-readable codes, in the camera’s live video. This initializer allows customization of data types, quality level, multiple item recognition, frame rate tracking, pinch-to-zoom, guidance, and highlighting. ```APIDOC ## init(recognizedDataTypes:qualityLevel:recognizesMultipleItems:isHighFrameRateTrackingEnabled:isPinchToZoomEnabled:isGuidanceEnabled:isHighlightingEnabled:) ### Description Creates a scanner for finding data, such as text and machine-readable codes, in the camera’s live video. ### Parameters #### Path Parameters - **recognizedDataTypes** (Set) - Required - The types of data that the data scanner identifies in the live video. - **qualityLevel** (DataScannerViewController.QualityLevel) - Optional - The level of resolution to scan that depends on the size of the items. Defaults to .balanced. - **recognizesMultipleItems** (Bool) - Optional - A Boolean value that indicates whether the scanner identifies all items in the live video. Defaults to false. - **isHighFrameRateTrackingEnabled** (Bool) - Optional - A Boolean value that determines the frequency that the scanner updates the geometry of recognized items. Defaults to true. - **isPinchToZoomEnabled** (Bool) - Optional - A Boolean value that indicates whether people can use a two-finger pinch-to-zoom gesture. Defaults to true. - **isGuidanceEnabled** (Bool) - Optional - A Boolean value that indicates whether the scanner provides help to a person when selecting items. Defaults to true. - **isHighlightingEnabled** (Bool) - Optional - A Boolean value that indicates whether the scanner displays highlights around recognized items. Defaults to false. ### Request Example ```swift let scannerView = DataScannerViewController(recognizedDataTypes: [.text(), .barcode()], isHighlightingEnabled: true) ``` ### Response This is an initializer, it does not return a value in the traditional sense but rather initializes an instance of DataScannerViewController. ``` -------------------------------- ### Get Left Wrist Joint Name Source: https://developer.apple.com/documentation/vision/vnhumanbodypose3dobservation/jointname/centershoulder Use this static property to get the joint name representing the left wrist. Available on iOS 17.0+, iPadOS 17.0+, Mac Catalyst 17.0+, macOS 14.0+, tvOS 17.0+, and visionOS 1.0+. ```swift static let leftWrist: VNHumanBodyPose3DObservation.JointName ``` -------------------------------- ### Get Right Elbow Joint Name Source: https://developer.apple.com/documentation/vision/vnhumanbodypose3dobservation/jointname/centershoulder Use this static property to get the joint name representing the right elbow. Available on iOS 17.0+, iPadOS 17.0+, Mac Catalyst 17.0+, macOS 14.0+, tvOS 17.0+, and visionOS 1.0+. ```swift static let rightElbow: VNHumanBodyPose3DObservation.JointName ``` -------------------------------- ### init(detectedObjectObservation:completionHandler:) Source: https://developer.apple.com/documentation/vision/vntrackobjectrequest/init%28detectedobjectobservation%3Acompletionhandler%3A%29 Creates a new object tracking request with a detected object observation. ```APIDOC ## init(detectedObjectObservation:completionHandler:) ### Description Creates a new object tracking request with a detected object observation. ### Parameters - **observation** (VNDetectedObjectObservation) - Required - A detected object observation with bounding box information. - **completionHandler** (VNRequestCompletionHandler?) - Optional - The callback to invoke after performing the request. ### Request Example init(detectedObjectObservation: observation, completionHandler: handler) ``` -------------------------------- ### Get Right Shoulder Joint Name Source: https://developer.apple.com/documentation/vision/vnhumanbodypose3dobservation/jointname/centershoulder Use this static property to get the joint name representing the right shoulder. Available on iOS 17.0+, iPadOS 17.0+, Mac Catalyst 17.0+, macOS 14.0+, tvOS 17.0+, and visionOS 1.0+. ```swift static let rightShoulder: VNHumanBodyPose3DObservation.JointName ``` -------------------------------- ### init(cgImage:orientation:options:) Source: https://developer.apple.com/documentation/vision/vnimagerequesthandler/init%28cgimage%3Aorientation%3Aoptions%3A%29-63ojm Creates a handler to be used for performing requests on a Core Graphics image with known orientation. ```APIDOC ## init(cgImage:orientation:options:) ### Description Creates a handler to be used for performing requests on a Core Graphics image with known orientation. ### Parameters - **image** (CGImage) - The Core Graphics image to process. Image content is immutable. - **orientation** (CGImagePropertyOrientation) - The orientation of the input image. - **options** ([VNImageOption : Any]) - An optional dictionary containing `VNImageOption` keys for auxiliary image data. Defaults to an empty dictionary. ``` -------------------------------- ### Get Left Shoulder Joint Name Source: https://developer.apple.com/documentation/vision/vnhumanbodypose3dobservation/jointname/centershoulder Use this static property to get the joint name representing the left shoulder. Available on iOS 17.0+, iPadOS 17.0+, Mac Catalyst 17.0+, macOS 14.0+, tvOS 17.0+, and visionOS 1.0+. ```swift static let leftShoulder: VNHumanBodyPose3DObservation.JointName ``` -------------------------------- ### init(boundingBox:) Source: https://developer.apple.com/documentation/vision/detectedobjectobservation/init%28boundingbox%3A%29 Creates a detected object observation with the bounding box you specify. ```APIDOC ## init(boundingBox:) ### Description Creates a detected object observation with the bounding box you specify. ### Parameters #### Path Parameters - **boundingBox** (NormalizedRect) - Required - The bounding box for the detected object. ### See Also - `init(VNDetectedObjectObservation)`: Creates a detected object observation. ``` -------------------------------- ### Initializer Source: https://developer.apple.com/documentation/vision/recognizedobjectobservation/init%28_%3A%29 Creates a recognized object observation. ```APIDOC ## init(_:) ### Description Creates a recognized object observation. ### Signature ```swift init(_ observation: VNRecognizedObjectObservation) ``` ``` -------------------------------- ### Get Supported Text Recognition Languages Source: https://developer.apple.com/documentation/visionkit/datascannerviewcontroller/supportedtextrecognitionlanguages Access the `supportedTextRecognitionLanguages` class property to get a list of language identifiers that the data scanner supports for text recognition. This property is available on iOS 16.0+, iPadOS 16.0+, Mac Catalyst 16.0+, and visionOS 1.0+. ```swift @MainActor class var supportedTextRecognitionLanguages: [String] { get } ``` -------------------------------- ### Getting the revision Source: https://developer.apple.com/documentation/vision/trackhomographicimageregistrationrequest Retrieves the algorithm or implementation the request uses. ```APIDOC ## `revision: TrackHomographicImageRegistrationRequest.Revision` ### Description The algorithm or implementation the request uses. ### Properties * **revision** (TrackHomographicImageRegistrationRequest.Revision) - The algorithm or implementation the request uses. ``` ```APIDOC ## `static let supportedRevisions: [TrackHomographicImageRegistrationRequest.Revision]` ### Description The collection of revisions the request supports. ### Properties * **supportedRevisions** ([TrackHomographicImageRegistrationRequest.Revision]) - The collection of revisions the request supports. ``` -------------------------------- ### init(data:orientation:options:) Source: https://developer.apple.com/documentation/vision/vnimagerequesthandler/2869635-init Creates a handler to use for performing requests on an image of known orientation. ```APIDOC ## init(data:orientation:options:) ### Description Creates a handler to use for performing requests on an image of known orientation. This is intended for use cases such as compressed images and network downloads. ### Parameters - **data** (Data) - Required - Data containing the image to be used for performing the requests. - **orientation** (CGImagePropertyOrientation) - Required - The orientation of the input image. - **options** (Dictionary) - Optional - An optional dictionary containing VNImageOption keys to auxiliary image data. ``` -------------------------------- ### Getting the revision Source: https://developer.apple.com/documentation/vision/detectanimalbodyposerequest Provides information about the revision used by the request. ```APIDOC ## let revision: DetectAnimalBodyPoseRequest.Revision ### Description The algorithm or implementation the request uses. ### Type DetectAnimalBodyPoseRequest.Revision ``` ```APIDOC ## static let supportedRevisions: [DetectAnimalBodyPoseRequest.Revision] ### Description The collection of revisions the request supports. ### Type [DetectAnimalBodyPoseRequest.Revision] ``` ```APIDOC ### enum Revision A type that describes the algorithm or implementation that the request performs. ``` -------------------------------- ### Initializer Source: https://developer.apple.com/documentation/vision/detectanimalbodyposerequest/init%28_%3A%29 Creates an animal body pose-detection request. ```APIDOC ## init(_:) ### Description Creates an animal body pose-detection request. ### Method Signature ```swift init(_ revision: DetectAnimalBodyPoseRequest.Revision? = nil) ``` ### Parameters #### Optional Parameters - **revision** (DetectAnimalBodyPoseRequest.Revision?) - An optional revision for the request. ``` -------------------------------- ### Get VNPoint y-coordinate Source: https://developer.apple.com/documentation/vision/vnpoint/y Access the y-coordinate of a VNPoint. This property is read-only. ```swift var y: Double { get } ``` -------------------------------- ### Initializer Source: https://developer.apple.com/documentation/vision/opticalflowobservation/init%28_%3A%29 Creates an optical flow observation. ```APIDOC ## init(_:) ### Description Creates an optical flow observation. ### Method Signature ```swift init?(_ observation: VNPixelBufferObservation) ``` ### Parameters #### Parameters - **observation** (VNPixelBufferObservation) - Required - The pixel buffer observation to initialize the optical flow observation with. ``` -------------------------------- ### GET availableJointsGroupNames Source: https://developer.apple.com/documentation/vision/vnhumanhandposeobservation/availablejointsgroupnames Retrieves the joint group names available in a VNHumanHandPoseObservation. ```APIDOC ## GET availableJointsGroupNames ### Description Returns the joint group names available in the observation. ### Method GET ### Endpoint VNHumanHandPoseObservation.availableJointsGroupNames ### Response - **availableJointsGroupNames** ([VNHumanHandPoseObservation.JointsGroupName]) - The joint group names available in the observation. ``` -------------------------------- ### Initialize ImageAnalysisOverlayView Source: https://developer.apple.com/documentation/visionkit/enabling-live-text-interactions-with-images Create an instance of the overlay view to display Live Text interface elements. ```swift let overlayView = ImageAnalysisOverlayView() ``` -------------------------------- ### init(targetedCMSampleBuffer:orientation:options:completionHandler:) Source: https://developer.apple.com/documentation/vision/vntargetedimagerequest/init%28targetedcmsamplebuffer%3Aorientation%3Aoptions%3Acompletionhandler%3A%29 Creates a new request with a completion handler that targets an image of a known orientation in a sample buffer. ```APIDOC ## init(targetedCMSampleBuffer:orientation:options:completionHandler:) ### Description Creates a new request with a completion handler that targets an image of a known orientation in a sample buffer. ### Parameters - **sampleBuffer** (CMSampleBuffer) - Required - A sample buffer containing a valid imageBuffer. - **orientation** (CGImagePropertyOrientation) - Required - The EXIF orientation of the image. - **options** (Dictionary) - Optional - A dictionary with options specifying auxiliary information for the image. - **completionHandler** (VNRequestCompletionHandler?) - Optional - The callback the system invokes when the request finishes executing. ``` -------------------------------- ### GET results property Source: https://developer.apple.com/documentation/vision/vngenerateobjectnessbasedsaliencyimagerequest/results Accesses the results of the image saliency request. ```APIDOC ## Property: results ### Description The results of the image saliency request. ### Availability - iOS 13.0+ - iPadOS 13.0+ - Mac Catalyst 13.1+ - macOS 10.15+ - tvOS 13.0+ - visionOS 1.0+ ### Declaration `var results: [VNSaliencyImageObservation]? { get }` ``` -------------------------------- ### GET VNFeaturePrintObservation.elementType Source: https://developer.apple.com/documentation/vision/vnfeatureprintobservation/elementtype Retrieves the type of each element in the feature print data. ```APIDOC ## GET VNFeaturePrintObservation.elementType ### Description The type of each element in the data. ### Availability - iOS 13.0+ - iPadOS 13.0+ - Mac Catalyst 13.1+ - macOS 10.15+ - tvOS 13.0+ - visionOS 1.0+ ### Declaration `var elementType: VNElementType { get }` ``` -------------------------------- ### Initializer: init(completionHandler:) Source: https://developer.apple.com/documentation/vision/vntrackhomographicimageregistrationrequest/init%28completionhandler%3A%29 Creates a new request that tracks the homographic transformation of two images, with a system callback on completion. ```APIDOC ## init(completionHandler:) ### Description Creates a new request that tracks the homographic transformation of two images, with a system callback on completion. ### Method Initializer ### Endpoint N/A (Initializes an object) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ## Parameters `completionHandler` The callback the system invokes when it completes the request. ``` -------------------------------- ### init(completionHandler:) Source: https://developer.apple.com/documentation/vision/vntracktranslationalimageregistrationrequest/init%28completionhandler%3A%29 Initializes a new request to track translational image registration with an optional completion handler. ```APIDOC ## init(completionHandler:) ### Description Creates a new request that tracks the translational registration of two images, with a system callback on completion. ### Parameters #### Parameters - **completionHandler** (VNRequestCompletionHandler?) - Optional - The callback the system invokes when it completes the request. ### Request Example init(completionHandler: { request, error in // Handle completion }) ``` -------------------------------- ### GET supplementalCompositeType Source: https://developer.apple.com/documentation/vision/vnbarcodeobservation/supplementalcompositetype Retrieves the supplemental composite type for a barcode observation. ```APIDOC ## GET supplementalCompositeType ### Description The supplemental composite type of the barcode observation. ### Property `var supplementalCompositeType: VNBarcodeCompositeType { get }` ### Availability - iOS 17.0+ - iPadOS 17.0+ - Mac Catalyst 17.0+ - macOS 14.0+ - tvOS 17.0+ - visionOS 1.0+ ``` -------------------------------- ### Get Circle Radius Source: https://developer.apple.com/documentation/vision/vncircle/radius Access the radius of a circle. This property is read-only. ```swift var radius: Double { get } ``` -------------------------------- ### init(targetedCIImage:orientation:options:completionHandler:) Source: https://developer.apple.com/documentation/vision/vntargetedimagerequest/init%28targetedciimage%3Aorientation%3Aoptions%3Acompletionhandler%3A%29 Creates a new request targeting a Core Image image of known orientation, executing the completion handler when done. ```APIDOC ## init(targetedCIImage:orientation:options:completionHandler:) ### Description Creates a new request targeting a Core Image image of known orientation, executing the completion handler when done. ### Parameters - **ciImage** (CIImage) - Required - The CIImage encapsulating the targeted image. - **orientation** (CGImagePropertyOrientation) - Required - The orientation of the image buffer, based on EXIF specification. Must be an integer from 1 to 8. - **options** (Dictionary) - Optional - A dictionary with options specifying auxiliary information for the image. - **completionHandler** (VNRequestCompletionHandler?) - Optional - The block to invoke when the request has finished executing. ``` -------------------------------- ### Getting the object-tracking descriptor Source: https://developer.apple.com/documentation/vision/requestdescriptor Provides descriptors for tracking objects and rectangles. ```APIDOC ## RequestDescriptor.trackObjectRequest ### Description A descriptor that describes a track object request. ### Method (Not applicable - enum case) ### Endpoint (Not applicable - enum case) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Request Example (Not applicable - enum case) ### Response #### Success Response (Not applicable - enum case) #### Response Example (Not applicable - enum case) ``` ```APIDOC ## RequestDescriptor.trackRectangleRequest ### Description A descriptor that describes a track rectangles request. ### Method (Not applicable - enum case) ### Endpoint (Not applicable - enum case) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Request Example (Not applicable - enum case) ### Response #### Success Response (Not applicable - enum case) #### Response Example (Not applicable - enum case) ``` -------------------------------- ### See Also Source: https://developer.apple.com/documentation/visionkit/imageanalysisoverlayviewdelegate/overlayview%28_%3Ashouldshowmenuforevent%3Aatpoint%3A%29 Related methods for responding to key and menu events. ```APIDOC ## See Also ### Responding to key and menu events - `func overlayView(ImageAnalysisOverlayView, shouldHandleKeyDownEvent: NSEvent) -> Bool` Returns a Boolean value that indicates whether the overlay view consumes the given key-down event. - `func overlayView(ImageAnalysisOverlayView, menu: NSMenu, willHighlight: NSMenuItem?)` Notifies your app that the given menu item is highlighted. - `func overlayView(ImageAnalysisOverlayView, willOpen: NSMenu)` Notifies your app that a given menu is opening imminently. - `func overlayView(ImageAnalysisOverlayView, didClose: NSMenu)` Notifies your app that the given menu closed. - `func overlayView(ImageAnalysisOverlayView, needsUpdate: NSMenu)` Notifies your app that the given menu needs updating. - `func overlayView(ImageAnalysisOverlayView, updatedMenuFor: NSMenu, for: NSEvent, at: CGPoint) -> NSMenu` Notifies your app before the framework presents a context menu. ``` -------------------------------- ### minimumLatencyFrameCount Source: https://developer.apple.com/documentation/vision/statefulrequest/minimumlatencyframecount-2h8se Gets the minimum number of frames required for low latency. ```APIDOC ## minimumLatencyFrameCount ### Description Gets the minimum number of frames required for low latency. ### Property `minimumLatencyFrameCount`: Int { get } ### Availability iOS 18.0+ iPadOS 18.0+ Mac Catalyst 18.0+ macOS 15.0+ tvOS 18.0+ visionOS 2.0+ watchOS 27.0+ ``` -------------------------------- ### init(_:frameAnalysisSpacing:) Source: https://developer.apple.com/documentation/vision/trackhomographicimageregistrationrequest/init%28_%3Aframeanalysisspacing%3A%29 Creates an image-alignment tracking request to determine the warp matrix. This initializer allows for optional revision and frame analysis spacing to be specified. ```APIDOC ## init(_:frameAnalysisSpacing:) ### Description Creates an image-alignment tracking request to determine the warp matrix. ### Parameters #### Path Parameters - **revision** (TrackHomographicImageRegistrationRequest.Revision?) - Optional - Specifies the revision of the request. - **frameAnalysisSpacing** (CMTime?) - Optional - Specifies the spacing between frames for analysis. ``` -------------------------------- ### GET selectedAttributedText Source: https://developer.apple.com/documentation/visionkit/imageanalysisoverlayview/selectedattributedtext Retrieves the currently selected attributed text from the ImageAnalysisOverlayView. ```APIDOC ## GET selectedAttributedText ### Description The current selected attributed text within the image analysis. ### Endpoint ImageAnalysisOverlayView.selectedAttributedText ### Response - **selectedAttributedText** (AttributedString) - The current selected attributed text. ``` -------------------------------- ### init(CMSampleBuffer:orientation:options:) Source: https://developer.apple.com/documentation/vision/vnimagerequesthandler/init%28cmsamplebuffer%3Aorientation%3Aoptions%3A%29-6qeht Initializes a new request handler with a sample buffer, orientation, and optional parameters. Available on iOS 14.0+, iPadOS 14.0+, macOS 11.0+, tvOS 14.0+, and visionOS 1.0+. ```APIDOC ## init(CMSampleBuffer:orientation:options:) ### Description Initializes a VNImageRequestHandler with a sample buffer, orientation, and optional parameters. ### Method Initializer ### Parameters - **sampleBuffer** (CMSampleBuffer) - The sample buffer containing the image data. - **orientation** (CGImagePropertyOrientation) - The orientation of the image. - **options** ([VNImageOption : Any]) - Optional dictionary for image processing options. Defaults to an empty dictionary. ### Availability iOS 14.0+ iPadOS 14.0+ Mac Catalyst 14.0+ macOS 11.0+ tvOS 14.0+ visionOS 1.0+ ``` -------------------------------- ### GET ImageAnalysisOverlayView.Subject.image Source: https://developer.apple.com/documentation/visionkit/imageanalysisoverlayview/subject/image Retrieves an image of the subjects with the background removed from the ImageAnalysisOverlayView. ```APIDOC ## GET ImageAnalysisOverlayView.Subject.image ### Description Returns an image of the subjects with the background removed. ### Method GET ### Endpoint ImageAnalysisOverlayView.Subject.image ### Response #### Success Response (200) - **image** (NSImage) - An image of the subjects with the background removed. ### Response Example { "image": "NSImage object" } ``` -------------------------------- ### init(_:frameAnalysisSpacing:) Source: https://developer.apple.com/documentation/vision/detecthumanbodypose3drequest/init%28_%3Aframeanalysisspacing%3A%29 Creates a 3D human body pose request. Supports iOS 18.0+, iPadOS 18.0+, Mac Catalyst 18.0+, macOS 15.0+, tvOS 18.0+, and visionOS 2.0+. ```APIDOC ## init(_:frameAnalysisSpacing:) ### Description Creates a 3D human body pose request. ### Parameters #### Path Parameters - **revision** (DetectHumanBodyPose3DRequest.Revision?) - Optional - The revision of the request. - **frameAnalysisSpacing** (CMTime?) - Optional - The spacing between frames for analysis. ``` -------------------------------- ### init(url:options:) Source: https://developer.apple.com/documentation/vision/vnimagerequesthandler/init%28url%3Aoptions%3A%29-4k623 Creates a handler to be used for performing requests on an image at the specified URL. The image must be in a format supported by Image I/O. Image content is immutable. ```APIDOC ## init(url:options:) ### Description Creates a handler to be used for performing requests on an image at the specified URL. ### Parameters #### Path Parameters - **imageURL** (URL) - Required - A URL pointing to the image to be used for performing the requests. The image must be in a format supported by Image I/O. Image content is immutable. - **options** (Dictionary) - Optional - An optional dictionary containing `VNImageOption` keys to auxiliary image data. Defaults to an empty dictionary. ### See Also - `init(cgImage: CGImage, options: [VNImageOption : Any])` - `init(cgImage: CGImage, orientation: CGImagePropertyOrientation, options: [VNImageOption : Any])` - `init(ciImage: CIImage, options: [VNImageOption : Any])` - `init(ciImage: CIImage, orientation: CGImagePropertyOrientation, options: [VNImageOption : Any])` - `init(cvPixelBuffer: CVPixelBuffer, options: [VNImageOption : Any])` - `init(cvPixelBuffer: CVPixelBuffer, orientation: CGImagePropertyOrientation, options: [VNImageOption : Any])` - `init(cvPixelBuffer: CVPixelBuffer, depthData: AVDepthData, orientation: CGImagePropertyOrientation, options: [VNImageOption : Any])` - `init(cmSampleBuffer: CMSampleBuffer, options: [VNImageOption : Any])` - `init(cmSampleBuffer: CMSampleBuffer, orientation: CGImagePropertyOrientation, options: [VNImageOption : Any])` - `init(cmSampleBuffer: CMSampleBuffer, depthData: AVDepthData, orientation: CGImagePropertyOrientation, options: [VNImageOption : Any])` - `init(data: Data, options: [VNImageOption : Any])` - `init(data: Data, orientation: CGImagePropertyOrientation, options: [VNImageOption : Any])` - `init(url: URL, orientation: CGImagePropertyOrientation, options: [VNImageOption : Any])` ``` -------------------------------- ### GET ImageAnalysisOverlayView.Subject.bounds Source: https://developer.apple.com/documentation/visionkit/imageanalysisoverlayview/subject/bounds Retrieves the rectangular bounds of a subject identified by the ImageAnalysisOverlayView. ```APIDOC ## GET ImageAnalysisOverlayView.Subject.bounds ### Description A rectangle that identifies the extremities of a subject within an image. ### Method GET ### Endpoint ImageAnalysisOverlayView.Subject.bounds ### Response - **bounds** (CGRect) - A rectangle that identifies the extremities of a subject within an image. ``` -------------------------------- ### Getting the detected data Source: https://developer.apple.com/documentation/vision/documentobservation/container/datadetectormatch Access the details of the data detected by the DataDetectorMatch. ```APIDOC ## Getting the detected data `var match: DataDetector.Match` The details of the data detected. ``` -------------------------------- ### Initializer Source: https://developer.apple.com/documentation/vision/humanobservation/init%28_%3A%29 Creates a human observation using an existing VNHumanObservation object. ```APIDOC ## init(_:) ### Description Creates a human observation. ### Method Signature ```swift init(_ observation: VNHumanObservation) ``` ### Availability iOS 18.0+, iPadOS 18.0+, Mac Catalyst 18.0+, macOS 15.0+, tvOS 18.0+, visionOS 2.0+ ``` -------------------------------- ### dataScanner(_:didAdd:allItems:) Source: https://developer.apple.com/documentation/visionkit/datascannerviewcontrollerdelegate Responds when the data scanner starts recognizing an item. ```APIDOC ## dataScanner(_:didAdd:allItems:) ### Description Responds when the data scanner starts recognizing an item. ### Method `func dataScanner(_: DataScannerViewController, didAdd recognizedItems: [RecognizedItem], allItems: [RecognizedItem])` ### Parameters #### Path Parameters - **dataScanner** (DataScannerViewController) - Description of the data scanner instance. - **recognizedItems** ([RecognizedItem]) - An array of newly recognized items. - **allItems** ([RecognizedItem]) - An array of all currently recognized items. ### Remarks **Required** Default implementation provided. ``` -------------------------------- ### Initializer Source: https://developer.apple.com/documentation/vision/humanbodypose3dobservation/init%28_%3A%29 Creates a 3D human body pose observation using an existing VNHumanBodyPose3DObservation object. ```APIDOC ## init(_:) ### Description Creates a 3D human body pose observation. ### Method Signature ```swift init(_ observation: VNHumanBodyPose3DObservation) ``` ### Parameters #### Path Parameters - **observation** (VNHumanBodyPose3DObservation) - Required - The existing 3D human body pose observation to initialize with. ``` -------------------------------- ### GET VNTrajectoryObservation.detectedPoints Source: https://developer.apple.com/documentation/vision/vntrajectoryobservation/detectedpoints Retrieves the centroid points of the detected contour along the trajectory. ```APIDOC ## Property: detectedPoints ### Description The centroid points of the detected contour along the trajectory. These points may differ slightly from the ideal trajectory due to allowed tolerance. The system limits the maximum number of points based on the maximum trajectory length set in the request. ### Declaration `var detectedPoints: [VNPoint] { get }` ### Availability - iOS 14.0+ - iPadOS 14.0+ - Mac Catalyst 14.0+ - macOS 11.0+ - tvOS 14.0+ - visionOS 1.0+ ```