1. What a vision system does
A machine vision system captures an image of each item as it passes, analyses it and decides whether it is acceptable. Tasks include reading the text and codes on labels and packs, checking that seals are closed and clean, confirming the fill level, finding missing or broken items in a tray, spotting foreign objects with a different colour or shape from the product and checking the position and orientation of items.
Classical systems apply rules, such as comparing pixel brightness or measuring a shape. Newer systems use deep learning, in which a neural network is trained on many labelled images to recognise patterns, including ones that are hard to describe in rules, such as the look of a burnt biscuit. Many installations combine the two. Vision complements the optical sorting described in Module 3.9, which works on bulk product in free fall, and the X-ray and metal detection described earlier, which work on density and conductivity, not appearance.
2. Lighting and optics come first
A common mistake is to treat software as the solution and to neglect the image. Poor, uneven or changing light is the most frequent cause of poor performance. Choose lighting to make the defect stand out: low-angle light to show surface texture, backlighting to show silhouettes and holes, diffuse light to avoid glare on shiny packs and coloured or infrared light to boost contrast. Shield the station from stray light, and use light sources with stable output.
Camera resolution must match the defect. As a rule of thumb, the smallest defect to be found should span at least three pixels. To find a 1 mm defect, the pixel size on the product must be about 0.33 mm or smaller. If the field of view is 300 mm wide, the camera needs at least 300 ÷ 0.33, about 900 pixels across, and in practice more, to allow margin. Speed matters too: for a line running 600 items a minute, each item has 100 milliseconds, and the system must capture, analyse and trigger a reject within that time, with the reject point placed correctly downstream.
Figure 11.6 — High-Speed Camera Capture, CNN Feature Extraction, Seal & Label Classification, and Encoder-Synchronized Reject Workflow
3. Training a deep learning model
- Collect images from the real line, under real conditions, including every product variant and the normal variation in position, colour and lighting.
- Label them carefully. Experts decide what counts as a defect, and the labels must be consistent, since inconsistency in the training data limits what the model can learn.
- Balance the classes. Defects are rare, so seek out examples, for instance by seeding known defects, and use augmentation, such as rotating or adjusting images, to increase variety.
- Split the data. Train on one set, tune on a second and test on a third that the model has never seen.
- Include difficult cases, such as borderline defects and good items that look odd.
- Keep a record of the images, labels, model version and settings.
A few hundred examples of each defect class may be enough for a simple task, but complex tasks need thousands. Where defects are too rare, anomaly detection models, trained only on good items, can flag anything unusual.
4. Measuring performance
The same measures apply as for any classifier. Recall is the share of real defects that are rejected, and precision is the share of rejects that are real defects. A false reject wastes good product, and a false accept lets a defect pass. The trade-off is set by the decision threshold: lowering it catches more defects but rejects more good items.
The threshold should be chosen from the consequences. For a safety-critical defect, such as a foreign object, a very high recall is needed, and a higher false reject rate may be accepted. For a cosmetic defect, a balanced setting is better. Report results by defect type and size, and by line speed, since performance usually falls as speed rises.
5. Validation, drift and change control
Validate the system as a control, using test items with known defects mixed into the normal flow. A statistical approach, like that in Module 9.9, shows the detection rate with confidence: for example, 59 consecutive correct detections of a defect type support a claim of at least 95 percent detection at 95 percent confidence. Run a challenge at the start of each shift with known good and bad items, and record the result.
Models drift. New packaging, a different supplier’s film, a change in lighting, dirt on the lens or a seasonal change in the product can alter the images, and performance falls without any alarm. Monitor the reject rate and the confidence scores, check for sudden changes, clean optics on a schedule and revalidate after any change in product, packaging, camera, lighting or software. Control the model like any critical setting: version it, limit who can change it and record every change.
Example scenario (illustrative)
A plant that packs salads uses a vision system to find plastic fragments among leaves. For months it works well. After a change to a new green film for the bags, the reject rate jumps to 4 percent, and operators begin to turn down the sensitivity to keep the line running. A review finds that the new film’s green is close to that of the old test fragments, and the model needs retraining with images that include the new colour. The plant retrains, revalidates with seeded pieces and adds a rule that no sensitivity change can be made without quality approval.
6. Privacy, ethics and human factors
Cameras in a plant can also see people. Using them to monitor hygiene, for example to check that hairnets are worn, raises questions about privacy, consent and trust, and the law differs by country. If such monitoring is considered, involve staff and their representatives, state the purpose, limit the data collected, avoid identifying individuals where possible and follow data protection law.
Human factors matter in product inspection. Operators need to understand what the system is looking for and what a reject means. They should know how to respond to alarms, report suspected faults and test the system with confidence. A vision system that nobody trusts will be bypassed.
