CameraPreview

fun CameraPreview(modifier: Modifier = Modifier, cameraSession: CameraSession, camSelector: CamSelector = cameraSession.state.camSelector.value, captureMode: CaptureMode = cameraSession.state.captureMode.value, captureStrategy: ImageCaptureStrategy = cameraSession.state.imageCaptureStrategy.value, scaleType: ScaleType = cameraSession.state.scaleType.value, imageAnalyzer: ImageAnalyzer? = null, camFormat: CamFormat = cameraSession.state.camFormat.value, implementationMode: ImplementationMode = cameraSession.state.implementationMode.value, isImageAnalysisEnabled: Boolean = imageAnalyzer != null, isFocusOnTapEnabled: Boolean = cameraSession.state.isFocusOnTapEnabled.value, isPinchToZoomEnabled: Boolean = cameraSession.state.isPinchToZoomEnabled.value, previewBackgroundColor: Color = Color.Unspecified, onPreviewStreamChanged: () -> Unit = {}, switchCameraContent: @Composable (ImageBitmap) -> Unit = {}, onFocus: suspend (onComplete: () -> Unit) -> Unit = { onComplete -> delay(1000L) onComplete() }, focusTapContent: @Composable () -> Unit = { SquareCornerFocus() }, content: @Composable BoxScope.() -> Unit = {})

Creates a Camera Preview's composable.

Parameters

cameraSession

camera session, hold state, info and camera's controller

camSelector

camera selector to be added, default is CamSelector.Back

captureMode

camera capture mode, default is CaptureMode.Image

captureStrategy

camera image capture mode, default is ImageCaptureStrategy.MinLatency for better performance

scaleType

scale type to be added, default is ScaleType.FillCenter

imageAnalyzer
camFormat

camera format, default is CamFormat.Companion.Default

implementationMode

implementation mode to be added, default is ImplementationMode.Performance (Android Only)

isImageAnalysisEnabled

enable or disable image analysis

isFocusOnTapEnabled

turn on feature focus on tap if true and supported

isPinchToZoomEnabled

turn on feature pinch to zoom if true and supported

previewBackgroundColor

The preview background color to be added. This is necessary because non-fill scale types can display bars with the system background color, and it is not overridden by the modifier color.

onPreviewStreamChanged

dispatch when preview is switching to front or back (Android only)

switchCameraContent

composable preview when change camera, and it's not been streaming yet (Android only)

focusTapContent

content of focus tap, default is SquareCornerFocus

onFocus

callback to use when on focus tap is triggered, call onComplete to focusTapContent gone.

content

content composable within of camera preview.

See also