OCR, Detection and Vision-Language Models
Engineering

OCR, Detection and Vision-Language Models

Reading a code, finding an object and describing a scene are different tasks; the output you have to verify decides which one you need.

Short answer

OCR turns the text in an image into characters, object detection returns boxes showing where known objects are and how many there are, and a vision-language model writes a free-text answer about the image. Use OCR with validation when the output must match a format or expected value, detection for presence and position, and a vision-language model for open-ended questions a person will review.

What is the difference between OCR, object detection and a vision-language model?

They answer different questions and return different outputs. OCR (optical character recognition) turns pixels into characters: it tells you what text is printed and where. Object detection finds known things in an image and returns a box and a class for each one: it tells you what is there, where, and how many. A vision-language model (VLM) takes an image and a question in natural language and writes an answer in natural language: it can describe, compare and explain. "Image recognition" is the umbrella term people use for all of these, which is why projects often start with the wrong one.

The practical difference is in what you can check. An OCR result can be compared character by character with what should have been printed. A detection result can be compared box by box with what a person marked. A VLM answer is free text, so checking it means reading it against the image. The more exact and traceable the output must be, the further you should stay from free text.

ApproachOutputTypical questionHow you measure it
OCRText, with the position of each word or line and a confidence scoreWhat lot code and expiry date are printed on this label?Character error rate and exact match per field
Barcode or 2D code readingThe encoded value, decoded directly from the symbolWhich product and batch does this DataMatrix code carry?Read rate and misread rate
ClassificationOne label for the whole imageIs this part acceptable or defective?Precision and recall per class
Object detectionBoxes with a class and a confidence scoreAre all four caps present, and where?Precision and recall at a given overlap (IoU)
SegmentationA pixel mask per object or defectHow large is the scratch?Mask overlap and area error
Vision-language modelFree-text answer about the imageWhat seems wrong in this maintenance photo?Claim-by-claim review by a person

How do you choose the right task?

Write down the output your process needs before choosing a model: the fields, the allowed characters, the position, what happens at low confidence, and which system receives the result. Then work through these questions in order and stop at the first "yes":

  1. Is the information encoded in a barcode or 2D code? Use a code reader. The value is encoded for machines, and decoding it directly is a more reliable check than reading the printed digits next to it with OCR.
  2. Is the output an exact string that must match a format or an expected value? Use OCR followed by validation: format rules, check digits, and comparison with the value the production system expects.
  3. Is the question whether known objects are present, where they are, or how many? Use object detection. If one label for the whole image is enough, classification is simpler; if the size or shape of a region matters, use segmentation.
  4. Do the images vary widely, is the question open-ended, and can a person review each answer? A vision-language model may fit, as a drafting or triage aid.
  5. Must the answer be exact, and is a wrong answer costly? Do not let a VLM be the only reader. Use it alongside one of the steps above or route the case to a person.

Many real flows combine steps: a detector finds the label, OCR reads it, rules validate it, and a person sees only the doubtful cases. Add a component only when the output requires it.

When is OCR enough, and when does it need help?

OCR is enough when the text is legible, large enough and in a predictable place. Microsoft documents the output of its Document Intelligence Read model as lines and words with bounding polygons and a confidence per word, and sets a practical floor: the minimum text height is 12 pixels in a 1024 × 768 image, about 8-point text at 150 dpi. The same page points to a separate Read feature, optimised for general images rather than documents, for labels, signs and posters. These limits are a useful first test for camera placement: if a lot code is only 8 pixels tall in your frame, no recognition engine will make it reliable.

OCR needs help in three common situations. First, when several pieces of text appear and only one is authoritative: a fixed crop (for a fixed camera and fixture) or a detector should select the region before reading. Second, when lighting is uneven or the surface reflects. Tesseract's guide to improving OCR quality notes that the engine binarises images internally with Otsu's method, that the result can be poor when the background darkness is uneven, that it works best at 300 dpi or more, and that skew sharply reduces line segmentation quality. It also offers page segmentation modes for a single line or a single word, which suit cropped label fields. Third, when a misread must never pass silently: OCR confidence alone is not a guarantee, so validate every field against format rules and expected values.

Do not assume preprocessing always helps. Thresholding, sharpening and contrast changes can rescue faint print on one product and destroy it on another. Compare raw and prepared images on the same labelled sample before you keep any step.

What does object detection give you that OCR does not?

Detection answers presence, position and count questions: a missing cap, a part fitted in the wrong slot, a protective guard left open. It is evaluated by matching predicted boxes to boxes drawn by people. Ultralytics' guide to detection performance metrics defines IoU as the overlap between a predicted and a ground-truth box, precision as the share of positive predictions that are correct, recall as the share of real objects found, mAP50 at a 0.50 IoU threshold and mAP50-95 averaged across thresholds from 0.50 to 0.95. For a production line, pick the IoU threshold that matches the position tolerance your process actually needs, and report missed objects and false objects separately. A single mAP figure hides which error you are making.

When does a vision-language model make sense?

A VLM makes sense when images vary too much for a fixed set of classes and the output is meant for a person: describing damage in a field-service photo, summarising what differs between two images, or sorting incoming pictures into rough categories for review. It is weakest exactly where line inspection is strictest. Anthropic's vision documentation lists the limits plainly: the model may hallucinate or make mistakes with low-quality, rotated or very small images under 200 pixels; coordinate and localisation outputs are approximate; counts of many small objects are approximate; and images above the size limit are downscaled, which can make text less legible. The same page advises against using the model for tasks requiring perfect precision without human oversight.

So use a VLM to draft, triage or explain, keep the original image with its answer, and let a person or a deterministic check confirm anything that triggers an action.

Hypothetical example: checking a lot code on a bottle label

This is a hypothetical example to show the test design; the numbers are illustrative, not measured results. A filling line prints a lot code and expiry date on each label, and the goal is to stop bottles whose print does not match the current order. The flow is: camera trigger, fixed crop of the print area, OCR in single-line mode, then validation against the lot format and the expected value from the production system. Anything that fails validation or falls below a confidence limit goes to an operator screen.

The test set has 2,000 images of correct prints, collected across shifts, plus 200 deliberately misprinted labels, because a set of correct prints alone cannot measure the most expensive error: a wrong print being accepted. On the correct prints, 1,946 pass and 54 (2.7 percent) go to the operator, which is a review workload the team can staff. Of the 200 misprints, 199 are stopped. The one accepted misprint differs from the expected code only by a letter O in place of a zero, and the OCR read the letter as a zero. The fix starts with the test set, not a bigger model: add more O/0 and similar misprints, require a higher confidence when a read contains confusable characters, and send anything below it to review. The test is then repeated with the same images plus the new ones.

How should you measure each approach?

  • OCR: character error rate (edits needed to turn the read into the correct text, divided by the length of the correct text) and exact match per field. Report confusable pairs such as O/0, I/1 and S/5 separately.
  • Detection: precision and recall at your chosen IoU, broken down by object class and by condition.
  • VLM: a person checks each claim in a sample of answers against the image; track unsupported claims and how often the model says it cannot tell.
  • All three: build the test set from real conditions (blur, glare, rotation, worn print, packaging variants, every shift) and report the cost of a wrong acceptance separately from the cost of a manual review.

Common mistakes

  • Choosing a model before writing down the exact output and the system that consumes it.
  • Reading the printed text next to a barcode instead of reading the code itself.
  • Testing only on correct samples, so false acceptance is never measured.
  • Treating a VLM's description as a measurement of position, count or exact text.
  • Keeping preprocessing steps that were never compared with the raw image.

Selecting the task, testing it under line conditions and connecting the result to an existing system is the scope of our computer vision and image recognition service. For how multimodal models handle images and text together, see our guide to multimodal AI.

Key takeaways

  • Write the exact output, allowed characters and receiving system before choosing between OCR, detection and a vision-language model.
  • Read barcodes and 2D codes with a code reader, and validate every OCR field against format rules and expected values.
  • Check that text in your camera frame clears the engine's minimum character height before tuning any model.
  • Report detection precision and recall at an IoU that matches the line's position tolerance, not one mAP figure.
  • Use a vision-language model to draft and triage; leave exact reads and actions to deterministic checks or a person.
  • Put deliberately wrong samples in the test set so that false acceptance is measured.

Frequently asked questions

Is OCR a type of image recognition?

In the broad sense, yes: image recognition is the umbrella term for software that extracts information from images, and OCR is the part that extracts text. In a project, though, OCR, detection and classification are separate tasks with different training data, outputs and acceptance tests.

Can a vision-language model replace OCR?

Not where the text must be exact and traceable. Anthropic's vision documentation notes that the model can make mistakes with low-quality, rotated or very small images, and that oversized images are downscaled, which can reduce legibility. Use a vision-language model to describe or triage, and OCR with validation for codes and dates.

How small can text be for OCR to read it?

It depends on the engine and the image. Microsoft documents a minimum text height of 12 pixels in a 1024 × 768 image for its Read model, about 8-point text at 150 dpi, and Tesseract works best at 300 dpi or more. Measure the character height in your own camera frame before choosing a model.

Should product labels be read with OCR or a barcode reader?

If the information is in a barcode or 2D code, read the code: the value is encoded for machines, and decoding it directly is a more reliable check. Use OCR for information that is printed only as text, such as some lot codes and dates.

How do you measure OCR accuracy?

Use character error rate, the number of edits needed to turn the read text into the correct text divided by the length of the correct text, together with exact match per field. Report confusable pairs such as O and 0 separately, and include deliberately wrong prints so false acceptance can be measured.

All articles