DEV Community

Noble Ronin
Noble Ronin

Posted on

Tesseract Read a Bank Statement and Silently Dropped the Decimal Point in 3 Amounts

I keep seeing "just OCR it" in threads about invoices, receipts and bank statements. So I ran
plain Tesseract (eng, default settings, no preprocessing) on a handful of public test images,
including a bank statement, and compared every number it returned with the image.

The headline

The bank statement came back with a confidence of 83 and text that looks perfect at a
glance. Three amounts out of about twenty-five lost their decimal point:

image says Tesseract returned
14.54 1454
32,414.50 3241450
70.51 7051

No warning, no low-confidence marker on those lines, nothing in the output that tells you
which numbers to distrust. 14.54 became 1454: a 100× error that will happily sum in a
spreadsheet.

It also flattened the table: Debits and Credits are separate columns in the image, but the
text has one number per line with no column, so you can't tell a debit from a credit without
re-parsing the layout yourself.

What it handled well

  • Clean printed text: a scanned poem and a test paragraph came back word-perfect at confidence 92–94.
  • Rotated images: the same image rotated 90° and 180° still came back as Tesseract.js, confidence 91.
  • Speed and cost: nine images across two runs took under 9 seconds and well under a tenth of a cent of compute.

Two quieter failures

  • It "fixed" a deliberate zero. The test image says Hell0 World with a zero; Tesseract returned HellO, with a letter O. Fine for prose, wrong for serial numbers, codes and IDs.
  • Wrong language = garbage with a tell. A Traditional Chinese image read with eng returned FRET OCHE at confidence 0. That one, at least, is easy to catch: a confidence of 0 almost always means the wrong language model (it needs chi_tra).

My takeaways

  1. Confidence is per image, not per number. An 83 says nothing about which amount is wrong.
  2. For money, validate. Check that balances add up row by row; the three errors above all break the running balance, so a simple check would have caught them.
  3. Tables need layout, not just text. If columns matter, use word boxes/positions, or a tool built for tables.
  4. Set the language. eng+fra, deu, ron, chi_tra… and treat confidence 0 as "wrong language", not "empty image".

If you want to try the same thing

The setup above runs as an Apify Actor: a list of image URLs in, one row per image with
text, confidence, words, lines out; images without text are not billed. $2.50 per
1,000 images with text: Image OCR — Extract Text from Images in Bulk.
The cheatsheet with the Tesseract commands and the validation checks is on GitHub:
noble-ronin/tesseract-ocr-pitfalls.

Your turn

What do you put after OCR when the numbers matter: balance checks, a second OCR engine, an
LLM pass, a human? I'm curious which one actually catches the dropped-decimal case in practice.

Top comments (1)

Collapse
 
smtahosin profile image
S M Tahosin •

Balance check is the one I'd trust first, because it doesn't care how confident the OCR felt. A dropped decimal breaks the running total every time, so the row flags itself. I'd pair it with a strict money pattern before parsing, something that requires the decimal part and rejects a bare 1454 instead of quietly turning it into a valid number, then send only the flagged rows to a human. An LLM pass worries me here, it tends to fix numbers into whatever looks plausible. Did the per-word confidence in the TSV output dip at all on those three amounts, or were they high confidence too?