Skip to main content

Command Palette

Search for a command to run...

How to Select a Machine Vision Lens and Focal Length

Updated
10 min readView as Markdown

A practical route from field of view and working distance to a lens that also satisfies sensor coverage, image quality, and mechanical constraints.

Lens problems often arrive late. The camera has been ordered, the enclosure has been fabricated, and only then does the team discover that the part does not fit in the image, the corners are soft, or the calculated 25 mm lens needs a working distance the machine cannot provide.

Focal length is important, but it is not a complete lens specification. A reliable selection begins with geometry, then checks image circle, mount, resolution, distortion, aperture, depth of field, and the actual lens data at the intended working distance.

What you will learn

  • Estimate focal length from sensor size, field of view, and working distance.

  • Understand where the thin-lens approximation becomes unreliable.

  • Check sensor coverage, mount, resolution, distortion, and aperture.

  • Choose between fixed-focal-length, macro, and telecentric optics.

  • Validate a candidate lens before the mechanical design is frozen.

Technical foundation

Field of view, sensor size, and working distance

For a first-order estimate at modest magnification:

Focal length ≈ sensor dimension × working distance / field of view

Use horizontal sensor size with horizontal FOV, or vertical sensor size with vertical FOV. Keep the units consistent.

The working distance (WD) is normally measured from a defined mechanical reference on the lens to the object, while optical equations use principal planes that may lie inside the lens. This is why the result is a starting point, not a mechanical guarantee. Edmund Optics explicitly warns that paraxial estimates ignore principal-plane location and distortion, especially for short focal lengths and demanding geometries.

Magnification

Primary magnification is approximately:

Magnification = sensor dimension / field of view

If an 11.3 mm-wide sensor must view 240 mm:

Magnification = 11.3 / 240 = 0.047×

This value helps when selecting fixed-magnification or telecentric lenses and when checking lens resolution in object space.

Sensor format and image circle

A lens must cover the sensor diagonal. A lens designed for a smaller image circle can vignette or lose sharpness at the corners even if the mount fits. Do not rely only on legacy format labels such as “1 inch”; verify the sensor’s actual width, height, and diagonal against the lens specification.

Optical resolution and MTF

The modulation transfer function (MTF) describes how much contrast a lens preserves at different spatial frequencies. A high-resolution sensor behind an inadequate lens records more samples of a blurred image. Check lens performance for the sensor size, pixel pitch, wavelength, aperture, and intended field position.

[Suggested visual: lens-selection geometry with sensor width, focal length, WD, and FOV]

Purpose: Make the first-order focal-length relationship easy to apply.

Required elements: Object plane, lens with principal-plane caveat, sensor plane, labelled WD, FOV, sensor width, and ray bundle.

Suggested caption: “Focal-length calculations narrow the search; the lens datasheet and bench test finish the selection.”

Accessible alt text: “Ray diagram connecting an object field of view to a camera sensor through a lens, with working distance and dimensions labelled.”

Engineering workflow

1. Fix the inspection geometry

Define the usable FOV, object-height variation, minimum and preferred WD, available lens diameter, enclosure window, and permitted camera angle.

Why it matters: changing WD later changes FOV and often changes perspective, focus, and lighting access.

Common failure: treating WD as free space while ignoring the lens body, cable bend radius, lighting, guarding, and robot reach.

2. Record the real sensor dimensions

Use the camera datasheet’s active width and height. If only resolution and pixel pitch are supplied:

Sensor width = horizontal pixels × pixel pitch
Sensor height = vertical pixels × pixel pitch

For example, 2,448 pixels × 3.45 µm gives approximately 8.45 mm active width.

3. Estimate focal length in both axes

Calculate the horizontal and vertical requirements. The results should agree if sensor and FOV aspect ratios match. A mismatch signals that one axis will contain extra margin or require cropping.

Trade-off: a shorter focal length provides a wider FOV at the same WD but typically increases sensitivity to distortion and perspective. A longer focal length often requires more WD but can make lighting and geometry easier.

4. Shortlist real lenses

Select nearby standard focal lengths and use each manufacturer’s FOV data or calculator. Confirm:

  • Sensor coverage and mount

  • Minimum and nominal WD

  • Focusing range

  • Distortion

  • Relative illumination or vignetting

  • MTF or recommended pixel size

  • Aperture range and lockability

  • Environmental and mechanical suitability

5. Decide whether a standard lens is appropriate

Use a standard fixed-focal-length lens for general inspection when perspective and moderate distortion are acceptable. Consider macro or fixed-magnification optics at close WD or higher magnification. Consider an object-space telecentric lens when magnification must remain stable as part height changes or when parallax would compromise measurement.

6. Check focus and depth of field

Confirm that all required surfaces remain acceptably sharp. Closing the aperture increases depth of field but reduces light and eventually increases diffraction blur. Do not solve a depth-of-field problem by turning the iris to its smallest setting without an image-quality test.

7. Bench-test the complete optical path

Mount the actual camera and lens at the intended WD. Include the enclosure window if one will be used. Test centre and corners with the real lighting, aperture, focus, and wavelengths. Lock focus and aperture after approval.

Worked example: 240 mm conveyor field at 600 mm WD

Hypothetical application: a camera with an 11.3 mm active sensor width must cover a 240 mm horizontal FOV. The preferred WD is 600 mm.

First-order magnification:

M = 11.3 mm / 240 mm = 0.0471×

Estimated focal length:

f ≈ 11.3 mm × 600 mm / 240 mm
f ≈ 28.25 mm

This suggests evaluating real lenses near 25–30 mm. A simple estimate predicts:

FOV with 25 mm lens ≈ 11.3 × 600 / 25 = 271 mm
FOV with 30 mm lens ≈ 11.3 × 600 / 30 = 226 mm

Neither number should be treated as exact. The 25 mm option may provide comfortable guard band but fewer pixels per millimetre. The 30 mm option may require increasing WD to approximately:

Required WD ≈ FOV × f / sensor width
            ≈ 240 × 30 / 11.3
            ≈ 637 mm

The engineering choice is therefore either a wider 25 mm view at 600 mm, a 30 mm lens near 637 mm, or a less common focal length supported by verified manufacturer data. The correct answer also depends on distortion, MTF, lighting access, and mechanical tolerance.

[Suggested visual: comparison of 25 mm and 30 mm candidate lenses in the worked example]

Purpose: Show that lens choice is a geometry trade-off, not a single calculated number.

Required elements: Same sensor, two ray cones, 271 mm and 226 mm estimated FOVs at 600 mm, and an adjusted 637 mm WD case.

Suggested caption: “Nearby standard focal lengths require a decision between field margin and working distance.”

Accessible alt text: “Two camera diagrams compare the wider view of a 25 millimetre lens with the narrower view of a 30 millimetre lens.”

Practical lens-selection checklist

Requirement Evidence to collect Typical failure
FOV at usable WD Manufacturer data or bench measurement Part clipped at position extreme
Sensor coverage Supported image circle Vignetting or soft corners
Detail transfer MTF data and sample image More pixels but no more detail
Distortion Datasheet and calibration test Biased measurements near edges
Depth of field Worst-height image series Top surface sharp, lower edge blurred
Aperture Exposure and diffraction test Iris closed excessively
Mechanical fit CAD envelope and cable access Lens or light collides with guarding
Stability Focus/iris locks and rigid mount Settings drift after maintenance

Common mistakes

  1. Using only focal length. Two lenses with the same nominal focal length can differ in distortion, FOV, minimum WD, and image quality.

  2. Pairing a large sensor with a small image circle. The centre may look correct while the corners fail.

  3. Treating the calculated WD as a mechanical dimension. Principal-plane location makes the simple equation approximate.

  4. Ignoring pixel pitch and MTF. A lens suitable for a coarse sensor may not support a small-pixel camera.

  5. Selecting a very short lens to fit a tight machine. Distortion, perspective, corner quality, and lighting access may worsen.

  6. Closing the aperture for unlimited depth of field. Diffraction and lost light can reduce useful resolution.

  7. Testing without the enclosure window. Window tilt, flatness, contamination, and reflections can change the final image.

Validate the lens under real conditions

Use a calibrated target and representative parts. Verify FOV, pixels per millimetre, focus, contrast, distortion, and illumination uniformity at the nominal WD and mechanical limits. Repeat after loosening and re-tightening mounts to expose setup sensitivity.

For measurement applications, calibrate and check residual error with traceable artifacts across the whole FOV and at relevant object heights. For defect inspection, test the smallest accepted and rejected features in the corners as well as the centre.

Document lens model, serial number when appropriate, spacer configuration, aperture, focus position, WD reference, camera orientation, window, and lighting wavelength. A lens setting that exists only in an engineer’s memory is not a maintainable specification.

Key takeaways

  • Estimate focal length from sensor size, FOV, and WD, but treat it as a shortlist tool.

  • Verify real lenses with manufacturer data and a complete bench setup.

  • Sensor coverage, MTF, distortion, depth of field, and mechanical fit matter as much as focal length.

  • Avoid forcing a short focal length into a tight envelope without evaluating its optical costs.

  • Freeze and document the complete optical configuration after validation.

Follow this Hashnode blog for more practical machine-vision design guides, and connect with Kivanc Ekici on LinkedIn. For related engineering information, visit the ITAGE Türkiye website.

Frequently asked questions

How do I calculate focal length for a machine-vision camera?

As a first estimate, multiply the relevant sensor dimension by working distance and divide by the matching field of view. Then verify the result with the actual lens specification or a bench test.

Why does the real FOV differ from my calculation?

Simple equations assume ideal thin-lens geometry. Real lenses have principal planes, distortion, internal focusing, tolerances, and manufacturer-specific designs.

Can a lens cover a sensor if the mount fits?

Not necessarily. Mechanical mount compatibility and optical image-circle coverage are separate requirements.

When should I use a telecentric lens?

Consider one when measurement is sensitive to part-height variation, perspective, or magnification change. Telecentric optics are larger and more expensive, so the required measurement uncertainty should justify them.

Should I choose a lens by megapixel rating?

Use such ratings only as screening information. MTF at the relevant field position, aperture, wavelength, and sensor pixel pitch is more informative.

Sources