Skip to content

Vision: tools, pass/fail and counting ​

Last updated

License feature: Machine Vision

A real inspection asks more than one question: four screws present, one lot code readable, the right colored cap fitted. Each question is a tool. This section covers what every tool has in common, the pass/fail rules, and the four simplest tools — Circles, Blobs (any shape), Presence and Color match. The others have their own sections: Pattern match and gauges, Barcodes, Text.

Choosing a tool ​

Tool (as labeled)AnswersJudged againstUse it when
CirclesHow manyExpected count ± toleranceThe parts are round. Finds them by shape, so a partly hidden one still counts
Blobs (any shape)How manyExpected count ± toleranceAny other shape that stands out from the background
Presence% of the region filledA band (at least / at most)Is something there — a screw in a hole, a cap on a bottle
Color match% of the region that is the target colorA bandThe right cap, the right label, the right wire
Pattern matchHow well a taught feature matched (%), and whereA bandThe right component is fitted; also locates the part for other tools
CaliperA distance (px or mm)A bandA width, gap or spacing
Circle gaugeA diameter (px or mm), and roundnessA bandA bore, a boss, a hole
Text (read & verify)The printed text, and whether it is rightThe expected textA lot code, date code or part number
Barcodes & QR codesWhat the codes sayA code must be read / must containTraceability labels, DataMatrix on parts

Adding, copying and removing tools ​

  • Add tool (in the Tools card) adds a Circles tool named Tool N with prefix toolN to the program you are editing.
  • The copy icon (Duplicate this tool) inserts a copy after it, with prefix <key>_copy and name "… copy".
  • The bin icon (Remove this tool) is disabled on the last tool: "An inspection needs at least one tool."
  • Changing Tool resets the parameters to that type's defaults — a circle's sensitivity means nothing to a blob tool.

Fields every tool has ​

FieldWhat it doesRules
Name (top of the card)A label shown on the page and on imagesUp to 60 characters. Renaming does not rename tags
Tag prefixTags are published as <prefix>/count, <prefix>/pass …Cleaned when you leave the field: lower case, anything but a–z, 0–9 and _ becomes _. A device-level tag name (pass, trigger, program …) is refused and the old prefix kept. A duplicate is renumbered on save (label_2). Changing it renames the tags, so anything bound to the old ones needs repointing
ToolThe tool typeChanging it resets parameters
Region of interestDraw region / Whole frameSee Tuning
Looks throughWhich camera the tool usesOnly shown with more than one camera. Changing it clears the region and any locator
Follow a located featureMoves the region with a Pattern match tool on the same cameraOnly shown when such a tool exists. See Pattern match and gauges
Pass / failThe rule (below)
SlidersThe tool's parameters (tables below)Each shows its current value and a one-line hint
Publishes …The exact tag paths this tool will createRead-only

Pass, fail and not judged ​

A tool only affects the verdict when Include this tool in the verdict is ticked. A tool that is not judged still reports its count, measurement or codes — it simply cannot fail the part.

Tool kindPasses when
Counting (Circles, Blobs)The count is within Tolerance (+/-) of Expected count — 24 ± 1 passes 23, 24 and 25
Measuring (Presence, Color match, Pattern match, Caliper, Circle gauge)The value is ≥ At least (if set) and ≤ At most (if set). Limits are inclusive
Text (read & verify)The text read equals It should say; or, with no expected text and Every character must be readable ticked, nothing came back as ?
Barcodes & QR codesA code must contain is empty or found in the codes read (case-sensitive); and, if A code must be read is ticked, at least one code was read

Three states, not two:

  • Judged with nothing to judge against — a counting tool with Expected count 0, a measuring tool with both limit boxes empty, a text tool with no expected text and the "every character" box unticked, a barcode tool with neither option — reports as not judged. The card warns: "Judged with no expected count, so this tool reports as not judged. Set a target." / "Judged with no limits, so this tool reports as not judged. Set at least one."
  • A tool that errored fails rather than reading not judged: something went wrong and the part has not been checked, which is not a pass.
  • If no tool is judged, the device's pass tag is published with uncertain quality rather than reading true, and an alarm on it should not fire. The judged tag says how many tools contributed.

The device's pass tag is true only when every judged tool passed. That is the tag to alarm on, and the one a reject gate or an andon should watch — not an individual count, which wobbles by one on detection noise.

Limits for measuring tools ​

  • An empty box means no limit that way. 0 is a real limit, not "none".
  • Set from this part reads the value on screen: for Presence, Color match and Pattern match it sets At least 10 points below the reading (not below 0) and leaves At most alone; for gauges it sets both limits 5% either side of the reading. It is a starting point, not an answer. Disabled until there is a reading ("Grab a frame first.").
  • An upper limit catches a region drawn larger than the part.

Circles ​

Hough circle detection on a grayscale, blurred image.

SliderDefaultRangeWhat it does
Min radius151–200 pxIgnore anything smaller. The cheapest way to stop shadows counting
Max radius602–400 pxIgnore anything larger, such as a tray edge
Edge threshold501–300Canny edge threshold (param1). Rarely needs changing
Sensitivity301–200Accumulator threshold (param2). Lower finds more circles, including ones that are not there. The one to reach for first
Min distance301–300 pxMinimum distance between centers. Stops one part being found twice
Blur93–31, oddSmooths noise before detection. The slider steps by two

Counting tools also have Expected count (≥ 0) and Tolerance (+/-) (≥ 0) under Pass / fail.

Blobs (any shape) ​

Separates foreground from background with a brightness threshold, cleans up, and counts connected shapes within an area window.

SliderDefaultRangeWhat it does
Threshold00–2550 lets the image choose (Otsu's method) — right under steady lighting, wrong the moment a shadow moves. Set a value when the lighting varies
Invert00–10 finds parts darker than the background; 1 for light parts on a dark background or a backlit setup
Min area2000–50,000 pxDrops specks and noise
Max area00–200,000 px0 for no upper limit
Cleanup31–15, oddFills pinholes inside a part then drops specks between parts. 1 turns it off. Without it a part with a highlight on it can count as two
Blur53–31, oddSmooths before thresholding

The tool also publishes areaMin, areaMax and areaAvg — the sizes it actually counted, in pixels. A drifting average area is a part changing size, and worth trending.

Presence ​

Reports what percentage of the region is filled, not yes or no. A percentage can be watched while a good part is under the camera and the limits set from what it actually reads, and it degrades honestly — a half-seated cap reads 60% rather than flickering between present and absent.

SliderDefaultRangeWhat it does
Threshold1280–255Pixels darker than this (or lighter, with Invert) count as filled. 0 lets the image choose
Invert00–11 counts pixels lighter than the threshold
Cleanup31–15, oddRemoves specks. 1 turns it off
Blur53–31, oddSmooths before thresholding

It also publishes brightness (mean gray level 0–255) and contrast (standard deviation). When the fill collapses, they tell "the part is missing" from "the lamp is failing": both drop the fill, but only a failing lamp takes the brightness with it.

Tip: Keep a real threshold rather than 0. Automatic thresholding assumes two populations of brightness, and an empty fixture has only one — on a test image an empty tray read 44% filled and a tray with a part read 28%, which is backwards. The tool guards against this (a region with contrast below 8 is compared against mid-gray instead), but the dependable setting is a threshold between what a good part reads and what an empty fixture reads. The brightness and contrast readings are what you set it from.

Color match ​

Reports what percentage of the region is the target color. It works in hue rather than RGB, so a red cap stays red when the lamp dims.

SliderDefaultRangeWhat it does
Target color00–179The hue to look for, on a 0–179 scale (half of the usual 0–360 degrees). 0 is red, about 30 yellow, 60 green, 120 blue
How close it must be101–90Hue distance that still counts. Wider catches shade variation; narrower tells two similar colors apart
Ignore below this saturation600–255Gray has no meaningful hue. Raise it if a shadow or a bare tray is matching
Ignore below this brightness400–255Near-black has no meaningful hue either
Blur53–31, oddSmooths before matching

Do not type a hue from memory. Put a good part under the camera, Grab one, and press Use the color in view: the card shows "Hue 4, saturation 180, brightness 150" for what is in the region, and the button copies the hue into Target color.

Hue is compared the short way round the circle, so red — which sits across the 179/0 join — matches correctly. A monochrome camera fails the tool with "This camera gives a monochrome image; color cannot be matched." rather than reporting 0%.

Worked example: cap check on a bottling line ​

Two tools on one camera, triggered by a part sensor.

  1. Tool 1, prefix cap, Presence. Region round the neck. A capped bottle reads 85%, an uncapped one 12% at Threshold 110. At least 60. Judged.
  2. Tool 2, prefix color, Color match. Same region. Use the color in view on a red cap gives hue 2. How close it must be 8. A red cap reads 70%, a blue one 0%. At least 50. Judged.
  3. Save. Alarm on pass going false; trend cap/brightness to catch a failing lamp.

See also ​

Scada.Ink Help Center