Quality Control with Computer Vision: Types, Hardware, Setup
How is quality control with computer vision set up? Defect, measurement, assembly, label, OCR and counting inspection; camera, lighting, reject via PLC and validation steps.
Translated from the Turkish original · Türkçe aslı
Quality control with computer vision means that an industrial camera on the line captures an image of every part under controlled lighting, software searches that image for defects, dimensional deviations, missing components, position errors or code errors, and the decision is sent to the PLC as an OK/NOK signal. Defective parts are removed from the line by a reject mechanism, and the image behind every decision is kept on record.
We covered the quality management side of moving from sampling inspection to continuous inspection in our article on Quality 4.0. This guide focuses on the engineering side of automated quality control systems: what types of inspection there are, which camera, lens and lighting are needed, how the system is connected to line speed and the PLC, how its reliability is proven, and what to do about defects the camera cannot see.
What defects does quality control with computer vision catch?
Defect detection with computer vision falls into six main types of inspection. Each has a different optical setup, decision logic and measure of success, so the types required in a project should be specified one by one.
| Inspection type | What it catches | Example metric (CX solution page) | Solution page |
|---|---|---|---|
| Surface defect | Scratches, burrs, porosity, weld defects, stains and colour deviation | Smallest distinguishable defect 0.05 mm; 60 parts/min at line speed | Surface and defect inspection |
| Dimensional measurement | Diameter, length, angle and centre-to-centre distance; the result is compared against the tolerance table | Repeatable measurement precision ±0.02 mm; 12 critical dimensions per frame | Dimensional measurement and tolerance control |
| Presence/absence and assembly | Missing or reversed components, open lids | Decision time per station under 200 ms; 24 components per frame | Assembly inspection |
| Position and label | Position and rotation angle of a label, print or cap relative to the product | Tolerance ±0.3 mm position, ±1° angle; 120 items/min line speed | Label alignment inspection |
| Code and OCR verification | Barcode, QR, DataMatrix, dot-peen code and printed characters; matching against order or batch data | First-read success rate 99.8% | Barcode, QR and OCR verification |
| Counting and classification | Recognising, counting and sorting products on a conveyor by shape, size and colour | Counting accuracy 99.3%; maximum flow rate 1,000 units/min | Product counting and classification |
The values for surface inspection depend on the optics and field of view. In assembly inspection, a missing clip, a reversed seal or an open lid is stopped before it passes to the next station; in code verification, a product that does not match does not move on down the line; in counting, the product is diverted to a sorting actuator if necessary.
What is the difference between classical computer vision and deep learning?
Rule-based classical computer vision works through steps defined by the engineer: thresholding, edge detection, blob analysis, template matching and measurement calipers. If the defect or dimension can be precisely described, this method is fast, explainable and can be set up with little data. That is why dimensional measurement, positioning and code reading are largely done with classical tools; it can be shown which edge and which threshold each decision came from.
Deep learning, by contrast, learns the rule from examples. Wood, leather and cast surfaces with natural texture variation, scratches and stains whose shape changes every time, or cases where the difference between good and bad cannot be described, are the domain of deep learning. In return, it requires labelled data, training time and a validation regime that demonstrates the consistency of its decisions. In the field, most systems are hybrid: the part is located and aligned with a classical tool, the dimension is taken with a classical method, and surface classification is done with deep learning.
How do you choose a quality control camera and lens?
On-line inspection uses a triggered global shutter industrial camera that does not produce distortion on moving parts; for continuously flowing sheet metal, paper, film or fabric, a line scan camera is preferred. A colour camera is needed only if colour deviation is being inspected or the product or component is distinguished by its colour; a monochrome sensor gives more detail and light sensitivity at the same resolution. Security cameras are generally not suitable for this job: they do not offer external triggering, short exposure synchronised with the lighting, or optics chosen for the part.
Resolution is calculated from the ratio of the field of view to the smallest feature being sought. Example: if a 100 mm wide field of view is imaged with a sensor giving about 2,450 pixels horizontally, each pixel covers about 0.04 mm and a 0.12 mm scratch spans 3 pixels. As the defect shrinks to the scale of a single pixel, the decision gets lost in noise; that is why the aim is for the smallest defect to cover several pixels.
In lens selection, working distance, field of view and depth of field are decisive. In measurement, if perspective error, where a part's size in the image changes as its height changes, eats up the tolerance budget, a telecentric lens is used; for surface and assembly inspection, a fixed-focus industrial lens is usually sufficient.
Which lighting makes which defect visible?
In machine vision, lighting is the main tool that separates the defect from the background. The choice depends on the material, the glossiness of the surface and the feature being sought; the same part looks completely different under different light.
| Lighting | How it works | Suitable jobs and limitation |
|---|---|---|
| Backlight | Places the part between the light source and the camera, producing a sharp silhouette | Measurement, hole presence and counting transparent products |
| Ring light | Provides general-purpose, low-shadow light from around the lens | General purpose; can create hot spots on glossy surfaces |
| Low-angle ring / dark field | Surface detail scatters light into the camera; bright marks appear on a dark background | Scratches, embossing and texture on the surface |
| Coaxial lighting | Sends light along the camera axis; flat, reflective surfaces appear bright | Scratches, pits and laser marking show up as dark marks |
| Dome lighting | Diffuses light from all directions, evening out reflections on curved and glossy surfaces | Foil packaging, metal caps and domed parts |
Ambient light, meanwhile, is a problem in every installation: changes in window or ceiling light over the day are one of the most common sources of false rejects, which is why the station is isolated with an enclosure or pulsed lighting.
How are triggering, line speed and the reject mechanism set up?
Images are captured by triggering, not from a continuous stream: when a part passes a photoelectric sensor or the conveyor encoder counts a certain step, the camera captures and the lighting pulses at the same moment. Exposure time determines motion blur. Example: a part moving at 0.5 m/s travels 0.05 mm during a 100-microsecond exposure; in a setup where each pixel covers 0.04 mm, this is blur slightly exceeding one pixel. A shorter exposure requires stronger light.
The decision time must fit within the distance between the camera and the reject point and the line speed. The result goes to the PLC as a digital OK/NOK output or over a fieldbus network such as Profinet or EtherNet/IP. If there is more than one part between the camera and the pusher, the PLC tracks the decision for each part using the encoder count and triggers the reject actuator on the correct part. The choice between an air jet, a pusher arm or a diverter is made according to the part's weight and the speed.
Two safety rules are designed in from the start. The first is fail-safe behaviour: if an image cannot be captured or the decision does not arrive in time, the part is treated as NOK, not accepted as good. The second is reject verification: a separate sensor confirms that the rejected part actually dropped into the reject bin, and the line issues a warning when the bin is full.
How is a model trained when defective samples are scarce?
On a well-running line, defective parts are scarce, and this is where deep learning struggles most: a model cannot classify a defect type it has never seen an example of. In the field, three approaches are used together. The first is the anomaly approach, which learns the good surface and flags whatever deviates from it; we explained the details in our article on surface defect detection. The second is a defect catalogue: the quality team collects examples of each defect type from past returns, the scrap bin and boundary samples. The third is data augmentation and synthetic samples; however, success is measured only on a test set made up of real parts.
Label consistency matters more than the amount of data. Where two quality technicians make different decisions on the same part, the model also learns inconsistently. That is why, before labelling, the boundary between acceptance and rejection is written down using boundary samples; the same samples later form the basis of validation as well.
How is the system's reliability validated?
A quality control camera is a measuring instrument and is validated like a caliper. Measurement system analysis (MSA) asks whether the system gives the same result for the same part again and again (repeatability), whether it produces the same result under changing conditions (reproducibility) and how close it is to the reference value (bias). In a vision system, the operator effect is replaced by re-placing the part in the fixture and by changes in shift and lighting.
In dimensional measurement, this is a Gage R&R study. According to the AIAG MSA manual, a common reference in the automotive supply chain, a measurement system is accepted if %GRR is below 10%, may be conditionally accepted between 10% and 30% depending on the importance of the application, and is not accepted above 30%. For surface and assembly inspection, which make OK/NOK decisions, an attribute agreement analysis is carried out instead: a set of good, defective and borderline parts with known correct decisions is fed to the system many times; missed defects and unnecessary rejects are reported separately, because their costs differ.
Validation does not end with commissioning. Running a known good and a known defective reference part through the system at the start of each shift catches drift, such as weakening light, a dirty lens or a camera that has shifted out of position, before production starts.
What steps does the installation follow?
The installation proceeds in six steps:
- Requirements definition: which defect or dimension will be inspected, with what tolerance, at what line speed, and what the acceptance criterion will be. A defect catalogue and technical drawing are the outputs of this step.
- Feasibility: good, defective and boundary samples are imaged on the bench with different camera, lens and lighting setups; this is where it becomes clear which defect is reliably visible under which light.
- Line design: the station location, enclosure, triggering, PLC signals, reject mechanism and the fields with which records will be written to the MES are defined.
- Observation mode: the system runs on the line but does not reject parts; its decisions are compared with the quality team's checks, and thresholds are adjusted.
- Validation: an MSA or attribute agreement study is carried out, and the result is compared with the acceptance criterion written at the outset.
- Commissioning: the reject mechanism is activated; the start-of-shift reference part check and responsibility for model updates are put in writing.
What defects can a camera not see?
In opaque materials, a camera sees only the surface that light reaches; in glass and transparent plastic, internal bubbles and foreign matter can be seen. Voids inside a casting, lack of fusion inside a weld seam, delamination within a material or a missing part inside a closed box cannot be found with computer vision. Non-destructive testing is used for these defects: X-ray (radiography) to see internal structure, and ultrasonic testing for discontinuities within the material and wall thickness. X-ray images can also be analysed automatically, but that is a separate project involving radiation safety and choice of radiation source.
There are limits on the visible surface as well. A camera cannot inspect the side of a part that is not facing it; multi-sided parts require more than one camera, mirrors or a station that rotates the part. Two-dimensional images are not enough for three-dimensional measurements such as height, pit depth and flatness; a laser profiler or 3D camera is required. Making this distinction clearly during the site survey prevents false expectations later.
Where to start?
Rather than connecting the entire line to cameras at once, starting with the single defect type that generates the most scrap or customer complaints makes it possible to prove the optics, thresholds and PLC integration at one station. We have gathered the questions to ask when talking to suppliers in our guide to choosing a computer vision company.
At CX Teknoloji, we set up surface, measurement, assembly, label, OCR and counting inspection from GTU Technopark in Gebze. We start with a bench test using sample parts, define the acceptance criterion with you in writing, and first run the system in observation mode, comparing its decisions with your quality team's checks. If you share your part and tolerance table, we can show on a sample which inspection can be done with which optics.
Frequently asked questions
Can security cameras be used for quality control with computer vision?
Generally not. On-line quality control requires a triggered global shutter industrial camera, a lens chosen for the part and field of view, and controlled lighting suited to the defect type. Because security cameras do not offer short exposure, triggering or lighting control, they do not give reliable results for fine defect and measurement inspection. There may be exceptions for coarse jobs such as counting boxes; the decision is made through a sample test.
Does a quality control camera slow down the production line?
Not at a properly designed station. The image is captured by triggering from a sensor or encoder, the decision is made within a time that fits the line speed and is sent to the PLC as OK/NOK; the reject mechanism removes the defective part without stopping the line. For example, in our assembly inspection solution, the decision time per station is under 200 ms. If the line speed is high, the camera type, exposure and lighting are chosen accordingly.
Should you choose classical computer vision or deep learning?
The choice depends on how precisely the defect can be described. For jobs that can be defined by rules, such as measurement, positioning and code reading, classical computer vision is fast, explainable and can be set up with little data. On surfaces with natural texture variation and for defects that change shape, deep learning is stronger but requires labelled data. Most systems in the field use both together: positioning and measurement are done classically, surface classification with deep learning.
Does a computer vision system catch every defect?
No inspection system gives an unconditional 100% guarantee; reliability is demonstrated by measurement. In OK/NOK inspection, a set of good, defective and borderline parts with known correct decisions is fed to the system many times, and the rates of missed defects and unnecessary rejects are reported separately. At measurement stations, a Gage R&R study is carried out. The acceptance criterion is written before commissioning and maintained with a start-of-shift reference part check.
We have very few defective samples; can a model still be trained?
Yes, but the method is chosen accordingly. In the anomaly approach, the model learns from plentiful good parts and flags regions that deviate from the good appearance as defect candidates. To distinguish defect types, a defect catalogue is built from past returns, scrap and boundary samples; data augmentation is used if needed. In every case, success is measured only on a test set made up of real parts.
Can a camera see defects inside a part?
Not in opaque materials; in light-transmitting materials such as glass and transparent plastic, however, internal bubbles and foreign matter can be seen with a camera. In an opaque part, the camera sees only the surface that light reaches; voids inside a casting, lack of fusion inside a weld or delamination within a material cannot be found with computer vision. Non-destructive methods such as X-ray (radiography) or ultrasonic testing are used for these defects. X-ray images can also be analysed automatically, but because of radiation safety and equipment selection they are handled as a separate project.