DocumentScanScreen

fun DocumentScanScreen(modifier: Modifier = Modifier, state: ScanScreenState = rememberScanScreenState(), isDetectionEnabled: Boolean = true, flashMode: FlashMode = FlashMode.AUTO, jpegQuality: Int = DEFAULT_JPEG_QUALITY, previewScaleType: PreviewScaleType = PreviewScaleType.FIT, shutterAnimationEnabled: Boolean = false, overlayColor: Color = Color.Blue, autoTriggerAnimationEnabled: Boolean = false, onBorderDetectionResult: (QuadStreamAnalyzer.Result) -> Unit = { _ -> }, onBorderDetectionFailure: (Exception) -> Unit = { _ -> }, onCameraReady: () -> Unit = {}, onCameraFailure: (Exception) -> Unit = {}, onShutterTriggered: () -> Unit = {})

Displays a camera preview that detects documents and draws their boundaries.

The caller must obtain the Android camera permission before adding this composable to the composition. Use state to take a picture. Camera resources are released when this composable leaves the composition.

Parameters

modifier

Modifier applied to the camera screen.

state

State used to take pictures from this screen.

isDetectionEnabled

Whether document detection is enabled. Disabling detection does not stop the camera preview.

flashMode

Flash mode used by the camera.

jpegQuality

JPEG quality in the range 0–100.

previewScaleType

Whether the preview fits within or fills its available bounds.

shutterAnimationEnabled

Whether taking a picture displays a shutter animation.

overlayColor

Color used to draw the detected document boundary.

autoTriggerAnimationEnabled

Whether the document boundary displays auto-trigger progress while the detector reports QuadStreamAnalyzer.Status.ABOUT_TO_TRIGGER. This option does not take a picture automatically.

onBorderDetectionResult

Called with the latest document detection result. Call ScanScreenState.takePicture when the result status is QuadStreamAnalyzer.Status.TRIGGER to implement automatic capture.

onBorderDetectionFailure

Called when a preview frame cannot be analyzed.

onCameraReady

Called when the camera is initialized and ready to take pictures.

onCameraFailure

Called when the camera cannot be initialized.

onShutterTriggered

Called when image capture starts.