Skip to content

AI visual quality inspection: a camera and a model instead of the human eye

B2Bnetwork team · · 6 min

IT in manufacturing

In brief

Visual quality inspection means a camera over the line and software that decides on every image whether a part is good, passing doubtful cases to a person. It works where an inspector checks hundreds of parts per shift and fatigue lets defects through. Simple features (a dimension, a missing component) need only classic rules; defects that vary in appearance (scratches, dirt, blisters) need a model trained on images. Results depend on lighting, the set of defect images and two metrics: how many defects the system lets through and how many good parts it rejects.

When a camera beats the human eye

A visual inspector who looks at parts for eight hours gets worse at spotting rare defects as the shift goes on. Two inspectors judge the same part differently, and a third changes their mind after a break. A camera with software judges the same way at six in the morning and at two at night, and it stores an image of every part with its batch number.

Visual inspection usually pays off when at least two of these conditions hold:

  • high volume, for example a line making dozens of parts a minute where 100% human inspection is impossible,
  • the defect is visible in an image: color, shape, a scratch, a missing component, a wrong label,
  • an escaped defect is expensive: a complaint from an automotive customer, a batch recall, a contractual penalty,
  • disputes about judgment: inspectors disagree and there is no objective measure to settle it.

When the defect is not visible from outside (an internal crack, wrong hardness), a camera will not help and you need a different test method.

Rules or a model trained on images

Vision systems work in two ways, and a good implementation often combines them.

ApproachHow it worksWhen to choose itLimitations
Classic rulesmeasuring edges, dimensions, color or presence against thresholdsmeasurable features, a part that always looks the samecannot cope with defects of varying shape
Classification modelthe model judges the whole image: good or bad, possibly the defect typedefects of varying appearance, several defect typesneeds hundreds of images of each defect type
Detection and segmentationthe model marks where the defect is in the imagewhen the size and position of the defect mattermore work labeling images
Anomaly detectionthe model learns only from good parts and flags anything that differsrare defects, almost no defect imagesmore false alarms at the start

In a plant that is just starting, defects are rare, so anomaly detection gets you going faster. Over time, once you have an archive of defect images, you can move to classification with a defect type that goes straight into the nonconformity log.

Camera, optics and light

The most common reason for poor results is not the model but the image. A scratch that is invisible under the current lighting will not be found by any software. That is why the project starts with the inspection station:

  1. Lighting matched to the defect: low-angle light brings out scratches, backlighting shows the contour, diffuse light removes glare on shiny surfaces.
  2. A shroud that blocks light from the hall, because sunlight through a window changes the images during the day.
  3. A camera and lens with a resolution at which the smallest defect covers several pixels. Camera performance is compared using the EMVA 1288 standard, and the GenICam standard makes connecting cameras to software easier.
  4. Triggering the image with a sensor or a machine signal, so the part is always in the same place in the frame.
  5. Processing at the line on an edge computer, because the reject decision has to be made before the part passes the ejector. More on this in Edge computing in manufacturing and logistics.

Images, labeling and error metrics

The model learns from images labeled by people according to the plant's defect catalog. Sort out the catalog at the start: defect name, reference image, acceptance limit. If two inspectors give the same scratch different names, the model will learn that mess.

System quality is measured with two numbers that must never be averaged together:

MetricWhat it meansConsequence
Escaped defectsa defective part accepted as gooda complaint, risk at the customer
False rejectsa good part judged defectivewasted material, re-inspection

The decision threshold trades one error for the other: a lower threshold catches more defects but rejects more good parts. That is why parts scoring in the gray zone are better sent to an inspector than straight to scrap. An example to work with: at 10,000 parts per shift and a 2% gray zone, the inspector reviews 200 images instead of 10,000 parts.

Before go-live, the system is checked on a set of images the model has never seen, against the judgments of experienced inspectors. After go-live, watch for drift: a new raw material supplier, a different coating or a replaced lamp can change the images and raise false rejects. Track the reject rate per shift like any other process parameter, with a control chart, as described in SPC: statistical process control.

Connecting to the line, the MES and the nonconformity log

The camera's decision has three recipients. The line PLC gets a signal for the ejector. The MES stores the result with the order and batch number, which adds to batch traceability. The quality team gets the defects for analysis when they repeat on one machine or raw material batch.

That last step is paperwork that an AI Worker can take over. In the DYNAMINDS Labs Quality department, the Nonconformity logger creates an entry from a report or photos from the shop floor, adds the batch, order and line from the ERP and classifies the defect using the plant's defect list. The batch decision (rework, scrap, release) stays with a person. How to turn nonconformities into root cause analysis is covered in Nonconformities and the 8D report.

Questions and answers

How many defect images do we need to start?

For anomaly detection, images of good parts plus a few dozen defect images to check the results are enough to start. Classifying defect types usually needs hundreds of images of each type. When defects are rare, start with anomaly detection and build an image archive from the line, which later lets you move to classification.

Will a vision system replace the quality inspector?

It takes over looking at thousands of parts, but not the decisions. The inspector judges gray-zone cases, maintains the defect catalog, checks the system after changes on the line and decides on batches. The job shifts from looking at every part to making sure the system judges correctly.

What happens when the lighting or raw material changes?

The images start to look different, and false rejects or escaped defects can increase. That is why the station is shielded from hall lighting and the reject rate is tracked continuously. After a major change, such as a new raw material supplier, the model needs to be rechecked on new images and retrained if necessary.

Do we need to keep the part images?

It is worth keeping images of rejected parts and a sample of good ones, linked to the batch and order. They help with customer complaints, model retraining and audits. Agree the retention period with the quality team based on customer requirements, because a full archive of every image fills storage quickly.

Connecting the shop floor with your business systems? Talk to an engineer who has worked on MES and OT.

Let's talk

Read more: IT in manufacturing

All in IT in manufacturing →