Innovus AI LtdField notes

· Computer vision

When OCR puts the right price on the wrong part

The hinge on this parts sheet has no price. A parser gave it 32.70, a number that appears on the sheet exactly once. Look one row down. That price belongs to the gasket.

Five printed rows. Bracket 12.40, hinge with no price, gasket 32.70, clip 18.50, washer 24.30.
The generated parts sheet used in the test.

I generated a five-row parts sheet with Python and ran Apple Vision’s text recognition on two full-height crops, one for each column. It read every printed label and price correctly. The mistake appeared in the next line of code. Pairing the lists with zip(labels, prices) assigned the gasket’s price to the hinge, shifted the next two prices, and dropped the washer entirely.

Two parsers, the same observations
ItemPrinted priceBy list positionBy row height
Bracket12.4012.4012.40
HingeBlank32.70Blank
Gasket32.7018.5032.70
Clip18.5024.3018.50
Washer24.30Missing row24.30

Each Vision observation includes a bounding box. I kept its vertical midpoint, converted it to distance from the top using 1 - boundingBox.midY, and paired each price with the nearest item row. The crops both span the full height, so their vertical coordinates are comparable. The script rejects a match farther away than 40% of the median item-row spacing and rejects a second price assigned to the same row. The hinge keeps an empty cell. Apple’s bounding-box coordinates

Both parsers used the same OCR observations. List position recovered one of five rows. Matching by height recovered five of five on this synthetic, upright form. Test skewed scans, wrapped labels and missing item names separately before applying the rule to another layout.

Reproduce the result

Extract both source files into one directory on a Mac with Swift, the Menlo system font and Python’s Pillow package. From that directory, run:

python3 receipt_rows.py

The script generates the sheet, recognises two temporary images locally and removes them on exit. Tested on macOS 15.0.1, Swift 6.0.3, Python 3.9.6 and Pillow 11.3.0.

Download both files (.zip)

receipt_rows.py recognize.swift