rememberFrameOutput
fun rememberFrameOutput(options: FrameOutputOptions = FrameOutputOptions(), onFrameDropped: (reason: FrameDroppedReason) -> Unit? = null, onFrame: (frame: Frame) -> Unit?): CameraFrameOutput
Create a CameraFrameOutput with the given options, kept across recompositions and recreated when the options change (the equivalent of VisionCamera's useFrameOutput).
onFrame runs on the output's thread (not the main thread) for every Frame, and must dispose it as soon as possible. The latest onFrame is always used, without recreating the output.
val frameOutput = rememberFrameOutput(FrameOutputOptions(pixelFormat = TargetVideoPixelFormat.YUV)) { frame ->
frame.use {
// processing...
}
}
Camera(device = TargetCameraPosition.BACK, isActive = true, outputs = listOf(frameOutput))Content copied to clipboard
onFrameDropped is called when a Frame has been dropped, e.g. because onFrame takes longer than a frame interval.