Preview
A CameraPreviewOutput streams the camera feed to a preview view.
With Compose, Camera displays its own preview. To use your own outputs, create a preview output and display it with NativePreviewView:
val previewOutput = rememberPreviewOutput()
rememberCamera(isActive = true, device = TargetCameraPosition.BACK, outputs = listOf(previewOutput))
NativePreviewView(
previewOutput = previewOutput,
modifier = Modifier.fillMaxSize(),
resizeMode = PreviewResizeMode.COVER,
)
Without Compose, use the platform PreviewView (an Android View, or a UIView on iOS) and set its previewOutput.
resizeMode:COVERfills the view and crops the feed,CONTAINfits the whole feed in the view.implementationMode(Android only):PERFORMANCEuses aSurfaceView,COMPATIBLEuses aTextureViewthat supports transformations and animations.
Snapshots
On Android, takeSnapshot() (on the PreviewView, a PreviewViewRef or a CameraRef) returns the preview’s current contents as an Image, much faster than a photo capture. Like VisionCamera, it is not available on iOS and throws.