rememberResizer
Use a Resizer with the given options (the equivalent of VisionCamera's useResizer).
The Resizer can be used to resize and convert Frames for ML processing. It is created asynchronously (the returned ResizerState is ResizerState.Loading meanwhile), kept across recompositions, recreated when the options change, and disposed once it leaves the composition (where V5 lets the garbage collector release it).
Inspect the returned ResizerState.error if the Resizer couldn't be created successfully.
val resizer = rememberResizer(
ResizerOptions(
width = 192,
height = 192,
channelOrder = ChannelOrder.RGB,
dataType = DataType.FLOAT32,
scaleMode = ScaleMode.COVER,
pixelLayout = PixelLayout.PLANAR,
),
).resizer
val frameOutput = rememberFrameOutput(FrameOutputOptions(pixelFormat = TargetVideoPixelFormat.YUV)) { frame ->
frame.use {
resizer?.resize(it)?.use { resized ->
val pixels = resized.getPixelBuffer()
// run your ML model...
}
}
}Content copied to clipboard
Parameters
options
The output size and format of the Resizer.