CameraRegionView
This view displays a stabilized region of interest within a person’s view and provides passthrough camera feed for that selected region.
Declaration
@MainActor @preconcurrency struct CameraRegionViewOverview
CameraRegionView needs enterprise API access in order to be used. To use this view, you need to apply for the Camera Region access entitlement. For more information, including how to apply for this entitlement, see Building spatial experiences for business apps with enterprise APIs for visionOS.
This is a standalone view used in a WindowGroup that a person can freely move and place in order to position the desired region of interest. Examples of possible regions of interest are documents, user manuals, gauges, and displays.
The view also allows additional post-processing of passthrough camera frames. These stabilized camera frames of the selected region of interest are directly rendered into the view. The framework provides these frames to enterprise developers before rendering them on screen, so developers can apply any enhancements or modifications prior to the rendering within the view.
struct AppScene: Scene {
var body: some Scene {
// Enterprise use case which requires an enterprise license and
// entitlement.
WindowGroup(id: "WithEnterpriseLicense") {
CameraRegionView() { result in
switch result {
case .success(let context):
let pixelBuffer = context.pixelBuffer
// Add desired changes to pixel buffer.
return pixelBuffer
case .failure(let error):
// Handle errors.
return nil
}
}
}
.windowResizability(.contentSize)
}
}