Machine Vision DISCUSSION

How do I choose camera resolution and lens focal length for a machine vision inspection task?

Started by mehulpatel machine vision lens selectioncamera resolutionfield of viewfocal length calculationworking distance
5 replies 248 views 6 participants
Latest activity · 30 Sep 2026

How do I choose camera resolution and lens focal length for a machine vision inspection task?

mehulpatel Machine Vision Forum
#1

I need to inspect stamped metal parts up to 80 mm wide for scratches and burrs down to about 0.1 mm. The camera can be mounted roughly 300 mm above the part. I have looked at industrial cameras from 1.3 MP to 12 MP and C-mount lenses from 8 mm to 50 mm, and I do not know how to narrow it down.

Is there a systematic way to get from part size and smallest defect to a sensor resolution and a focal length?

Community replies 5

Re: How do I choose camera resolution and lens focal length for a machine vision inspection task?

#2

Start with the field of view and the smallest feature. The field of view should be larger than the part to allow for positioning tolerance, so take 100 mm for an 80 mm part. A defect must cover several pixels to be detected reliably; 3 pixels across the smallest defect is a common minimum for presence detection, and measurement tasks need more.

With 0.1 mm defects and 3 pixels, you need 0.033 mm per pixel. Across 100 mm that is 100 / 0.033 = 3,000 pixels on the long side. A 5 MP sensor (2448 × 2048) gives 0.041 mm per pixel, which is slightly short; a 12 MP sensor (4096 × 3000) gives 0.024 mm per pixel and leaves margin.

Re: How do I choose camera resolution and lens focal length for a machine vision inspection task?

#3

Focal length follows from magnification, m = sensor width / field of view. A 12 MP sensor with 3.45 µm pixels is 4096 × 3.45 µm = 14.1 mm wide, so m = 14.1 / 100 = 0.141. With the thin-lens approximation and the working distance measured from the lens, f = WD × m / (1 + m) = 300 × 0.141 / 1.141, about 37 mm. The nearest standard lens is 35 mm; it gives a field of about 107 mm at 300 mm, or you move the camera a little closer.

The quick version, f ≈ sensor width × WD / FOV, gives 42 mm here. It is fine for small magnifications but overestimates noticeably once m is above about 0.1.

Re: How do I choose camera resolution and lens focal length for a machine vision inspection task?

#4

Check that the lens matches the sensor. Two things matter: the image circle and the resolving power. A 12 MP sensor of this type is a 1.1 inch format with a diagonal of about 17.5 mm, so a lens designed for 2/3 inch sensors (11 mm image circle) will vignette in the corners. And 3.45 µm pixels need a lens rated for that pixel size; the sensor's Nyquist limit is 1 / (2 × 0.00345 mm), about 145 line pairs per mm, and a lens that resolves far less wastes the pixels you paid for.

Stopping down too far also costs resolution through diffraction, so very small apertures such as f/16 are a poor match for small pixels.

Re: How do I choose camera resolution and lens focal length for a machine vision inspection task?

#5

Resolution on paper is not contrast on the part. Whether a 0.1 mm scratch shows up depends mostly on lighting, and a scratch on metal is often only visible with low-angle (dark field) illumination, where it appears bright on a dark background. Test with real good and bad parts under the intended lighting before ordering the final camera. If the defect has strong contrast you may manage with fewer pixels, and if it does not, more pixels will not rescue it.

Also consider depth of field. If the part is not flat, the whole surface must stay in focus, which pushes you toward a smaller aperture and therefore more light or a longer exposure.

Re: How do I choose camera resolution and lens focal length for a machine vision inspection task?

#6

For dimensional measurement rather than defect detection, look at telecentric lenses. With a normal lens the magnification changes with distance: a surface 2 mm closer to the camera at 300 mm appears roughly 0.7 percent larger, around 0.5 mm on an 80 mm part. A telecentric lens keeps the magnification constant over its depth range and removes perspective error at the edges of tall parts.

The limitation is size. The front element must be at least as large as the field of view, so a 100 mm field needs a large and costly lens, and the working distance is fixed by the design. For scratch and burr detection a good fixed-focal-length lens is the normal choice.

TEP COMMUNITY