Skip to main content

Command Palette

Search for a command to run...

Industrial OCR vs OCV: A Practical Selection Guide

Updated
9 min readView as Markdown

Choose and validate the right method for reading, verifying, and judging date codes, lot codes, and serial text on production lines.

A camera returns 8B2407, the expected code is BB2407, and the application reports success because six characters were found. The image-processing step worked; the quality-control decision did not.

Industrial text inspection has three separate questions: Is text present and legible? What does it say? Is that string the correct one for this product and time? OCR, OCV, and business-rule validation answer different parts of that problem.

What you will learn

  • Distinguish optical character recognition (OCR) from optical character verification (OCV).

  • Size the image around character height and stroke width.

  • Stabilize print contrast and segmentation.

  • Add format, recipe, and database checks after recognition.

  • Validate character-level and string-level errors under line conditions.

Technical foundation

OCR

Optical character recognition determines which characters are present. A typical pipeline locates the text, segments or detects characters, classifies them, and returns a string with confidence values.

OCR is appropriate when the string is unknown in advance: serial numbers, variable lot codes, identifiers, or human-readable text that must be stored.

OCV

Optical character verification checks whether visible characters match an expected string or pattern. It is useful for expiry dates, fixed warnings, or product-specific codes already known from the recipe, PLC, MES, or database.

Cognex documentation describes OCV as verifying expected characters at expected positions. Some commercial tools share recognition and verification functions, so define the required behaviour rather than relying on a product label.

Legibility and correctness are separate

A correctly recognized wrong code is a process failure. A correct code printed faintly may be recognized in one image and fail in the field. A complete system can therefore include:

  1. Image-quality or print-quality checks

  2. OCR or OCV

  3. Syntax validation

  4. Recipe, date, checksum, or database validation

  5. Explicit unreadable/unknown handling

Character pixels and stroke width

Total character height alone is not enough. The narrowest stroke and gap must be represented with useful contrast. Small dot-matrix print may require more sampling than a solid laser-marked font of the same height.

[Suggested visual: OCR, OCV, and business-rule layers for one printed code]

Purpose: Show why reading a string is not the same as approving it.

Required elements: Camera image, recognized text, expected-text comparison, syntax/date check, and final result with separate reason codes.

Suggested caption: “Recognition reports what the image contains; verification and process logic decide whether it is acceptable.”

Accessible alt text: “A printed lot code passes through recognition, comparison with an expected string, and format validation before approval.”

Engineering workflow

1. Define the text requirement

Record the character set, font or marking method, number of lines, minimum character and stroke size, expected format, permitted position/rotation, and whether the actual string is known before inspection.

Why it matters: a known expiry string is a different problem from reading an arbitrary serial number.

2. Define quality and logic failures

Separate missing print, weak print, smeared print, extra character, wrong character, wrong sequence, wrong date, wrong product code, and unreadable image. Give each condition an action and reason code.

3. Design the image for segmentation

Choose lighting that separates ink, laser mark, embossing, or dot-peen features from the substrate. Use diffuse or coaxial lighting for many flat reflective labels, darkfield for some engraved features, and spectral filters where colour or ambient light matters.

Common failure: asking OCR to overcome glare that erases parts of a character.

4. Allocate sufficient pixels

Set a starting requirement for character height and, more importantly, pixels across the narrowest stroke. Validate with the actual font, print degradation, motion blur, and algorithm.

Trade-off: a tight ROI increases pixels per character but makes the system more sensitive to code position. Mechanical guidance or reliable registration can resolve this.

5. Choose OCR, OCV, or both

  • Use OCR when the text must be discovered and recorded.

  • Use OCV when the expected string is available and exact comparison is the main need.

  • Use OCR followed by semantic checks when the code varies but must follow rules.

6. Constrain the problem

Configure only the required character set and known format. A pattern such as AA-NNNNNN removes impossible substitutions. Use checksums, valid date ranges, prefix lists, or recipe data where the production specification allows them.

Do not use constraints to hide weak imaging. If O and 0 are indistinguishable in the image, fix the print or optics rather than relying only on context.

7. Define confidence and unknown handling

Treat character confidence as a score, not a calibrated probability unless demonstrated. Specify how low-confidence characters, partial strings, and timeouts are handled. “Unreadable” should not become “good.”

Worked example: sizing a lot-code image

Hypothetical application: a 2.5 mm-high inkjet lot code appears anywhere within an 80 mm-wide label zone. The initial design target is 20 pixels per character height.

Required sampling density:

20 px / 2.5 mm = 8 px/mm

Minimum horizontal pixels for the 80 mm FOV:

80 mm × 8 px/mm = 640 px

This is only a starting screen. Suppose the narrowest ink stroke is 0.25 mm. At 8 px/mm it spans:

0.25 mm × 8 px/mm = 2 px

Two pixels across a degraded stroke may be fragile. Increasing to 12 px/mm produces 3 pixels across that stroke and requires at least:

80 mm × 12 px/mm = 960 horizontal pixels

The team should compare both configurations with worst-case print, motion, glare, and position. If the code is known from the active recipe, use OCV or OCR plus exact string comparison. If it is a variable serial, use OCR plus a format rule and database uniqueness check.

[Suggested visual: character-height and stroke-width sampling diagram]

Purpose: Explain why stroke width can govern resolution even when character height looks adequate.

Required elements: 2.5 mm character, 0.25 mm stroke, 8 px/mm and 12 px/mm grids, and resulting 2-pixel versus 3-pixel strokes.

Suggested caption: “Specify the smallest stroke and gap, not only the overall character height.”

Accessible alt text: “The same printed character is shown on two pixel grids, where the narrow stroke covers two pixels in one image and three in the other.”

OCR/OCV decision table

Production need Recommended logic Essential validation
Read unknown serial OCR + format/database checks Character and full-string error rates
Confirm known expiry date OCV or OCR + exact comparison Wrong-code challenge set
Check print presence only Image-quality/print-presence tool Weak and partial print samples
Read dot-peen mark OCR designed for variable strokes Pose, depth, oil, and lighting variation
Approve valid date range OCR + date parser + recipe logic Month-end, leap-year, rollover cases
Store traceability data OCR + sequence ID + database transaction Duplicate, timeout, and communication faults

Common mistakes

  1. Using OCR when only verification is required. An unconstrained reader creates unnecessary ambiguity.

  2. Treating any returned string as a pass. Recognition must be followed by correctness checks.

  3. Specifying only character height. Narrow strokes and gaps often set the true resolution requirement.

  4. Training on clean print only. Production includes weak jets, smear, misalignment, missing dots, and substrate variation.

  5. Letting glare cut character strokes. No confidence threshold can recover absent pixels reliably.

  6. Allowing every alphanumeric character. Constrain the alphabet and format to the real process.

  7. Ignoring date and recipe transitions. Midnight, month-end, product change, and line restart are common failure moments.

  8. Using aggregate string accuracy only. Report errors by character, position, font, and failure mode.

Validate under production conditions

Collect independent codes across product variants, printers, printheads, shifts, substrates, speeds, positions, and environmental states. Include deliberate weak, smeared, missing, extra, and wrong codes. Challenge similar characters such as 0/O, 1/I, 5/S, and 8/B if they are permitted.

Measure character error rate, full-string exact-match rate, false acceptance of wrong codes, false rejection of correct codes, unreadable rate, and processing time. Slice by character position and print condition.

Test recipe changeovers, clock and date rollover, database unavailability, duplicate serials, and result/part identity. Preserve the raw image for audited errors where policy and storage allow.

Key takeaways

  • OCR reads unknown text; OCV checks against expected text.

  • Image quality, recognition, and business-rule validation are separate layers.

  • Narrow stroke width can govern camera resolution.

  • Format, recipe, date, checksum, and database constraints improve the decision when they reflect real process rules.

  • Validate wrong-code acceptance and unreadable handling, not only clean-string accuracy.

Follow this Hashnode blog for more practical code-reading guidance, and connect with Kivanc Ekici on LinkedIn. For related machine-vision and automation information, visit ITAGE.

Frequently asked questions

What is the difference between OCR and OCV?

OCR determines the characters present. OCV checks whether the visible characters match an expected string or model.

How many pixels high should industrial text be?

There is no universal figure. Character height, narrowest stroke, print quality, motion blur, and the chosen tool all matter. Use a starting budget and validate worst-case samples.

Can OCR verify an expiry date?

OCR can read it. A separate comparison or date-validation rule must confirm that it is the correct date for the product and production time.

Should low-confidence text be rejected?

Define an explicit unknown or review path. The threshold should be selected from representative correct and incorrect codes, not from a convenient default.

Why does OCR fail only at line speed?

Motion blur, trigger timing, vibration, short exposure, or strobe alignment may reduce stroke contrast even though stopped-line images are clear.

Sources