Quick reference · printable

Receipt OCR stack map

The compressed package architecture: what runs today, what every technology owns, and where an optional application adapter connects.

One-sentence model

Pillow and OpenCV prepare the image; Tesseract reads text; Python ranks payment candidates; evidence gates the suggestion; a human confirms; only the calling application may persist it.

Current architecture

One deep module, one consumer-owned decision

Public interface · caller runtime

  • Function: recognize(image, currency=...)
  • Result: typed total, currency, grade, warnings
  • Guard: requires_confirmation is always true
  • Privacy: diagnostics excluded by default
  • Side effects: no network and no persistence
  • Adapter: CLI included; HTTP left to the caller

Implementation · Python runtime

  • File handling: Pillow
  • Pixels: NumPy + OpenCV headless
  • Recognition: Tesseract 5 + tessdata_fast
  • Bridge: pytesseract
  • Interpretation: regex, Unicode normalization, Decimal
  • Output: evidence-rich internal result

Pipeline

Six transformations

# Owner Input → output Failure it addresses
1 Pillow file → oriented RGB image rotated phone screenshots
2 OpenCV image → grayscale + threshold views skew, contrast, dark UI
3 Tesseract pixels → text, boxes, confidence visible text recognition
4 Python rules text → money candidates saving/subtotal confusion
5 Evidence gate candidates → suggestion + grade unsafe certainty
6 Benchmark labeled corpus → readiness result anecdotal success
2 variants × 2 languages × 3 PSM layouts = 12 OCR passes

Meaning hierarchy

How the parser thinks about totals

Payment labels

Amount Paid, Paid by You, To Pay, Grand Total, Amount Due

Fallback totals

Total Bill Amount, Item Total & GST, MRP Total, generic Total

Negative evidence

Total Savings, discount, cashback, tendered cash, change

Safety contract

What output means

strong

Independent evidence agrees and competitors are safely behind. Still confirm.

review

A plausible suggestion exists, but evidence or competition is ambiguous. Confirm carefully.

none

No acceptable payment/fallback candidate was found. Enter the value manually.

Benchmark gate

Readiness is a conjunction

authorized ≥ 30 AND each app ≥ 10 AND exact ≥ 90% AND false-strong = 0 AND confirmation = 100%

The tuned public 35-image corpus reached 35/35, but it is in-sample exploratory evidence. The formal gate remains blocked until fresh authorized screenshots are labeled and tested.

Integration boundary

Future request path

authorized image
→ application or optional HTTP adapter
→ payable-receipt-ocr recognize(...)
→ { total, currency, grade, warnings, requires_confirmation }
→ user edits or confirms
→ caller validates the confirmed value
→ caller-owned persistence

Primary sources