OCR and code reading on production lines

Pixels per module, lighting for DPM codes, exposure and motion blur, and read-rate maths for OCR and barcode stations on Indian production lines.

Reference
RE-1741
Published
Read
5 min

About the author · Sources, testing and AI policy

Fixed 2D code reader inspecting a laser-marked code on a metal part

Reading a code is the easiest vision task to underestimate. The image looks clear to you; the decoder disagrees, because the code is 12 pixels wide and half of it is glare.

This guide covers OCR, OCV and barcode reading on production lines: what resolution you actually need, how lighting and optics decide the result, and the failure modes that turn a 99 percent read rate into a stopped line.

OCR, OCV and codes are different problems

TaskWhat it doesTypical failure
OCRReads text, usually with a trained font modelFont variation, low contrast, smudged print
OCVVerifies that printed text is present and correctMissing or partial print
1D barcodeReads lines, needs quiet zonesLow bar height, curved surface
2D code (QR, Data Matrix)Reads a matrix, tolerant of damageLow module size, poor contrast
DPM codesDirect-part marking on metal or plasticLow contrast, glare from machining marks
A system that reads QR codes well may fail completely on laser-marked DPM codes. Test the marking method, not just the symbol type.

Resolution: the module size rule

For 2D codes, the smallest element is the module, not the whole symbol. A common rule is three pixels per module minimum, five preferred, and more for DPM or damaged marks. At 0.2 mm modules with three pixels each, you need 0.067 mm per pixel.

pixels per module = module size (mm) / mm per pixel
mm per pixel      = field of view width / sensor width in pixels

Example: 0.3 mm modules, 5 px/module → 0.06 mm/px
         1200 px sensor width → 72 mm field of view

If your field is 200 mm, that sensor gives 0.167 mm/px,
which is only 1.8 px per module. It will not decode reliably.

That calculation is the same one used for any vision task, and our lens selection guide shows how the field of view and focal length connect. Deciding the lens first and the code size later is the most common ordering mistake.

Lighting for codes

  • Diffuse dome light for curved or reflective surfaces and DPM marks on machined metal.
  • Low-angle dark field makes raised or engraved marks stand out against a flat surface.
  • Coaxial light for flat, shiny labels, where direct reflection is the problem.
  • Bandpass filter matched to the light colour to reject ambient and factory lighting.
  • Polariser on both light and lens to cut glare from plastic film and metal.

Most decode failures on metal parts are glare, not resolution. Look at the raw image before changing the camera: if you cannot see the code clearly in the captured frame, no algorithm will.

Exposure, motion and depth of field

A conveyor moving at 500 mm/s covers 0.5 mm in a 1 ms exposure. At 0.06 mm per pixel, that is eight pixels of motion blur, which destroys a 0.3 mm module. Options are a shorter exposure with a brighter light, a strobe synchronised to the encoder, or a stop-and-read station.

Depth of field is the second constraint. Parts that sit at different heights or curve away from the camera need enough depth of field to keep the code sharp across the range. Closing the aperture helps until diffraction softens the image; a telecentric lens solves the perspective problem at a price.

Reading on the move versus stop-and-read

ApproachThroughputCostBest for
Stop-and-readLower, but predictableLowestSlow lines, large parts, awkward angles
On-the-fly, area cameraGoodModerateMedium speeds, codes in a known window
On-the-fly, line scanHighestHigherFast conveyors, continuous webs
Handheld scannerManualLowestLow volume, mixed parts
Line scan needs an encoder and even lighting across the full width; area cameras are far more forgiving to set up.

The read-rate numbers that matter

A 99 percent read rate sounds good until you do the arithmetic: at 1,000 parts a shift, that is ten failed reads, each needing a manual scan or a rework decision. A 99.9 percent rate gives one. The difference is usually lighting and optics, not a better decoder.

Measure first-pass read rate on real parts over a full shift, including dirty and damaged ones. Vendors quote read rates on good samples, which is why acceptance tests should specify the sample population.

Integration with the line

The reader must tell the PLC what it saw, and the PLC must decide what to do. Typical outcomes are pass, reject and re-read. A re-read station with a second camera at a different angle raises the read rate cheaply compared with stopping the line.

Keep the decoder settings versioned with the rest of the cell program. A firmware update that changes default symbology settings is a real cause of Monday-morning failures, and the fix is faster if you know what changed.

Costs in India

  • Fixed-mount 2D reader, entry level: ₹35,000 to ₹85,000.
  • High-resolution reader with liquid lens: ₹1.2 lakh to ₹3 lakh.
  • Line scan camera with encoder interface: ₹1.5 lakh to ₹4 lakh.
  • Dome light with controller: ₹45,000 to ₹1.5 lakh.
  • Vision software licence for OCR: ₹40,000 to ₹2 lakh per station.

The pattern in most projects is that the reader is a small part of the cost and the lighting, mounting and integration dominate. Budget accordingly, and test with the real marking method before ordering.

For the camera and interface side, see our camera interface comparison and the machine vision lighting guide. If the code drives a robot, the calibration path in vision-guided robotics is the next read.

How many pixels per module do I need to read a QR code?

Three is the practical minimum and five is comfortable; DPM and damaged codes need more. Calculate millimetres per pixel from your field of view and sensor width, then divide the module size.

Why does my barcode reader fail on metal parts?

Almost always glare or low contrast from the marking, not the decoder. Use diffuse or low-angle lighting, a polariser, and test the actual marking method before choosing a reader.

Can I read codes on a moving conveyor?

Yes, with a short exposure and a strobe or line scan triggered by an encoder. Compute motion blur from line speed and exposure time before committing.

What is the difference between OCR and OCV?

OCR reads the characters; OCV verifies that the print is present and correct. Production lines usually need both, in that order.

How much does a code reading station cost in India?

A basic fixed reader is ₹35,000–85,000, high-resolution readers ₹1.2–3 lakh, and lighting and integration often cost as much again.

Every case needs a verified label before it reaches the pallet, and the end-of-line packaging guide covers where verification sits in the line.

Sources and further reading

  • GS1 India — barcode standards and quality guidance.
  • ISO/IEC 15415 — 2D barcode print quality grading.
  • EMVA — machine vision standards and resources.
  • Cognex India — code reading technology notes.
Pass it onWhatsAppLinkedIn

Keep reading

Continue learning

The Build Note

One short email when something is worth your bench time.

A new build sheet, a part price that moved, or a mistake worth avoiding. No daily drip, no recycled news.

One short email when a build or a price is worth your time. Unsubscribe in one click.