OCR inspection uses a camera to read the printed characters on a pack, such as a batch number or expiry date. The station checks them before the pack leaves the line. A reliable station does two jobs: it reads the characters, and it checks that the value is the one this batch should carry. It is one task within a complete machine vision inspection system, alongside label, code and presence checks.
What Is OCR Inspection?
OCR inspection is an automated check: a camera and software read the printed text on each pack. The station then compares that text with what the pack should carry.
The Wikipedia article on optical character recognition defines OCR as “the electronic or mechanical conversion of images of typed, handwritten or printed text into machine-encoded text”. On a production line that means turning the printed code on each pack into data the line controller can check and record.
Typical targets are lot or batch numbers, expiry and manufacturing dates, product codes and serial numbers printed in plain text beside a barcode or Data Matrix code.
Where OCR Inspection Is Used
OCR inspection is used wherever a printed code carries information that must be right on every unit.
- Pharmaceutical packs: Batch, expiry and serial numbers beside the 2D code.
- Medical devices: Lot numbers and the human-readable part of the unique device identifier (UDI).
- Electronics: Part numbers and date codes marked on components and boards.
- Personal care and household products: Batch and expiry codes on bottles, tubes and cartons.
- Labels and logistics: Shipping labels and case codes checked against the order.
Why Manual Code Checks Miss Errors
Manual code checks miss errors because people sample a few packs, tire over a shift and read what they expect to see. A line running 200 packs a minute produces 12,000 packs an hour, and a person checking one pack in fifty sees 240 of them. A camera reads all 12,000 and records the result for each.
OCR vs OCV: What Is the Difference?
OCR reads characters the station does not know in advance and returns them as text. OCV compares the printed characters with an expected value and returns pass or fail.
| OCR (recognition) | OCV (verification) | |
|---|---|---|
| Question it answers | What does the print say? | Does the print match what we expect? |
| Needs the expected value? | No | Yes, from the recipe or batch record |
| Output | A text string and a confidence score | Pass or fail, with a quality score per character |
| Best for | Recording codes, sorting, traceability | Confirming batch and date on every pack |
| Main risk | A misread character goes unnoticed | A wrong expected value passes wrong packs |
Packaging lines can use both: OCV to confirm the code is correct and legible, and OCR to store what was actually printed with the pack record.
Vision Sensor or Vision System for OCR?
A vision sensor is a compact, all-in-one unit with fixed OCR tools. A vision system is a camera plus a controller or PC that runs more flexible software. A vision sensor suits one code in a fixed position with a simple format. A vision system suits several codes per pack, codes mixed with other checks, variable formats and links to batch records or a line controller. The comparison of smart cameras and PC-based vision covers the trade-off in more detail.
How OCR Inspection Works
OCR inspection works in five steps on every pack: trigger, light, read, compare and reject.
- A part sensor triggers the camera as the pack passes.
- Lighting makes the print stand out from the pack surface.
- The software finds the code area, separates the characters and reads each one.
- The result is compared with the expected value and the date rules.
- A failed pack is tracked to the reject point, removed, and the removal is confirmed.
Rule-Based OCR vs Deep Learning OCR
Rule-based OCR matches each character against trained font samples, and deep learning OCR uses a neural network trained on many examples of real print.
| Rule-based OCR | Deep learning OCR | |
|---|---|---|
| Setup | Train each font and character set | Uses a pre-trained model, fine-tuned on samples |
| Handles | Consistent fonts on stable surfaces | Distorted, faint or curved print, varied fonts |
| Explaining a result | Character scores are easy to read | Harder to explain a single decision |
| Validation | Simpler to validate in regulated plants | Needs a fixed model version and a test set |
Rule-based OCR suits stable print in a controlled position. Deep learning OCR helps where print varies, with the model version locked and tested like any other recipe.
Print Methods and Hard Characters
Print methods for coded packs are continuous inkjet, thermal inkjet, laser marking, thermal transfer and embossing. Each one gives the camera a different kind of character to read.
| Print method | What the camera sees | What makes it hard |
|---|---|---|
| Continuous inkjet | Dot-matrix characters | Gaps between dots, ink spread on glossy film |
| Thermal inkjet | Fine, sharp characters | Fading as the cartridge empties |
| Laser marking | Characters etched or colour-changed | Low contrast on some materials |
| Thermal transfer | Solid characters on film or labels | Ribbon wrinkles, missing strokes |
| Embossing | Raised or pressed characters | Needs low-angle light to show relief |
Some characters are easy to confuse: O and 0, I and 1, S and 5, B and 8. Where they appear in your real codes, include them in the trial. Where you control the code format, leave out the letters O and I.
Lighting decides whether the print is readable. Low-angle light shows embossed print; diffuse light reduces glare on foil and film. Our machine vision lighting guide covers the options, and the machine vision camera guide covers exposure for moving packs.
Code Format and Fonts for Reliable OCR
Code format decides how easily a camera reads the print. Fixed-length codes, consistent separators and a fixed date format (for example, EXP 2027-11) are easier to verify than free text. OCR-A and OCR-B (ISO 1073) were designed for machine reading. A clear sans-serif font at a consistent height reads well from inkjet, laser and thermal transfer printers. Leave space around the code so the camera can find it, and keep the print inside a defined window on the pack.
Codes Required on Regulated Packs
Regulated packs carry codes with fixed content, and the human-readable text has to match the encoded data.
| Data | GS1 Application Identifier | Example use |
|---|---|---|
| Product code (GTIN) | (01) | Pharmaceutical and medical device packs |
| Batch or lot number | (10) | Recall and traceability |
| Expiry date | (17) | Pharmaceutical and medical device packs |
| Serial number | (21) | Serialised packs |
In the EU, prescription medicine packs carry a 2D code with a human-readable product code and serial number under the Falsified Medicines Directive. The batch and expiry are printed under EU labelling rules. Medical devices in the US and EU carry a unique device identifier in human-readable and machine-readable form. OCR and OCV confirm that the printed text matches the 2D code on each pack.
Lighting for OCR
Lighting for OCR is chosen from the pack surface and the print method, because the camera can only read characters that stand out from the background. A ring light suits matte printed cartons. A dome light gives even, glare-free light on shiny foil, film and curved bottles. A low-angle bar light throws shadows across embossed and etched codes so the raised or cut characters become visible. Test the light with real packs at line speed, including the shiniest and most creased examples.
Character Segmentation and Training
Character segmentation splits the code into single characters before each one is read. Segmentation fails when characters touch, when dot-matrix dots are spaced too widely or when the code is skewed. Set the code region, character height and spacing from real samples. Train each character in the font the printer actually produces, and include faint and heavy print in the training set.
OCR on Curved and Moving Packs
Curved and moving packs distort the code the camera sees. Characters near the edge of a round bottle shrink and lean. Position the code where the pack faces the camera most squarely, or use two cameras around the bottle. On a moving line, a short exposure and a strobed light freeze the code. A guide rail or side belts keep each pack at the same distance from the lens.
Why a Clear Read Needs a Value Check
A printer can print the wrong batch or date perfectly. Reading quality and value checking are separate results, and the station needs both.
- Match the expected value. Take the batch and date from the active recipe or batch record, set at changeover.
- Check the date is valid. Confirm the format, a real calendar date, and the right relationship between manufacturing and expiry dates.
- Decide what happens without a source. If the expected value is missing, stop or reject. Never fall back to “anything legible passes”.
- Keep the two results apart. Log the read confidence and the value check as separate fields.
For packs that also carry serial numbers and 2D codes, the human-readable text links to the same pack record; see our pharmaceutical serialization page. Barcode and Data Matrix grading is covered under code reading and traceability.
Pro Tip: Make the expected value part of the changeover screen, and have the operator confirm it before the first pack runs. That closes the gap a rushed changeover leaves open.
OCR Speed and Line Rate
An OCR station has a fixed time budget for each pack, set by the line rate. A line at 300 packs per minute delivers one pack every 200 milliseconds. Image capture, reading, the value check and the reject decision must all fit inside that time, with margin for the slowest read. Longer codes, more fonts and extra checks all add reading time, so measure the worst-case read time during the trial.
Validating OCR in Regulated Plants
OCR validation in a regulated plant proves the station reads and rejects correctly before it runs product. The usual sequence is an installation check, an operational test with the challenge set, and a performance run on real production. Lock the recipe, font training and software version after validation, and treat any change to them as a controlled change with a repeat of the relevant tests.
Build a Challenge Set Before Acceptance
A challenge set is a group of faulty and good packs that proves the OCR station rejects and passes the right packs. Test the station with packs that should fail as well as packs that should pass:
| Challenge sample | What it proves |
|---|---|
| Good print at the edges of the print area | Position tolerance |
| Faint, smeared and partly missing characters | Quality limits |
| Confusable characters in real codes | Font training |
| Correct format, wrong batch or date | Value check |
| Invalid date such as 31 April | Date rules |
| No print at all | Missing-code detection |
| Curved, glossy or creased packs | Lighting and presentation |
Run the set at full line speed, with the real pack and print, and repeat it after each recipe change.
Rejects and Evidence
OCR rejects and evidence prove that every failed pack left the line and that the record shows why. Each result must stay attached to the right pack until the reject point. Test a missing code, an unreadable code, a clear read of a wrong code and a lost expected-value input, and confirm that every one leaves the line. A sensor at the reject bin should confirm the removal.
Save images and results for the retention period your quality system sets. If only failed images are kept, record that rule so an investigation knows what exists. For label position and other pack defects, see our label inspection system guide.
Pro Tip: Store the image of every rejected pack with the read string and the expected value side by side. That record speeds up root-cause analysis.
How Does OCR Data Reach MES or ERP?
OCR data reaches MES or ERP through the line controller or a direct software link. For every pack, the vision system sends a short record:
| Field | Example content |
|---|---|
| Read text | The batch, date or serial number as printed |
| Result | Pass or fail, with the reason for a fail |
| Time | When the pack passed the camera |
| Image reference | Where the saved image is stored |
The record travels over the network the line already uses, such as industrial Ethernet or OPC UA, to the PLC or straight to the plant system. Stored against the batch, these records support genealogy, recall scope and audits.
Common OCR Inspection Mistakes
Common OCR inspection mistakes come from testing in conditions the line never sees. Trusting a clear read as proof of the right code is the other.
- Training on clean bench samples and testing on moving, curved packs.
- Accepting any legible string without checking it against the batch.
- Treating a high confidence score as proof the code is correct.
- Leaving the expected value to be typed in free text at changeover.
- Confirming the reject signal without confirming the pack left the line.
How Motionwell Builds OCR Inspection
Motionwell specifies the camera, lighting and reading tools for the actual print and pack. We link the expected value to the recipe or batch record and build the tracking and confirmed reject. Machine vision uses Keyence and other platforms selected for the part and the inspection task. Handover can include IQ/OQ/PQ protocols, electronic batch records, LVD and EMC test reports and MOM lifting certification.
Motionwell adds OCR and OCV stations to new packaging lines and to running ones. Motionwell has delivered more than 150 automation projects in Singapore since 2014.
Planning a printed-code check? Send sample packs, the code format and the line speed. Discuss your OCR inspection with Motionwell.