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

OCR data tests are fallback-only

Deliberately placed outside `/blog` so it can be moved wherever it belongs.

The rule

OCR data tests — the stock `eng` traineddata and similar generic OCR models — should only be used when everything falls:every MRZ-model attempt has failed. They are never run first, never run by default, and never silently substituted for the MRZ model.

Why fallback-only

Benchmarked on 66 MRZ bands, stock `eng` data passes all check digits on 1/66 reads; the self-hosted MRZ model passes10/66. Running a weak data test first would produce wrong reads and false confidence. Keeping it as the last attempt of the engine ladder means the scan only degrades when the primary model genuinely cannot load.

Functionality is maintained

Fallback does not mean broken. The `sharedWorker` applies the same OCR parameters to every engine (MRZ whitelist `ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\u003c`, PSM 6 single text block), so on the `eng` fallback the scan still:

  • reads the MRZ band from the preprocessed photo,
  • ranks candidates by check digits passed,
  • applies look-alike repairs, and
  • lets the user send the result to Validate or Compare.

User involvement

The user is never left guessing which engine read their document:

  • `activeOcrEngine()` reports "mrz" or "eng", and the scan UI shows it on the result screen.
  • When `eng` was used, a "Try the MRZ model again" button resets the worker and retries the full ladder from the MRZ model.
  • Loading steps are reported while the ladder runs.

Failed engine loads are not cached, so the next read starts with the MRZ model again — no sticky degradation.

Related:

  • `lib/ocr/engine-ladder.ts` — ladder ordering and last-resort rule
  • `lib/ocr/shared-worker.ts` — shared worker, engine state, reset
  • `components/scan-flow.tsx` — user-facing engine notice and retry
  • `lib/ocr/engine-ladder.test.ts` — ladder behaviour tests
  • `README.md` — OCR engine fallback section
← Back to blog