addaScan home
Assessment
Machine vision basics // Chapter 3 of 6

How does machine vision inspection decide pass or fail?

By Frank GuoTechnical review: Frank GuoPublished Updated 5 min read

// In short

Machine vision inspection decides pass or fail by running a chain of tools on each image. It first locates the product, then measures, counts, reads codes and text, or compares with a reference in regions tied to that position. Each result is checked against a limit set on good and defective samples, and the results are combined into one decision for the PLC. Rule-based tools apply limits an engineer sets; deep-learning tools learn from labelled images.

// Key takeaways

  • Locate first, so every other tool follows the product when it shifts or turns.
  • Every check ends as a value compared with a limit, including a deep-learning score.
  • Rules suit faults you can define; deep learning suits defects that vary in appearance.
  • A recipe holds the tools, limits and expected data for one product and is selected at changeover.

What happens to each image?

Every product goes through the same short sequence, and it must finish before the next product arrives:

  1. Acquire. The trigger fires, the light strobes or is on, and the camera takes the image.
  2. Locate. A tool finds the product or a feature on it, so the other tools know where to look even if the product has shifted or turned.
  3. Inspect. Tools run in regions tied to that position: measure, count, read or compare.
  4. Judge. Each result is compared with its limit.
  5. Decide and report. Logic combines the results into one pass or fail, which goes to the PLC with any data, such as the code read or the reason for a fail.

Which tools does a station use?

  • Locate: pattern matching, edge, line and circle search find the product or a feature. Everything else hangs off this position.
  • Measure: distances between edges, diameters, positions, angles, a fill line against a backlight. Values start in pixels and are converted to millimetres by calibration.
  • Count: objects or blobs in a region. Presence or absence is simply a count of one or zero.
  • Read: 1D and 2D codes are decoded; OCR reads printed characters; OCV verifies that the print matches the expected text. The OCR/OCV inspection page covers date and batch codes.
  • Compare: a region is checked against a reference of a good product, so a wrong label, missing print or an unexpected mark shows up as a difference.

HIKROBOT groups the VisionMaster tools in much the same way: locating, measurement, recognition (code reading and OCR) and defect detection, which includes OCV and anomaly detection (HIKROBOT catalogue 2025 Q4). The VisionMaster algorithm tools page maps each group to typical inspections.

What is the difference between rule-based and deep learning?

Rule-based inspection is a chain of tools an engineer builds: find the label edge, measure its position, fail it if it sits outside a band. Every decision can be traced to a measured value and the limit it was compared with.

Deep learning works from examples instead of rules. You show the station labelled images of good and defective products, and a model learns to classify them, find objects or mark defect areas. Some methods learn from good products only and flag anything unusual, which is called anomaly detection. The model returns a score or a region; a person still sets the threshold that turns it into a fail. HIKROBOT states, for example, that VisionMaster’s deep-learning OCR adapts to characters on complex backgrounds, in low contrast or deformed (VisionMaster product page).

Rule-based inspection and deep learning compared in plain terms
AspectRule-basedDeep learning
Best forFaults you can define as a measurement, count or ruleDefects that vary in shape and appearance, often on a variable surface
Main effortEngineering time to build and tune the toolsCollecting and labelling images, training and validation
Samples neededFewer images, covering normal variation and each faultLabelled images of each defect across its variation
Explaining a rejectA measured value against a limitA score, usually with a highlighted region
A new productUsually a new recipe and limitsMay need new images and retraining

Many stations combine both: rules locate the product and read the code, and a deep-learning tool inspects the one area where fixed rules fail. Neither finds a defect that the image does not show. The full comparison, with sample needs and upkeep, is in rule-based inspection or deep learning.

How are the limits set?

A limit is the line between pass and fail for one check: how far a label may be skewed, the lowest acceptable fill line, the size of mark that counts as a defect. Limits start from your quality team’s definition of a defect, written down with example images. They are then set on a sample set that covers normal variation and borderline cases, not on a single good part.

Set a limit too tight and good products are rejected; too loose and defects pass. Each limit is recorded with the reason it was chosen, and every later change is logged. Chapter 6 shows how the two resulting error figures are measured.

What is an inspection recipe?

A recipe holds everything the station needs for one product: references, regions, tools, limits and the expected codes or text. At changeover the PLC or HMI selects the recipe, the station reports back the recipe it is running, and the PLC checks that they match before production restarts.

Expected data that changes, such as today’s best-before date or the batch code, can come from the coder or the PLC, so verification compares the print with the value that should be there now rather than a fixed string. The source still matters: if the recipe and the coder both hold the wrong date, they agree and the error passes.

Define incomplete inspection as an explicit state

A practical decision chain begins by asking whether the image belongs to the current product and whether the required feature was located. Only then should it evaluate the defect or measurement. Defaulting a missing numeric result to zero can create a false pass if zero lies inside the allowed range. Likewise, an OCR failure must not leave the previous recognised text in a field that downstream logic treats as current.

Define incomplete inspection as an explicit stateCurrent image and product identityRequired feature successfully locatedAll required checks completedCombine decisions and send result
Schematic: Define incomplete inspection as an explicit state.
Define incomplete inspection as an explicit state
Requirement or conditionMeaning or riskPractical check
Location failedNo valid inspection regionHold or reject under the agreed fault policy
Readable but wrong textRecognition succeeded; comparison failedReject as identity/data failure
Classifier uncertainDecision boundary not resolvedUse the validated hold/review policy
Communication timed outPhysical item has no current resultContain the unresolved item and alarm

Worked example — hypothetical: For a hypothetical lid recipe, a product passes only when the lid is present, its identity matches and the date text matches the current production data. Deliberately failing each condition in turn verifies the logic. A correct date on a wrong lid must still fail. This truth-table exercise is more informative than showing only a known good pack.

Train and tune learning-based tools on development data, then freeze them before the independent test. Google’s dataset guidance separates training, validation and test sets and warns against duplicate examples crossing those boundaries. (Google Machine Learning Crash Course: dividing datasets) (NIST e-Handbook, 7.2.4.1 Confidence intervals for a proportion)

Keep the original image together with the active recipe and the reference judgement when investigating a disagreement. Change one controlled setting at a time and re-run the relevant challenge samples. Once a correction works, verify the neighbouring requirements too: improving contrast for one feature can hide another. Record the revised configuration and the evidence for release so maintenance does not have to reconstruct the decision from memory.

Frequently asked questions

Does a vision system need to be trained?

Rule-based tools are set up rather than trained: an engineer teaches a reference image and sets limits on samples. Deep-learning tools are trained on labelled images and then checked on a separate set of images that was not used for training.

What is the difference between OCR and OCV?

OCR reads the characters and reports what they say. OCV starts from the text that should be printed, such as the expected date and batch code, and checks that it is present, complete and legible. Many date-code checks use both.

Is AI inspection more accurate than rule-based inspection?

Not as a general rule. Each suits different defects, and the result depends on the image and the samples. Both are accepted the same way: on agreed samples, counting false rejects and missed defects.

Read next · Chapter 4Where should an inspection station sit, and how does it reject?Placement after the step that causes the fault, tracking to the reject, reject devices, confirmation and fail-safe behaviour.

Sources

  1. HIKROBOT Machine Vision Smart Product Catalog, 2025 Q4 (PDF), VisionMaster tool list (vendor catalogue, checked 2026-10-03; locating, measurement, recognition and defect detection groups)
  2. HIKROBOT VisionMaster product page (vendor page, checked 2026-10-03; deep-learning OCR and defect detection)
  3. Google Machine Learning Crash Course: dividing datasets (training, validation and independent test sets; read 2026-10-27)
  4. NIST e-Handbook, 7.2.4.1 Confidence intervals for a proportion (binomial interval methods; read 2026-10-27)
// Next step

Have a line in mind?

Describe the product and the fault you need to catch. We test on your samples and reply with a feasibility note and a budget.