Rule-based or AI inspection: which one, when?
Classical tools are fast and easy to explain. AI handles parts that vary too much for fixed rules. Most good stations use both.
"Do we need AI for this?" is one of the first questions in any inspection project. The honest answer is often: for part of it. Classical vision and AI are good at different things, and the best stations combine them.
Classical (rule-based) tools
Classical tools measure something in the image and compare it with a limit you set. Typical ones are presence and count, measurement of sizes and positions, colour, reading barcodes and Data Matrix codes, and polarity or orientation checks.
- They need no training images: you set them up on a few good parts.
- They are fast and give the same answer every time for the same image.
- They are easy to explain: "the hole measured 12.08 mm, the limit is 12.05 mm".
- They struggle when the part or its background varies naturally: textured surfaces, cosmetic defects of any shape, reflective or cast parts.
AI tools
AI tools learn from images rather than following fixed rules. The common types are:
- Anomaly detection: learns what a good part looks like and flags anything unusual. It is trained mostly on good parts, which are easy to collect.
- Object detection: finds and locates specific features or defect types.
- OCR: reads printed, engraved or laser-marked text that is hard for fixed rules.
- Classification: sorts a part or a defect into a category.
- Segmentation: outlines the exact area of a defect, for example to measure how much of a surface is affected.
AI copes with variation that would need hundreds of hand-tuned rules. The cost is that it needs representative images, it must be validated on parts it has not seen, and every change means retraining and checking again.
Which to use for what
| Task | Usually best with | Why |
|---|---|---|
| Is every component or feature there? | Classical | Clear contrast, simple yes or no |
| Size, gap or position against a limit | Classical | Exact, traceable numbers |
| Barcode or Data Matrix | Classical | Standard decoders are reliable |
| Printed or engraved text | AI (OCR) or classical | Depends on print quality and fonts |
| Scratches, dents, voids on varied surfaces | AI (anomaly or detection) | Defects have no fixed shape |
| Right variant or wrong part | Either | Classical if a marking differs; AI if the look differs |
| How much of an area is damaged | AI (segmentation) | Needs the defect outline |
Combining both in one program
A typical program uses each where it is strongest. A classical tool locates the part and corrects its position. Measurements and code reading run as classical checks. An AI tool then looks only at the regions where cosmetic defects can appear. The verdict combines all of them, and a failure in any step is a reject.
This keeps most of the program fast and explainable, and uses AI only where it adds something.
How much data does AI need?
- Anomaly detection starts from good parts. Defect examples are then used to check it and fine-tune it.
- Detection and classification need labelled examples of each defect type, including borderline ones.
- Keep some images aside that the model never trains on, and judge it on those.
- Before a program goes live, run it on a set of known good and known bad parts (golden samples) and check that every verdict is right.
Questions to ask any supplier
- What happens if the AI model is missing or fails to load? (The right answer: the part is rejected.)
- Can you show the image and the reason for every reject?
- How are program and model versions controlled, and can we go back to the previous one?
- Who can change the inspection, and is every change recorded?