scan

fun <F> MrzFrameAnalyzer<F>.scan(frames: Flow<F>, releaseFrame: (F) -> Unit = {}, captureErrorFor: (Throwable) -> CameraError? = { null }): Flow<MrzScanResult>

Turns a stream of platform frames into MrzScanResults, one per frame, in order.

It calls releaseFrame on each frame after analysis. If frames fails, captureErrorFor maps the failure to a CameraError, which is emitted as a final MrzScanResult.CaptureError and ends the flow. A null mapping rethrows the failure. Coroutine cancellation propagates.

Return

the results, one per frame the flow delivers.

Parameters

frames

the frame stream. A failure of this flow is treated as a capture failure.

releaseFrame

releases a frame after it is analysed, for example ImageProxy::close. The default does nothing.

captureErrorFor

maps a frames failure to the CameraError to report, or null to rethrow it. The default rethrows.