Runs in your browser. Your document data is not uploaded or stored.

OCR data tests used only as fallback

News · OCR · `eng` data · MRZ model · scan flow

The short version

In the MRZ Toolkit's client scan, generic OCR data tests (the stock `eng` traineddata) are a fallback of last resort. The self-hosted MRZ model is tried first, then re-downloaded, and only if both attempts fail does the scan use `eng`. The user is shown which engine produced the result and can retry the MRZ model at any time.

Why this matters

On 66 MRZ bands, the MRZ model passes all check digits on 10 reads; stock `eng` passes on 1. Running `eng` first would trade accuracy for nothing. Fallback-only ordering keeps the strong path strong while still giving a usable read when the MRZ model cannot load.

Nothing is lost on fallback

The same whitelist and page-segmentation mode apply to every engine, so the fallback still reads the band, ranks candidates, applies repairs, and feeds Validate or Compare. Functionality is maintained; only accuracy differs — which is exactly why the user is told.

User involvement

  • Loading steps are reported while the engine ladder runs.
  • The result screen names the engine (`mrz` or `eng`).
  • "Try the MRZ model again" resets the worker and retries from the primary model; failed loads are never cached.

Code:

  • `lib/ocr/engine-ladder.ts`
  • `lib/ocr/shared-worker.ts`
  • `lib/ocr/index.ts`
  • `components/scan-flow.tsx`
  • `lib/ocr/engine-ladder.test.ts`
← Back to blog