Machine Vision Lens Selection: Focal Length, Field of View, Working Distance

A vision system is supposed to measure a part and reject defects. The integrator mounts a camera and lens that “look right,” and the images are soft at the edges, the part fills only a fraction of the frame, or the focus shifts as the part height varies. The camera resolution is not the bottleneck. The lens geometry is, and it is fixed before the first image is processed.

The three numbers are linked

Working distance is the distance from the front of the lens to the part. Field of view is the area the camera sees at that distance. Focal length determines how wide an angle the lens covers. For a given camera sensor and a chosen field of view, the focal length and working distance follow from simple geometry. Change one and the others move with it.

The basic relationship is focal length divided by sensor dimension equals working distance divided by field of view. If the sensor is 7 mm wide and you need a 50 mm field of view at a 100 mm working distance, the focal length works out to 14 mm. Pick a lens from a catalog without this calculation and you end up with the wrong coverage or no room to mount the camera.

Fill the frame

The part should occupy most of the field of view in the direction that matters. If you measure a 40 mm feature on a camera that sees 100 mm, most pixels look at empty background, and the feature gets fewer pixels than the sensor could provide. Resolution in the real world is field of view divided by pixel count. A 2448 pixel sensor across 100 mm gives about 0.041 mm per pixel; tighten the field to 50 mm and you get 0.02 mm per pixel, doubling the effective measurement resolution without changing the camera.

Don’t crop so tight that part position variation falls outside the frame. Leave margin for the actual placement tolerance. The field should cover the part at its worst position plus the feature being measured.

Working distance and mechanical space

Set the working distance from the physical cell, not from the lens catalog. If a robot or an operator moves through the space, the camera cannot sit 100 mm above the part. Longer working distance needs a longer focal length to hold the same field, which narrows the angle and can reduce depth of field. Resolve the mounting space before choosing optics; a perfect lens that cannot be mounted is useless.

Watch for the lens itself colliding with fixtures, lights, or the part as it indexes. Measure the real clearance, including the lens barrel and any filters, rather than assuming the camera drawing leaves enough room.

Depth of field

Depth of field is the range of distance over which the image stays acceptably sharp. If parts vary in height, or the conveyor surface moves, the feature must stay within that range. Stopping down the aperture increases depth of field but needs more light. Longer focal lengths and closer working distances give shallower depth of field, which is why a tight macro view can blur as soon as the part height changes by a millimeter.

Test with the real range of parts. A setup focused on one ideal sample fails when production parts vary, even though the demo images look clean.

Distortion and edge sharpness

Wide-angle short focal length lenses show barrel distortion: straight edges bow. That distorts measurements near the frame edges. Telecentric or low-distortion lenses correct this but cost more. If you measure dimensions across the field, characterize distortion or keep the measured features away from the extreme edges.

Cheap lenses are often soft in the corners. A part placed centrally looks sharp while one shifted to the edge blurs. Use the lens across the full field during evaluation, not just the center.

Telecentric lenses

A telecentric lens keeps magnification constant regardless of small changes in working distance and removes perspective error. It suits precise dimensional measurement where part height varies or edges must be measured without angle error. The lens must be at least as large as the field of view, so it becomes large and expensive on big parts. Specify it for genuine measurement needs; a fixed part on a flat surface rarely justifies the cost.

Matching the light and sensor

The lens mount must match the camera, and the lens should resolve the sensor’s pixel size; a lens that cannot resolve fine pixels wastes a high-resolution camera. The lighting geometry works with the lens: the light angle that reveals the defect has to fit around the barrel and stay within the working distance. Select lens and light together rather than bolting a ring light onto whatever lens was available.

Filters, covers, and environment

A bandpass filter over the lens blocks ambient light and passes only the strobe wavelength, which makes measurements stable as shop lighting changes. Protective covers keep spatter and coolant off the front element in dirty cells, but every added glass surface can introduce reflections and reduce light; use coated filters and angle them where needed. In a welding or machining station, a dirty or spattered front window is a maintenance item, not a one-time install; design access to clean or replace it without realigning the camera.

Verifying the system

Calibrate pixels to millimeters with a calibrated target at the actual working distance, and recheck after any focus or mount adjustment. Run a set of known-good and known-bad parts through the full lighting and handling cycle; a lens that passes a static test may blur or distort when parts move and the strobe freezes motion. Document the working distance, focal length, aperture, and light settings so a replacement lens can be set to the same geometry instead of re-engineering the station.

Bottom line

Start from the field of view the measurement needs and the working distance the cell allows, then calculate focal length. Fill the frame, verify depth of field over real part variation, and check distortion and corner sharpness across the full field. Use telecentric lenses where perspective or height variation directly causes measurement error. Fix the geometry before tuning software; no algorithm recovers detail and accuracy that the lens never captured.