CameraRef

A reference to a Camera, exposing its controller and preview methods (the equivalent of a ref on VisionCamera's <Camera />). Create it with rememberCameraRef and pass it to Camera.

val camera = rememberCameraRef()
val scope = rememberCoroutineScope()
Camera(
device = TargetCameraPosition.BACK,
isActive = true,
ref = camera,
modifier = Modifier.pointerInput(Unit) {
detectTapGestures { offset -> scope.launch { camera.focusTo(offset) } }
},
)

View coordinates are in Compose pixels, as in pointer events.

Properties

Link copied to clipboard

The CameraController of the Camera, or null if it is not ready yet.

Link copied to clipboard

The PreviewViewRef of the Camera's preview.

Functions

Link copied to clipboard
Link copied to clipboard
suspend fun focusTo(viewPoint: Offset, options: FocusOptions = FocusOptions())

Focuses on the given point of the preview (e.g. a tap), see CameraController.focusTo.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard