The Vision System That Saw Everything Except the Part

We integrated a vision system to inspect a molded plastic part for flash and surface defects. The camera was 5 megapixels, the lens was the “high resolution” one the sales rep recommended, and the lighting was a ring light the integrator said was “standard for plastic parts.” On the bench, the system worked perfectly — the part was clean, the room was quiet, and it detected every defect. On the production floor, it couldn’t see the part at all. The overhead lights reflected off the glossy plastic, the ring light created hot spots, and the camera picked up more glare than part.

We spent three days relighting. We swapped the ring light for a diffuse dome light, added polarizing filters, and re-ran the tuning. Finally it worked. The camera wasn’t the problem. The lens wasn’t the problem. The lighting was the problem — and that’s where machine vision integration lives or dies.

This article is what I’ve learned about putting vision systems on custom machines without ending up in a three-day lighting debugging session.

Camera Resolution: Enough to See the Defect, Not More Than You Need

The first question everyone asks is “how many megapixels?” It’s the wrong first question. The right first question is “what is the smallest feature you need to see?”

Pixel Resolution: The Math That Matters

If you need to detect a 0.1 mm defect on a 50 mm wide part, you need enough pixels across that 50 mm to resolve the 0.1 mm defect. A good rule is 3–5 pixels per smallest feature. That means you need 0.1 mm × 5 = 0.5 mm per pixel across the field of view. Over a 50 mm width, that’s 100 pixels minimum. A 640 × 480 camera gives you 640 pixels across — more than enough. A 5-megapixel camera gives you 2,448 pixels across, which is overkill and wastes processing time.

Field of View Smallest Feature Required Pixels Across Suggested Camera
50 mm (close-up inspection) 0.05 mm 5,000+ 12 MP +
100 mm (part presence) 0.5 mm 1,000 1.3 MP
300 mm (full station view) 2 mm 150 VGA (640×480)
500 mm (pallet presence) 5 mm 100 VGA or even webcam-grade

Bigger isn’t better. A higher-resolution camera over a small field of view means you’re processing millions of pixels per inspection, which slows down the cycle time. Use the minimum resolution that sees the feature you need.

Global Shutter vs. Rolling Shutter

If the part is moving when the photo is taken (on a conveyor, on a moving pallet), use a global shutter camera. A rolling shutter reads the sensor line by line, which creates skew on moving objects — the part looks like it’s melting. A global shutter captures the entire frame at once, which freezes motion. It costs more, but it’s the only option for moving parts.

Lens Selection: Focal Length and Working Distance

The lens determines how much of the scene the camera sees at a given distance. It’s a trade-off between field of view and working distance.

Focal Length: The Zoom Question

A longer focal length (higher mm number) magnifies more but sees a smaller area. A shorter focal length (lower mm) sees more but has more distortion. For machine vision, 8 mm to 25 mm lenses cover most applications:

  • 8 mm: Wide angle, close working distance (50–200 mm), good for large field of view.
  • 12 mm: General purpose, medium working distance (100–300 mm), most common.
  • 16 mm: Medium telephoto, longer working distance (200–500 mm), good for avoiding obstruction.
  • 25 mm +: Telephoto, long working distance (500 mm+), for inspecting small features from far away.

Working distance matters mechanically. If the lens has to sit behind a guard or inside a station, you need enough stand-off. A 25 mm lens at 300 mm working distance fits where an 8 mm lens at 80 mm doesn’t. Plan the mounting position before you pick the lens.

Aperture and Depth of Field

The aperture (f-stop) controls how much of the scene is in focus. A small aperture (f/8 or f/16) gives deep depth of field — everything from 100 mm to 500 mm is sharp. A large aperture (f/1.4) gives shallow depth of field — only a narrow plane is sharp. For machine vision, use a small aperture (f/5.6 to f/11) so the entire part is in focus, even if it has depth or variation.

The tradeoff is light. A small aperture lets in less light, so you need brighter lighting. That’s fine — machine vision lights are designed for this.

Lighting: The Part That Actually Determines Success

Lighting is 80% of machine vision. A good camera with bad lighting fails. A mediocre camera with good lighting works. This is where integrators earn their money.

Light Types: Match the Lighting to the Part

Light Type Best For Avoid For
Backlight (behind the part) Dimension measurement, presence/absence, edge detection Surface defects, color inspection
Ring light (around the lens) General illumination, flat surfaces, barcodes Glossy/reflective surfaces (causes hot spots)
Coaxial light (through the lens beam splitter) Flat reflective surfaces (metal, glass), scratches 3D parts with depth
Diffuse dome light Curved, glossy, or reflective parts (bottles, plastics) Large parts (expensive)
Dark field light (at grazing angle) Scratches, engravings, surface texture, defects Flat, matte surfaces

Color: Match the Light to the Defect

White light is default, but it’s not always best. Colored light creates contrast that white light doesn’t:

  • Red light: Absorbed by blue parts, reflected by red parts. Good for inspecting red plastics against blue backgrounds, or reading laser markings on metal.
  • Blue light: Short wavelength, good for fine detail and small features. Also reduces specular reflections on metal.
  • Green light: Even, bright, good for general use and color inspection.
  • IR (infrared): Penetrates certain materials, reveals hidden defects, or blocks visible-light interference.

The trick is to light the defect you want to see and make everything else uniform. If you’re looking for a scratch on a shiny metal surface, dark field lighting makes the scratch light up against the dark surface. If you’re measuring the outline of a translucent part, backlight makes it a sharp silhouette. Pick the light that makes the target pop.

The lighting test: Before you buy a $2,000 light, grab a flashlight and a sample part. Shine it at different angles. If you can see the defect with a flashlight, the right LED light will make the camera see it too. If you can’t see it with a flashlight, no LED will help.

Integration into the Machine: Mechanical and Electrical

A vision system isn’t just a camera on a bracket. It needs to be triggered, connected, and protected.

Triggering: When Does the Camera Take the Picture?

Continuous free-running (taking pictures as fast as possible) wastes processing. Trigger the camera from a sensor — a proximity switch that detects the part at the right position, or a PLC output that signals “part is in position.” A hardware trigger (digital I/O into the camera) is faster and more consistent than a software trigger over Ethernet.

Mounting: Vibration and Alignment

A camera that moves between cycles won’t give repeatable results. Mount the camera and light on a rigid bracket, not a sheet metal panel that flexes. If the machine vibrates, isolate the camera mount or use a higher shutter speed to freeze motion. A camera that drifts 0.5 mm between runs needs recalibration every shift.

Protection: Dust, Oil, and Coolant

Industrial environments have dust, oil mist, and occasional coolant spray. A camera lens without protection gets coated in six months. Use a protective cover glass (a cheap piece of glass in front of the lens that you can replace when it gets dirty) and a filtered air purge if the environment is really dirty.

A Vision Integration Checklist

  1. What is the smallest feature you need to detect? (Calculates required resolution)
  2. Is the part moving or stationary when the photo is taken? (Determines global vs. rolling shutter)
  3. What is the field of view and working distance? (Determines lens focal length)
  4. What material is the part? (Determines lighting type)
  5. Have you tested lighting with a flashlight and a sample part? (Do this before buying anything)
  6. How is the camera triggered? (Sensor or PLC, hardware or software)
  7. Is the camera mount rigid enough to survive vibration?
  8. How will you protect the lens from dust and oil?
  9. What is the cycle time budget for image processing? (Higher resolution = longer processing)
  10. How will the system reject bad parts? (Output to PLC, alarm, eject station)

The Bottom Line

Vision system integration for custom machines isn’t about buying the most expensive camera. It’s about lighting the part so the feature you care about is obvious. Start with the defect, pick the resolution that sees it, choose a lens that fits the mounting position, and spend the time on lighting that it deserves. The vision system that works on the production floor on day one is the one where someone held a flashlight to the part before ordering the light.