Skip to content
Technical guide9 min read

How to choose a lens for machine vision

A practical engineer's guide to selecting machine-vision lenses: focal length from FOV and working distance, sensor format, resolving power, aperture, depth of field and telecentricity.

Why the lens deserves as much attention as the camera

In a machine-vision system the lens forms the image the sensor merely samples. No amount of resolution, processing or deep-learning software can recover detail the optics never delivered to the sensor plane. A mismatched or low-grade lens on a high-resolution camera is one of the most common and most expensive mistakes in inspection design, because the symptom (soft, low-contrast images) is easy to blame on the wrong subsystem.

Choosing a lens is a chain of dependent decisions. You start from the inspection task and the smallest feature you must resolve, work out the field of view and resolution that demands, then size the focal length to your available working distance and sensor format. Only after that do optical quality, aperture, depth of field, distortion and mount become the deciding factors between candidate lenses.

This guide walks that chain in order. The arithmetic is deliberately simple and vendor-neutral; the goal is to let you specify a lens with confidence before you ever open a supplier's selector tool.

Step 1: Focal length from field of view and working distance

For a standard (entocentric) lens, focal length, field of view (FOV) and working distance are linked by the sensor size through the basic thin-lens relationship. A workable approximation is: focal length f ≈ (sensor dimension × working distance) / field-of-view dimension. Use the sensor and FOV dimensions on the same axis (both horizontal or both vertical) and keep all values in the same units.

In practice you fix two of the three variables from your constraints. The FOV is set by the part size plus handling tolerance; the working distance is set by the mechanical envelope of the machine, guarding and lighting clearance. The focal length is then the value you solve for and round to the nearest available lens (commonly 8, 12, 16, 25, 35, 50 mm in C-mount). Re-check the result: a longer focal length narrows the FOV and increases stand-off, a shorter one widens the FOV but exaggerates perspective and edge distortion.

A worked example: a 2/3" sensor (~8.8 mm horizontal) imaging a 120 mm wide FOV at a 400 mm working distance needs roughly (8.8 × 400) / 120 ≈ 29 mm, so you would specify a 25 mm or 35 mm lens and adjust the working distance slightly to hit the exact framing.

  • Define the FOV from the largest part plus positioning tolerance, not just the nominal part size.
  • Fix the working distance from the real mechanical and lighting envelope before solving for focal length.
  • Round to a standard focal length, then trim the working distance to recover the exact FOV.
  • Remember magnification = sensor dimension / FOV dimension — useful when a supplier specifies lenses by magnification rather than focal length.

Step 2: Sensor format versus lens image circle

Every lens projects a circular image; the sensor crops a rectangle out of the centre of it. The lens image circle, quoted as a sensor format such as 1/1.8", 2/3", 1.1" or 4/3", must be at least as large as the diagonal of the sensor you are using. If the image circle is too small you get dark, blurred corners (vignetting) and a sharp drop in resolution away from the centre.

The trap is that sensor format names are nominal, not literal dimensions, and they have grown as resolution has climbed. A modern large-format sensor (1.1", 4/3" and up) needs a lens explicitly rated for that format; a lens designed for a 2/3" camera will not cover it. Always compare the actual sensor diagonal in millimetres against the lens image-circle diameter, and treat the format label only as a quick filter.

Using a larger-format lens on a smaller sensor is always safe optically — you simply use the sharp central region — but it costs size, weight and money. The economical choice is the lens whose image circle just covers your sensor with a little margin.

Step 3: Match resolving power and MTF to the sensor

A lens and a sensor each have a limiting resolution; the system resolution is governed by the weaker of the two. The sensor's limit is set by its pixel pitch (the Nyquist frequency is one line pair per two pixels). As pixels shrink below ~3 µm on high-resolution sensors, only lenses explicitly engineered as 'high-resolution' or 'X-megapixel' rated can keep up. Pairing an ordinary lens with such a sensor throws away the resolution you paid for.

Read this from the lens MTF (modulation transfer function) curves rather than a single 'megapixel' headline. MTF describes contrast as a function of spatial frequency (line pairs per mm) across the image, from centre to corner, usually at a couple of apertures. You want adequate contrast at the spatial frequency that corresponds to your sensor's Nyquist limit, and you want it to hold up toward the corners, not just on-axis.

As a sizing rule of thumb for the whole imaging chain, plan to spread the smallest defect you must reliably detect over roughly 3–5 pixels. That target sets your required resolution, which in turn sets both the sensor you choose and the resolving power the lens must deliver to it.

Step 4: Aperture, light and depth of field

The aperture (f-number) sets how much light reaches the sensor and how deep the in-focus zone is. Opening up (lower f-number) gathers more light, allowing shorter exposures for moving parts, but shrinks depth of field (DOF) and exposes the lens's worst aberrations. Stopping down (higher f-number) deepens DOF and cleans up corner performance, but eventually diffraction softens the whole image — so more stopping down is not always sharper.

Most fixed-focal-length machine-vision lenses are sharpest one to two stops down from wide open. Choose the working aperture together with your lighting design: bright, well-controlled lighting lets you stop down for DOF and sharpness, whereas dim or high-speed scenes force you toward wider apertures and shorter DOF. If parts vary in height or sit at an angle, DOF often becomes the binding constraint rather than raw resolution.

When DOF demands fight light demands, the right answer is usually more or better lighting rather than a wider aperture. AIS Components stocks bar, ring, dome, coaxial and backlight units (DCM Sistemes and others) precisely so that the optics can be stopped down to the sharp, deep-focus sweet spot.

  • Lower f-number: more light, shorter exposure, shallower depth of field, more visible aberrations.
  • Higher f-number: deeper depth of field, cleaner corners, but eventually diffraction-limited softness.
  • Practical sweet spot: roughly one to two stops down from the lens's maximum aperture.
  • If depth of field is short, fix it with lighting and aperture before reaching for a different lens.

Step 5: Lens mounts — C, CS, S and large-format

The mount is both a mechanical thread and a flange-focal-distance specification. C-mount is the industrial default: a 1" × 32 TPI thread with a 17.526 mm flange distance, suitable for sensors up to roughly 1". CS-mount uses the same thread but a 12.5 mm flange distance — 5 mm shorter. A C-mount lens works on a CS-mount camera with a 5 mm spacer ring; a CS-mount lens can never reach focus on a C-mount camera. Mismatched mounts are a frequent cause of 'won't focus' complaints.

Beyond C/CS, S-mount (M12) lenses are common on compact and embedded cameras and smart cameras, while large-format sensors move to F-mount, M42, M58 or other threaded mounts to cover the bigger image circle. Confirm the camera's mount and back-focal requirement against the lens before ordering, and account for any filters or extension tubes that change the optical path.

Match the mount to both the camera and the sensor size: a C-mount lens will physically thread onto a large-format camera but will not cover the sensor. For embedded and board-level builds, check that the lens holder and focus/lock mechanism suit a production environment with vibration and thermal cycling.

Step 6: Distortion and when to go telecentric

Standard lenses introduce geometric distortion (barrel or pincushion) and perspective error: features further from the optical axis are imaged at the wrong relative size, and parts nearer the lens appear larger than identical parts further away. For defect detection and presence checks this is usually tolerable, and residual distortion can often be calibrated out in software. For dimensional measurement it is a direct source of error.

Telecentric lenses solve this for metrology. An object-space telecentric lens accepts only rays parallel to the optical axis, so magnification stays constant across the depth of field: a part does not change apparent size as it moves toward or away from the lens, and there is essentially no perspective error. The cost is that the front element must be at least as large as the field of view, making telecentric lenses physically large, heavy and more expensive, and limiting them to FOVs the optic can cover.

Reach for a telecentric lens (often paired with telecentric backlighting) when you are measuring dimensions to tight tolerances, gauging holes or threads, inspecting parts with significant height variation, or checking 3D objects where edge position must be exact regardless of part position. For everything else, a good-quality fixed lens with software distortion correction is the more practical and economical choice.

  • Choose telecentric for: precision dimensional measurement, gauging, parts with height variation, edge-accurate inspection.
  • Choose a standard fixed lens for: defect detection, presence/absence, OCR/OCV, surface inspection and most general imaging.
  • Telecentric front element ≥ field of view — large FOVs make telecentric optics big and costly.
  • Calibrating out residual distortion in software is fine for inspection, but not a substitute for telecentricity in metrology.

Putting it together: a selection checklist

Work the decisions in dependency order so each choice constrains the next. Start from the task and the smallest defect, derive resolution and FOV, then focal length, then verify the lens covers the sensor and resolves it, and finally settle aperture, mount and whether telecentricity is required. Document the assumptions — part size, tolerance, working distance, lighting — because a change to any of them ripples through the whole optical chain.

If the application involves tight metrology, large-format high-resolution sensors, multi-camera setups or AI-based defect detection, the lens choice is tightly coupled to camera, lighting and software decisions and is worth validating with sample images on the real part. That is where an integrator earns its keep — AIS Vision can run application trials and feasibility studies, and Rosepetal handles the deep-learning inspection layer where rule-based vision falls short.

  • 1. Define the smallest feature to detect and target ~3–5 px across it.
  • 2. Set FOV from part size + tolerance, and working distance from the machine envelope.
  • 3. Solve for focal length: f ≈ (sensor dimension × working distance) / FOV dimension.
  • 4. Confirm the lens image circle covers the sensor diagonal with margin.
  • 5. Check MTF/resolving power against the sensor's pixel pitch (Nyquist).
  • 6. Pick a working aperture ~1–2 stops down; balance light vs depth of field with lighting.
  • 7. Verify the mount (C / CS / S / large-format) matches camera and sensor.
  • 8. Decide standard vs telecentric based on whether you are measuring or detecting.

Frequently asked questions

Related categories

  • Lenses and filters
  • C-mount lenses
  • Telecentric lenses
  • Machine vision lighting
  • High-resolution cameras

Related guides

Request a technical quote

If you have a specific application, we help you select the right hardware and validate it.