Can you give me a code sample with the new stuff in visionOS
Asked on 05/01/2025
1 search
To explore the new features in visionOS, particularly for Vision Pro, you can refer to the session titled "Platforms State of the Union" where they discuss enhancements in scene understanding, object tracking, and more. For a detailed look at the new APIs and capabilities, the session "Introducing enterprise APIs for visionOS" provides insights into enhanced sensor access and object tracking.
Here's a brief code sample to get you started with the new object tracking API in visionOS:
import VisionOS
// Initialize the object tracking session
let objectTrackingSession = VNObjectTrackingSession()
// Configure the session with known objects
objectTrackingSession.configure(with: [
VNKnownObject(identifier: "exampleObject", referenceImage: UIImage(named: "exampleImage")!)
])
// Start the session
objectTrackingSession.start()
// Handle detected objects
objectTrackingSession.didDetectObjects = { detectedObjects in
for object in detectedObjects {
print("Detected object: \(object.identifier) at position: \(object.position)")
}
}
This code demonstrates how to set up an object tracking session using the new APIs in visionOS. You can adjust parameters such as the maximum number of objects tracked or the tracking rate to suit your application's needs.
For more detailed information, you can watch the session Introducing enterprise APIs for visionOS (02:36) which covers enhanced sensor access and other new features.

Discover Swift enhancements in the Vision framework
The Vision Framework API has been redesigned to leverage modern Swift features like concurrency, making it easier and faster to integrate a wide array of Vision algorithms into your app. We’ll tour the updated API and share sample code, along with best practices, to help you get the benefits of this framework with less coding effort. We’ll also demonstrate two new features: image aesthetics and holistic body pose.

Bring your iOS or iPadOS game to visionOS
Discover how to transform your iOS or iPadOS game into a uniquely visionOS experience. Increase the immersion (and fun factor!) with a 3D frame or an immersive background. And invite players further into your world by adding depth to the window with stereoscopy or head tracking.

Introducing enterprise APIs for visionOS
Find out how you can use new enterprise APIs for visionOS to create spatial experiences that enhance employee and customer productivity on Apple Vision Pro.