ScanWisp ← Back to ScanWisp

OCR accuracy test: how to measure it on your own documents

A vendor's "99% accurate" is measured on somebody else's paper. If you need to know whether OCR will handle your receipts, your lab reports or your passport, you have to test your own pages — and you can do it in under an hour with a text file, a spreadsheet and a short script.

· Explainer · 9 min read

Disclosure: we build ScanWisp, which runs OCR locally in the browser. This guide describes a measurement method rather than publishing a headline accuracy figure, because a single figure would hide exactly the differences the method is meant to expose.

I've read a lot of scanner marketing. The accuracy claims are almost never false in the narrow sense. They're measured on a clean, flat, well-lit corpus in a handful of languages, at a resolution you'll never reproduce with a phone over a kitchen table. Then the number gets printed next to a picture of someone scanning a crumpled receipt, and the implication does the rest.

The useful question isn't "how accurate is this OCR?" It's "how accurate is it on the pages I actually have, in the language I actually need, and what kind of mistake does it make?" That question has a concrete answer, and you can get it yourself.

Why a single accuracy number tells you almost nothing

Four things move an OCR score, and marketing pages usually disclose none of them:

So the method matters more than the headline. The rest of this piece is the method.

Pick a metric you can defend

For most document work, character error rate (CER) is the honest starting point. It's the number of single-character edits — insertions, deletions, substitutions — needed to turn the OCR output into the correct text, divided by the number of characters in the correct text.

Word error rate (WER) is the same idea at word level. It's more intuitive for prose and less useful for identifiers, because one wrong character in a long word still counts as one word error, while one wrong character in a short number is also one word error. For invoices, passport numbers and lab values, CER plus a field check is better.

Here's the arithmetic, with made-up numbers so the shape is clear. Suppose a page has 1,000 characters after normalisation and the OCR output needs 3 edits to match. That's a CER of 0.003, or 0.3%. On an A4 page of about 2,000 characters, the same rate is roughly six wrong characters per page. That's usually fine for search and usually not fine for a bank account number. The rate is the same; the consequence isn't.

Decide the normalisation rules before you score, and write them down. At minimum: case, whitespace, line breaks, curly versus straight quotes, en dash versus hyphen, and whether accents count. Apply the same rules to the reference text and the OCR output. If you change the rules halfway through, you're not measuring the tool any more.

Build a sample set that looks like your paper

Ten pages is enough to see a pattern; twenty gives you more confidence. The point is variety, not volume. Include the conditions you actually scan in, including the bad ones. A test set of ten perfect laser prints will tell you what you already know.

Page typeWhat it stressesWhat to record
Clean laser printThe easy case. Establishes your ceiling.CER, time
Phone photo at an anglePerspective correction and edge detection.CER before and after correction
Low light or hard shadowThresholding and contrast enhancement.CER, visible dropouts
Thermal receiptFaint, narrow, curled paper.CER on amounts and dates
Form with handwritingPrinted labels plus handwritten answers.Which fields survived
Table of numbersReading order and decimal points.Field-level accuracy
Two languages on one pageModel selection and script switching.CER per language
Small print and footnotesResolution limits.CER on the smallest text
Stamped or initialled pageOverlapping marks.Missed or merged characters
Glossy or laminated pageGlare and specular highlights.Which lines were lost

If you're testing two tools, use the same photographs for both. Don't let each app take its own picture; you'd be comparing cameras and auto-capture, not OCR.

Type the ground truth yourself

This is the tedious part and it's the part that makes the result trustworthy. Open each page and type what it says into a plain UTF-8 text file. Don't copy from an OCR result, even a different tool's; that just measures agreement between two engines.

Keep one file per page: p01-truth.txt, p01-ocr.txt, and so on. When you change a setting, save the OCR output under a new name rather than overwriting it. Future you will want the comparison.

Run the test and score it

For each page, record the conditions before you look at the result: device, browser or app version, language selected, enhancement mode, whether the image was corrected, and how long recognition took. A score without those notes is hard to interpret later.

ScanWisp can export the recognised text as TXT, which is exactly what you need for scoring. Other tools often bury the text inside the PDF; if there's no TXT export, you can extract the text layer with a PDF tool, but be aware that some extractors reorder columns.

Side-by-side comparison of a scanned page on the left and the exported plain-text file on the right in a text editor.
The same page as an image and as exported TXT. The words survive, the layout does not: line breaks, columns and reading order are exactly what you need to check when scoring.

Then score. You can do this by hand for a small set, but a script removes arithmetic mistakes. This is a complete, dependency-free Python program: give it the truth file and the OCR file, and it prints the character count, the edit count and the CER.

import re
import sys
import unicodedata

def normalise(text):
    text = unicodedata.normalize("NFC", text)
    text = text.casefold()
    text = re.sub(r"[\u2018\u2019]", "'", text)
    text = re.sub(r"[\u201c\u201d]", '"', text)
    text = re.sub(r"[\u2013\u2014]", "-", text)
    text = re.sub(r"\s+", "", text)
    return text

def edit_distance(a, b):
    previous = list(range(len(b) + 1))
    for i, char_a in enumerate(a, 1):
        current = [i]
        for j, char_b in enumerate(b, 1):
            current.append(min(
                previous[j] + 1,
                current[j - 1] + 1,
                previous[j - 1] + (char_a != char_b),
            ))
        previous = current
    return previous[-1]

truth = normalise(open(sys.argv[1], encoding="utf-8").read())
ocr = normalise(open(sys.argv[2], encoding="utf-8").read())

if not truth:
    sys.exit("truth file is empty after normalisation")

edits = edit_distance(truth, ocr)
print(f"characters={len(truth)} edits={edits} CER={edits / len(truth):.4f}")

The script strips all whitespace before comparing, so it measures character fidelity and ignores word spacing. That's deliberate for identifiers and CJK text. If spacing matters for your document, score word by word as well, using the same normalisation except the whitespace step.

One caveat: the edit distance is quadratic in the length of the strings. A single page is fine. If you feed it a 40-page book as one string, it will be slow. Score page by page.

A scorecard you can fill in

Copy this into a spreadsheet and add a row per page. Leave the result columns blank until you have actually run the page; the table below is a template, not a set of results.

PageCategoryCharactersEditsCERNotes
p01Clean print————
p02Angled photo————
p03Low light————
p04Receipt————
p05Form + handwriting————
p06Numeric table————
p07Two languages————
p08Small print————

Report the results by category, not as one average. "4% on receipts, 0.4% on clean print" is a useful finding. "1.8% overall" hides the only number you needed.

The errors worth looking for

CER tells you how much went wrong. Reading the diffs tells you what went wrong, which is what determines whether you can trust the output. These are the patterns I look for first.

PatternExampleWhy it happensWhat to do
Lookalike lettersrn → m, 1 → l or ISimilar shapes at low resolution. Raise the effective resolution; check names and codes by eye.
Digit/letter swaps0 → O, 5 → S, 2 → ZSame reason, worse on sans-serif fonts.Never trust an identifier without a second look.
Lost decimal points1.50 → 150The dot is a few pixels; thresholding erases it.Use grayscale rather than hard black and white for numeric pages.
Accents strippedcafé → cafe, Müller → MullerModel or normalisation drops the diacritic. Choose the right language; check names against the original.
German ßStraße → StrasseTransliteration, not necessarily an error.Decide whether your downstream system expects the substitution.
CJK confusables未 vs 末, 己 vs 已One stroke apart.Read names and addresses against the image.
Japanese small kanaっ → つ, ゃ → やSize distinction lost at low resolution.Higher resolution; proofread kana-dependent words.
Korean jamo compositionSyllables split or recomposed incorrectly Different Unicode composition paths.Normalise to NFC before comparing, and check names.
Table reading orderColumns merged into one lineOCR returns text boxes, not a table model.Don't rely on layout; extract fields individually.
Hyphenated line breaksdocu- / ment The line break is in the image.Join and dehyphenate during normalisation.
Stamps over textWords merged or dropped under a sealTwo ink layers at different contrast.Rescan in colour; expect manual fixes in stamped areas.
HandwritingNames and dates replaced by plausible nonsense Models are trained mostly on print.Treat handwritten fields as unread unless verified.

That last row matters more than its position suggests. A wrong printed character usually looks wrong. A wrong handwritten word often looks plausible, which is worse, because nothing prompts you to check it.

What the result actually licenses you to do

A CER number doesn't have a universal pass mark. It has a pass mark for a job.

This is why "searchable PDF" and "data extraction" are different products. A searchable PDF can be useful at 97% character accuracy because you're using it to find a page. A spreadsheet of invoice totals at 97% is a liability.

How ScanWisp's OCR is set up

ScanWisp ships 66 languages and marks six as verified: Chinese, English, Japanese, German, French and Korean. The rest are best-effort, and the language list says so instead of implying uniform quality. Models are grouped by script: German and French share the Latin model, Chinese, Japanese and English share the main CJK model, and Korean loads its own.

Two practical consequences for testing. First, choose the document's language explicitly; leaving it on the wrong model produces confident text with the wrong language assumptions, and across scripts it can return the wrong alphabet entirely, which is harder to spot than an empty result. Second, the first scan in a script group downloads its model, so exclude that run from any timing comparison. Recognition after that runs locally, and the searchable PDF explainer covers what the text layer actually contains.

We don't publish a single accuracy figure for the app, and this guide is the reason. The number would depend on your pages, your language and your lighting. The claim we can defend is narrower and more useful: the recognition runs on your device, and you can test the result yourself before trusting it.

If you're comparing two tools

Fair comparison is mostly about removing the ways the comparison can flatter one side.

  1. Use one set of source images. Same photos, same crops, same rotation, fed to both tools.
  2. Set the same language. If one tool auto-detects and the other doesn't, run the auto-detect tool twice and report both.
  3. Use the same normalisation. Same script, same rules, same whitespace handling.
  4. Score by category. One tool may win on clean print and lose on receipts; an average would erase that.
  5. Record time and offline behaviour. A tool that needs a network round trip per page behaves differently on a plane, and the difference is part of the product.
  6. Check what the export gives you. A TXT file and a PDF with a text layer are not the same artefact, and one may be easier to score than the other.

And be suspicious of tools that "clean up" the text with a language model after OCR. They can turn a misread word into a fluent one, which improves the reading experience and quietly invents content. Check numbers and names against the image, not against what the sentence ought to say.

Questions about OCR testing

What is a good character error rate?

There isn't a universal one. For search, a few percent is workable. For identifiers or money, the only acceptable rate in those fields is zero. Decide the job before you decide the threshold.

Why does OCR fail on handwriting?

Recognition models are trained mostly on printed glyphs. Handwriting varies by writer, speed and pen, so there's far less consistent signal to learn. Printed labels on a form usually read fine; the handwritten answers are the part to verify.

Why are numbers worse than words?

Context helps. A language model can guess that "reciept" means "receipt", but it can't guess whether a digit should be 3 or 8. Numbers have no redundancy, so every character has to be right on its own.

Do I need to write code to do this?

No. A spreadsheet with a character count and a manual edit count works for ten pages. The script just removes arithmetic mistakes and makes re-scoring after a settings change less tedious.

Can I compare the accuracy numbers vendors publish?

Only if they disclose the corpus, the language, the metric and the image conditions. Without those, the number is a mood, not a measurement.

Run the test on your own worst page. ScanWisp exports the recognised text as TXT, and a PDF can carry the same text as an invisible layer, so you can score the output with the method above. No account, no upload, and the model runs in the tab.

Scan a document

Related