Your win for this lesson: explain what reads the image, what chooses
the payable amount, what keeps the suggestion safe—and why the package
never writes an expense itself.
Recognition and persistence are separate responsibilities
payable-receipt-ocr is a local Python module. An application may call
it directly or through an adapter, but authentication, expense
validation, and persistence remain the application's responsibility.
Consumer · your application
Expense application
Owns people, groups, expenses, authentication, UI, validation, and
persistence.
Input: an authorized image and currency context
Review: the user edits or confirms the
suggestion
Data: the application owns all persistence
Module · Python package
payable-receipt-ocr
Turns a local screenshot into ranked amount evidence and a
confirmation-only suggestion.
Image: Pillow, NumPy, OpenCV
Reading: Tesseract 5 through pytesseract
Decision: Python rules, Decimal, JSON
Optional adapter · not included
Self-hosted HTTP adapter
Can expose the Python interface over HTTP without gaining
permission to save expenses.
Input: authorized receipt image
Output: amount, currency, evidence, warnings
Guard: user confirms before app persistence
Interactive trace
Click each stage: image → evidence
The recognizer is a pipeline. Each stage produces a more useful
representation, but only the final human confirmation makes the
suggested total usable in an expense.
1 · Input is evidence, not an expense
The package accepts JPG, PNG, or WebP. Pillow fixes EXIF orientation
and converts the image into a predictable RGB representation. No
database record is created here.
OpenCV's official guide explains why adaptive thresholding helps when
illumination varies; pytesseract's official repository explains that
image_to_data returns boxes, confidence, and other
recognition metadata.
OpenCV source
·
pytesseract source
Technology roles
Do not confuse the reader with the judge
Pillow + OpenCV prepare pixels
Pillow loads and orients the file. OpenCV converts, deskews,
resizes, normalizes, and thresholds it. Neither decides which
rupee value is the final payment.
Tesseract reads visible text
Tesseract is the OCR engine. pytesseract calls that executable
from Python and returns text, geometry, and confidence. It may
read several plausible numbers incorrectly.
Python interprets receipt meaning
Repository code identifies money, recognizes labels, groups
agreement across passes, and ranks payment labels above fallback
totals. Decimal keeps currency math exact.
The user authorizes the expense
requires_confirmation is always true. Even “strong”
means “safe to suggest,” never “safe to silently save.”
Caller-owned persistence belongs after confirmation, not before
it.
Answer without scrolling upward. Immediate feedback builds a more
durable mental model than rereading alone. Score:
0 / 4
Which component actually recognizes text?
What is the package-to-application relationship?
What happens after OCR suggests a total?
Which three dimensions create 12 OCR passes?
Teach-back drill
Explain the flow in your own words
Imagine a teammate asks, “What happens when we give this system a
Zepto screenshot?” Write a short explanation from memory. The
checker looks for five architectural ideas, not exact phrasing.
Start writing to see which concepts you recovered.
Read only the introduction and command-line usage sections. Your
goal is to recognize Tesseract as the OCR engine and understand that
language data, OCR-engine mode, and page segmentation are explicit
inputs—not magic hidden inside Python.