Triggering
The camera does not watch a video stream. A photo-eye shines across the belt at a reflector. When a part breaks the beam, it sends a pulse to the camera, which fires the light and takes one picture at that instant. Every part is photographed in the same place. On fast lines an encoder on the conveyor sets the exact delay.
Lighting
Most vision problems are lighting problems. A ring light sits around the lens axis and lights the part from every side at once, and the diffuser spreads each LED into a soft glow, so there are no hard shadows or hot spots. It is far brighter than the room, so lamps, windows and people walking past barely change the picture. Strobing the LEDs only during the exposure lets them run brighter and freezes motion.
Lens and focus
The lens bends light from the part into a small, upside-down image on the sensor. The focus ring slides the glass so that image is sharp at the working distance, here 330 mm, and is then locked. The iris sets the aperture: a smaller opening (a higher f-number) gives more depth of field but lets in less light, so the exposure has to go up. Switch to X-ray to see the rays meet on the sensor only when the focus is right.
Sensor and pixels
The sensor is a grid of light-sensitive pixels; this simulated one is 320 × 240, so each pixel covers about 1.1 mm of the part. Exposure is how long the pixels collect light. Too short and the picture is dark and grainy. Too long and bright areas clip to pure white, and a moving part smears. A defect has to cover several pixels to be found reliably.
Deciding
The processor runs a simple blob tool. Inside the region of interest, pixels darker than a set gray level (the orange line on the histogram) are grouped into blobs. The area of the largest blob is the defect score. Above the reject threshold, the part is rejected and the PLC tells a pusher to take it off the line.
Set the threshold too low and good parts are thrown away: false rejects, which cost money. Set it too high, or let the picture go dark, bright or soft, and bad parts pass: escapes, which reach the customer. A good set-up leaves a clear gap between the largest acceptable mark and the smallest real defect, and the threshold sits in that gap.