Camera

fun Camera(device: CameraDeviceOrPosition, isActive: Boolean, modifier: Modifier = Modifier, outputs: List<CameraOutput> = emptyList(), constraints: List<Constraint> = emptyList(), mirrorMode: MirrorMode = MirrorMode.AUTO, orientationSource: OrientationSource? = OrientationSource.DEVICE, zoom: Double? = null, exposure: Double? = null, torchMode: TorchMode? = null, controllerConfiguration: CameraControllerConfiguration = CameraControllerConfiguration(), sessionConfiguration: CameraSessionConfiguration = CameraSessionConfiguration(), resizeMode: PreviewResizeMode = PreviewResizeMode.COVER, implementationMode: PreviewImplementationMode = PreviewImplementationMode.PERFORMANCE, onControllerChanged: (CameraController?) -> Unit? = null, onSessionConfigSelected: (CameraSessionConfig) -> Unit? = null, onConfigured: () -> Unit? = null, onStarted: () -> Unit? = null, onStopped: () -> Unit? = null, onError: (Throwable) -> Unit = { println("VisionCamera error: $it") }, onInterruptionStarted: (InterruptionReason) -> Unit? = null, onInterruptionEnded: () -> Unit? = null, onSubjectAreaChanged: () -> Unit? = null, onUIRotationChanged: (rotation: Int) -> Unit? = null, onPreviewStarted: () -> Unit? = null, onPreviewStopped: () -> Unit? = null, enableNativeZoomGesture: Boolean = false, enableNativeTapToFocusGesture: Boolean = false, ref: CameraRef? = null)

A Camera view (the equivalent of VisionCamera's <Camera />): it creates a preview output, runs a session with it and the given outputs (see rememberCamera), and displays the preview.

Camera(
device = TargetCameraPosition.BACK,
isActive = true,
modifier = Modifier.fillMaxSize(),
)

Parameters

device

The me.nathanfallet.visioncamera.CameraDevice to open, or a me.nathanfallet.visioncamera.TargetCameraPosition to use the default device at that position.

isActive

Starts the session when true, and stops it when false.

modifier

The Modifier of the preview.

outputs

Additional CameraOutputs, besides the preview.

constraints

Constraints the session tries to match, ranked by priority. Like VisionCamera's Camera, a ResolutionBiasConstraint for each output is added after them, with a lower priority.

mirrorMode

Whether the outputs are mirrored. MirrorMode.AUTO mirrors selfie cameras.

orientationSource

The OrientationSource whose orientation is automatically applied to all outputs (see CameraOutput.outputOrientation), or null to set it yourself (VisionCamera's 'custom').

zoom

The zoom value, applied declaratively.

exposure

The exposure bias, applied declaratively.

torchMode

The torch mode, applied declaratively.

controllerConfiguration

Low-light boost, smooth auto-focus and distortion correction.

sessionConfiguration

Session-wide configuration (iOS audio and haptics behavior).

resizeMode

How the Camera feed is scaled into the view's bounds.

implementationMode

Whether the preview uses a SurfaceView or a TextureView (Android only).

onControllerChanged

Called with the CameraController once the session is configured, e.g. to focus.

onSessionConfigSelected

Called once the constraints have been resolved.

onConfigured

Called whenever the session has been configured.

onStarted

Called when the session started.

onStopped

Called when the session stopped.

onError

Called when the session encountered an error.

onInterruptionStarted

Called when the session was interrupted.

onInterruptionEnded

Called when an interruption ended.

onSubjectAreaChanged

Called when the subject area substantially changes, e.g. when the user pans away from a scene previously in focus: a good point to reset locked focus. iOS only, like V5.

onUIRotationChanged

Called when the output orientation (driven by orientationSource) or the interface orientation changes, with the rotation in degrees (-90, 0, 90 or 180) that UI elements such as Camera controls need to appear upright.

onPreviewStarted

Called when the preview started streaming.

onPreviewStopped

Called when the preview stopped streaming.

enableNativeZoomGesture

Installs the native pinch-to-zoom gesture. zoom must then be null.

enableNativeTapToFocusGesture

Installs the native tap-to-focus gesture.

ref

A CameraRef exposing the controller and preview methods, see rememberCameraRef.