OCR for Shipping Labels That Are Never Perfectly Lit

Published 2026-08-27 by Faraz Rahimi

Warehouse labels are wrinkled, taped, and shot at an angle. A production OCR pipeline is mostly geometry and rejection, not a fancier model name.

OCR for Shipping Labels That Are Never Perfectly Lit

Tags: OCR, Computer Vision, Logistics, Python, Labels, unlisted

Shipping-label OCR fails for reasons that never show up in a blog screenshot. The label is on a curved poly mailer. Tape cuts a tracking number in half. Someone photographed the pallet, not the label.

If you send that image straight to a generic OCR API, you will get confident garbage. Confident garbage is worse than a retry prompt.

Fix the geometry first

I look for the label rectangle, deskew, and crop before any text recognition. A homography on a mostly-rectangular sticker does more for accuracy than swapping engines. When I cannot find a rectangle, I do not guess — I ask for a closer shot.

Lighting: I convert to a contrasty grayscale and try a second pass with a different threshold rather than one magic setting. Night-shift photos and day-shift photos are not the same dataset.

Validate like a clerk, not like a demo

A tracking number has structure. A ZIP has structure. If the regex fails, the result is not "almost." It is invalid. Show the crop to the operator and let them type one field, not the whole label.

The win is not 100% read rate. The win is killing re-typing of the 70% that are clean, and making the rest a 5-second correction instead of a 90-second form.

Original post: https://farazrahimi.com/posts/ocr-for-shipping-labels-that-are-never-perfectly-lit