Computer Vision for Quality Control on Production Lines
Advanced4 minInnovialabs editorial team
In short
Computer vision inspects every part with a camera and a model that flags defects; success depends less on the algorithm than on stable lighting, representative defect images, agreed accuracy targets and a clear action when a defect is found.
What it does and when it fits
A vision inspection system photographs each product on the line and decides: good, defective, or uncertain. It fits when:
- the defect is visible to a camera (scratches, cracks, missing parts, wrong labels, color or shape deviations, contamination);
- inspection is currently manual, tiring and inconsistent between shifts;
- the line speed makes 100% manual inspection impossible;
- the cost of a defect reaching the customer is high.
It fits poorly when the defect is internal, depends on touch or smell, or varies so much that even experts disagree.
The physical setup comes first
Most failed projects fail on optics, not on AI.
- Camera. Area-scan cameras for discrete parts, line-scan cameras for continuous material (film, textile, sheet metal). Resolution must make the smallest defect span several pixels.
- Lens. Chosen for field of view and working distance; telecentric lenses help when measuring dimensions.
- Lighting. The single most important factor. Backlight for silhouettes and holes, diffuse dome light for shiny surfaces, low-angle light to reveal scratches and dents, specific wavelengths for certain materials.
- Enclosure. Shield the station from sunlight and shop lights that change during the day.
- Trigger. A sensor or encoder fires the camera exactly when the part is in position, so every image looks the same.
A useful test: if a person looking at the captured images cannot reliably see the defect, no model will.
Choosing the model approach
| Approach | When to use |
|---|---|
| Rule-based vision (edges, blobs, measurements) | Clear, geometric checks: presence, position, dimensions, barcode reading |
| Classification | The whole image is "good" or one of several defect types |
| Object detection | Defects must be located and counted |
| Segmentation | Defect area or shape matters |
| Anomaly detection | Defects are rare and varied; train mostly on good parts |
Combining approaches is normal: rules check dimensions, a neural network checks surface defects.
Collecting training data
- Capture on the real line, with the final camera and lighting. Images from a phone or a lab setup will not transfer.
- Collect good parts first — they are plentiful. Defects are rare, so start a defect library early and ask quality staff to set aside defective samples.
- Cover variation: all product variants, colors, batches, suppliers, shifts and normal process drift.
- Label consistently. Write a defect catalog with example images and acceptance limits. Have two people label a sample independently to find where they disagree.
- Keep a separate test set that the model never sees during training.
Setting accuracy targets
"99% accuracy" says little when defects are rare. Agree on two numbers with the quality team:
- Escape rate (false negatives) — defective parts passed as good. Usually the critical one.
- False reject rate (false positives) — good parts rejected. Drives scrap and re-inspection cost.
You trade one against the other by moving the decision threshold. Also define an uncertain zone: parts the model is unsure about go to a human instead of being forced into a yes or no. Compare targets with the real performance of current manual inspection, measured on the same parts.
Integrating with the line
- Cycle time — inference must finish before the next part arrives; this decides between an edge device near the line and a server.
- Action — reject gate, air jet, line stop, marking, or alert to an operator.
- Communication with the PLC through digital I/O, OPC UA or industrial protocols.
- Traceability — store images and decisions with batch and timestamp, linked to MES or quality systems.
- Operator interface — show why a part was rejected and let staff confirm or override; these confirmations become new training data.
Pilot pitfalls
- Training on a perfect dataset collected over one day, then facing new batches and lighting.
- No agreed definition of a defect between quality, production and the customer.
- Underestimating mechanical work: part positioning, conveyors, reject mechanisms.
- No process for retraining when products or materials change.
- Measuring success on accuracy alone, without escape and false reject rates.