A marking can be readable enough to identify a familiar product without being clear enough to transcribe reliably. That difference changes the inspection method, image requirements, and rejection logic. For engineers identifying parts from printed, molded, or engraved markings, the first decision is whether you need the actual characters or only a known product class. Establish that requirement before selecting hardware or spending more time tuning recognition software.
Decide what the inspection must return
Choose OCR when the output must contain individual characters: a serial number, changing batch code, date, or product identifier that is not limited to a small approved list. Choose multiple contour templates when the marking identifies a finite set of known products and the required output is simply the matching class.
A template system does not necessarily read the marking. It measures resemblance to stored examples. That can be sufficient for classification, but it cannot establish that every character is correct unless the inspection explicitly tests those differences.
| Decision factor | OCR | Multiple contour templates |
|---|---|---|
| Required output | Character string | Known class or no match |
| Changing serial numbers | Appropriate task, subject to image quality | Poor fit for an expanding set of unique markings |
| Small, fixed product family | Useful when text content matters | Often a practical starting point |
| Touching or incomplete characters | May require segmentation or a suitable recognition model | May tolerate repeatable appearance, but can confuse similar classes |
| New product introduction | Validate the new text format and appearance | Add templates and repeat cross-class rejection tests |
| Unknown product handling | Validate text and approved-value rules | Require explicit rejection thresholds and class separation |
If characters merge into each other, the guide to separating touching digits before OCR addresses the segmentation problem. Do not introduce segmentation work when the production requirement only needs classification.
Write the acceptance requirement before building either method. For example: identify an approved product family, reject unreadable images, and reject unapproved markings. These are separate decisions, not a single similarity score.
Validate the image before comparing algorithms
Neither method can reliably recover a distinction that the camera never captures. Start with saved images covering actual part variation, then inspect the smallest feature that separates confusing products.
Check these conditions in order:
- Focus and sampling: inspect original-resolution pixels rather than a resized preview. Confirm that narrow strokes and gaps remain distinguishable.
- Lighting direction: move the light while holding exposure and gain fixed. Compare contrast at the distinguishing feature, not average image brightness.
- Exposure: look for saturated highlights, dark strokes disappearing into noise, and motion blur at production speed.
- Pose and background: confirm that the marking stays inside the inspection region throughout normal displacement and rotation.
- Surface variation: include different production lots, finishes, marking depths, and contamination levels permitted by the process.
Changing lighting direction can reveal an engraved stroke that disappears under frontal illumination. Diffusion can reduce concentrated reflections, but it can also weaken the shading that makes a shallow engraving visible. Compare both effects on real samples rather than assuming that softer lighting is always better.
Use lighting accessories and the accessories finder only after identifying a specific need, such as a compatible diffuser or extension cable. Verify mechanical fit and electrical compatibility rather than selecting an accessory by appearance.
The OCR layout segmentation guide is useful when unrelated text or surrounding features enter the recognition region. A smaller, well-defined region can remove ambiguity without changing the recognition algorithm.
Calculate whether the character detail is sampled
Use the narrowest relevant stroke or gap to estimate horizontal sampling requirements. Character height alone can be misleading: two markings may have large characters but differ only at a much smaller feature.
These calculations describe sampling, not recognition accuracy. Lens contrast, focus, noise, surface reflection, and processing still determine whether the sampled feature remains usable.
Suppose the marking occupies a 60 mm field width and the smallest distinguishing stroke is 0.30 mm wide. As an initial screening target, try 4 pixels across that stroke:
Four pixels is a trial target, not a universal OCR requirement. Validate it against your font, surface, and false-accept requirement. If the feature is low contrast or partly damaged, additional sampling may help, but it cannot replace missing contrast.
Use the resolution calculator to explore the field-width and feature-size trade-off:
For an illustrative image width of 1,600 pixels, the same stroke spans:
Increasing the field width to 96 mm reduces that value to 5 pixels. This is why widening the view to accommodate part movement can make previously reliable recognition fail.
Motion creates another constraint. At a 60 mm field width and 1,600 horizontal pixels, object sampling is 0.0375 mm per pixel. For an object speed of 250 mm/s and a trial blur limit of 0.5 pixel:
This estimates translational blur only. It does not account for vibration, rotation, or rolling-shutter distortion. Check the saved image at operating speed before deciding that more resolution is necessary.
Build rejection into multiple-template classification
Locate the part first, preferably using stable geometry independent of the marking. Transform or constrain the marking region using that location. Then compare it with templates representing approved product classes.
A useful processing sequence is:
- Confirm that a part is present and sufficiently visible.
- Locate its position and orientation.
- Reject images outside validated focus, exposure, or pose limits.
- Search the marking region with approved templates.
- Combine template scores by product class.
- Apply minimum-score and competing-class separation rules.
- Return an approved class or an explicit rejection state.
When several templates represent the same class, compare the winning class against the best different class. Comparing against another template of the same product can create a meaningless ambiguity alarm.
For systems whose score increases with similarity, an illustrative decision rule is:
For example, a winning score of 0.86 and a competing score of 0.84 give a margin of 0.02. A minimum-score threshold of 0.80 would accept the winner if no separation rule existed. Whether that margin is adequate must come from validation; score scales are software-specific.
Add templates to represent legitimate appearance variation, not to make every difficult image pass. Enlarging the template library gives unknown markings more opportunities to match accidentally. Repeat rejection testing whenever templates, masks, search ranges, or preprocessing change.
For OCR, apply corresponding checks to the returned string: expected length, permitted characters, format, and approved product values. If your process already provides a barcode, barcode-to-part verification offers another route to identification without relying on visually similar text alone.
Run a validation that exposes similar and unknown markings
Evaluate both methods on the same held-out images. Keep training, template creation, threshold tuning, and final acceptance testing separate. Images of the same physical part should not appear on both sides of the split.
A practical development collection might cover 5 product classes, 3 production lots per class, and 5 distinct parts per lot. Photograph each part at 4 representative poses:
Those 300 images are not 300 independent parts. Repeated views help expose pose sensitivity, but they do not provide the same evidence as additional independent samples. Where possible, reserve a later production lot for final validation.
Include challenge groups that ordinary good-part collections miss:
- The closest-looking approved classes, especially those differing by one small stroke.
- Unknown products with similar marking size, font, or outline.
- Missing, partial, doubled, or smeared markings.
- Blank surfaces and unrelated nearby features.
- Permitted pose extremes and the least favorable acceptable lighting conditions.
Record correct identification, wrong-class acceptance, unknown acceptance, rejection of acceptable parts, and processing time. Build a confusion table by true class and reported class. A single overall accuracy figure can conceal a serious error between two similar products.
Zero observed false accepts does not establish a zero false-accept probability. Under independent, representative trials, a rough one-sided 95% upper bound after zero events is 3 divided by the number of trials. With 300 independent unknown-part trials, that estimate is 3 / 300 = 1%. Use a validation plan suited to the consequence of a wrong identification.
Choose hardware around the validated inspection
Compare smart cameras when inspection on the device suits the installation. Compare area scan cameras when you need a separate image-processing environment or more freedom to change software.
Neither category guarantees a particular OCR tool, contour matcher, score definition, or licensing arrangement. Confirm the required functions on the exact device and software combination. The smart camera software compatibility checklist covers the questions to resolve before ordering.
The LS-SMC-0063 is a smart-camera candidate with a GigE interface. Confirm that its supported inspection tools, image export, optics, and lighting suit the validated task.
- Interface
- GigE
- Resolution
- Up to 3 MP
The MV-CU020-90GC is an area scan candidate with a global shutter, GigE interface, and C-mount lens mount. Confirm acquisition support and select the processing environment separately.
- Sensor format
- 1/1.7"
- Lens mount
- C-mount
- Interface
- GigE
- Resolution
- Up to 3 MP
These candidates illustrate different system architectures, not interchangeable recognition capabilities. Do not infer algorithm support from the presence of a network connection.
Use the camera finder to narrow acquisition requirements after calculating field coverage, sampling, and exposure. Then use the camera configuration step to check the surrounding lens, lighting, and connection requirements.
Recognize when the usual choice is wrong
Multiple templates become a poor fit when the product family changes frequently or differences are smaller than the validated image detail. Maintaining many nearly identical templates can cost more effort than reading the relevant characters.
OCR can also be the wrong starting point. If the only required output is a fixed class and the marking has a repeatable overall shape, character segmentation may introduce unnecessary failure points. Compare a controlled template baseline before building a character-training workflow.
Use a hybrid when classification is easy but a small text region carries a critical distinction. A template can locate the marking, while OCR checks the differentiating characters. Alternatively, classify the product and add a targeted check for the stroke that separates its nearest competitor.
Do not mask out a feature merely because it reduces matching scores. If that feature distinguishes products, removing it can improve apparent stability while weakening identification.
If neither method separates acceptable and unacceptable samples, return to acquisition or change the identification method. Software tuning is not a substitute for visible evidence.
Check these items before ordering
- Output definition: specify a character string, product class, or both. This determines what the inspection must prove.
- Unknown handling: require a rejection output rather than forcing every image into an approved class.
- Feature sampling: record field width, smallest distinguishing feature, and tested pixel coverage.
- Motion limit: verify exposure and blur using images captured at operating speed.
- Closest-class challenge: test the most similar markings, not only obviously different products.
- Independent validation: reserve physical parts or production lots not used to create templates or tune thresholds.
- Runtime support: confirm OCR, matching, image export, licensing, and controller communication for the selected configuration.
- Change control: save templates, preprocessing, thresholds, and test images together so later changes can be checked consistently.
Start with a representative image set and a written rejection requirement. If the acquisition requirements or software compatibility remain uncertain, use application support to review the marking, field coverage, motion, and required output before choosing hardware.
Questions
Can template matching replace OCR for product identification?
Template matching can replace OCR when the required output is membership in a limited, approved product family rather than the actual text. Validate the closest-looking classes and unknown markings. A successful match establishes similarity to a template, not necessarily the correctness of every character.
Should one product have more than one contour template?
Use several templates only when they represent genuine appearance differences within the same product class. Group their scores by class before checking ambiguity. Every library expansion needs renewed testing against other approved products and unknown markings because additional templates can increase accidental matches.
What matching score should trigger acceptance?
No fixed score is safe across software tools, surfaces, and image conditions. Select thresholds from held-out examples, including unknown products and the nearest competing classes. Check both absolute score and separation from other classes, then confirm performance on samples not used during tuning.
Will a higher-resolution camera fix unreliable character recognition?
Additional pixels help when distinguishing strokes are undersampled, provided the lens and lighting preserve their contrast. They will not restore a stroke hidden by glare or an unreadable surface. Calculate sampling first, then compare original-resolution images with controlled focus, exposure, and lighting changes.

