Why OCR misreads your scan, and five fixes before you blame the engine
Most OCR errors aren't caused by the OCR engine. They come from the image you give it. Engines such as Tesseract are trained on clean, upright, evenly lit text, and every step away from that costs accuracy. Here is what
Most OCR errors aren't caused by the OCR engine. They come from the image you give it. Engines such as Tesseract are trained on clean, upright, evenly lit text, and every step away from that costs accuracy. Here is what usually goes wrong and what to do about it.
1. Resolution is too low
OCR works best when capital letters are roughly 20β30 pixels tall. That usually means scanning at 300 DPI. A 72 DPI screenshot of small print gives the engine blobs instead of letters. Upscaling a tiny image helps a bit, but rescanning helps far more.
2. The page is tilted or rotated
A few degrees of skew is enough to break line detection. Tesseract can report orientation for you:
tesseract scan.png - --psm 0
Rotate or deskew first, then run the real pass.
3. Uneven lighting and shadows
Phone photos often have a dark corner or a fold shadow. Converting to grayscale and applying adaptive (local) thresholding usually beats a single global threshold:
import cv2
img = cv2.imread("photo.jpg", cv2.IMREAD_GRAYSCALE)
bw = cv2.adaptiveThreshold(img, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C,
cv2.THRESH_BINARY, 31, 15)
cv2.imwrite("clean.png", bw)
4. The wrong language model
If the page is French and you run the English model, accented letters become junk, and words get "corrected" into English-looking nonsense. Pick the right model, and add a second one only when the page really mixes languages:
tesseract page.png out -l fra+eng
5. The PDF already has real text
Many PDFs aren't scans at all. If you can select text in a viewer, extract it directly instead of running OCR. Direct extraction is exact; OCR is an educated guess.
Always proofread
Even on a good scan, check numbers, names and look-alike characters (0/O, 1/l/I, rn/m). OCR gives you a fast first draft, not a final copy.
Disclosure: I run GoToolsOnline. Its free Document OCR tool reads images and scanned PDFs in 21 languages and tells you which PDF pages already contain real text.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.