MrzFrameAnalyzer

class MrzFrameAnalyzer<F>(recognizer: MrzTextRecognizer<F>, mode: ParsingMode = ParsingMode.STRICT, telemetry: TelemetrySink = TelemetrySinkRegistry.current, referenceTimeProvider: () -> Instant = { Clock.System.now() })

Analyses one camera frame: runs OCR, locates an MRZ, parses it, and returns a MrzScanResult.

Before parsing it folds case to upper and maps out-of-alphabet chevron glyphs to <; ParsingMode.LENIENT also removes spaces. When no MRZ of exact width is found, a name line read short is padded with < at the end, and the result says so (see MrzFillerPadding). The raw OCR text stays on every result. The analyzer emits one CameraFrameEvent per frame. It reads a frame but never closes or retains it: the caller releases the frame after analyse returns.

Since

0.2.0

Parameters

recognizer

the OCR engine.

mode

how tolerant candidate extraction is of OCR formatting noise. The default is ParsingMode.STRICT.

telemetry

where per-frame CameraFrameEvents go. The default is the sink registered when the analyzer is constructed, or NoOpTelemetrySink when none is registered.

referenceTimeProvider

supplies the reference instant for date parsing. The default is the system clock.

Type Parameters

F

the platform frame type, for example ImageProxy on Android.

Constructors

Link copied to clipboard
constructor(recognizer: MrzTextRecognizer<F>, mode: ParsingMode = ParsingMode.STRICT, telemetry: TelemetrySink = TelemetrySinkRegistry.current, referenceTimeProvider: () -> Instant = { Clock.System.now() })
constructor(recognizer: MrzTextRecognizer<F>, provenance: FrameProvenance, mode: ParsingMode = ParsingMode.STRICT, telemetry: TelemetrySink = TelemetrySinkRegistry.current, referenceTimeProvider: () -> Instant = { Clock.System.now() })

Creates an analyzer that stamps provenance as the reading method of every result.

Functions

Link copied to clipboard
suspend fun analyse(frame: F): MrzScanResult

Analyses a single frame and returns the result.

Link copied to clipboard
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.