How to Choose a Lens for Machine Vision
Lens selection in machine vision begins with the requirements of the inspection task. The required field of view, working distance, image resolution, and lighting conditions influence the choice of focal length, sensor compatibility, aperture, and lens mount. Selecting a lens that matches these requirements helps ensure that the imaging system captures the required scene with sufficient image quality for inspection or measurement.
This article describes a typical lens selection process, beginning with the required field of view and working distance before covering sensor compatibility, lens mount, optical performance, and aperture. The Imaging Source's Lens Calculator Lens Calculator can assist with the calculations used to determine focal length and field of view.
Step 1: Calculate the Required Focal Length
The required focal length is often the starting point for lens selection. It determines the field of view at a given working distance and can be calculated from three known parameters: the required field of view (FOV), the working distance (WD), and the image sensor size.
For a given working distance, the focal length can be estimated using:
Focal Length (mm) = Sensor Size (mm) × Working Distance (mm) ÷ Field of View (mm)
Perform the calculation using both the horizontal and vertical sensor dimensions. The smaller focal length should be selected, as it ensures the required field of view is achieved in both directions and the entire object remains within the image.
Worked example:
An inspection system needs to image a 120 mm wide object from a working distance of 500 mm. The camera uses a 1/1.8" sensor, which has a horizontal dimension of approximately 7.2 mm.
FL = 7.2 × 500 ÷ 120 = 30 mm
Available focal lengths from lens manufacturers are typically: 6, 8, 12, 16, 25, 35, 50, and 75 mm. A calculated value of 30 mm does not correspond to a standard focal length, so the nearest available options are 25 mm and 35 mm. Choosing a 25 mm lens results in a slightly wider field of view than the design target: the object fills less of the frame. Choosing a 35 mm lens results in a narrower field of view. The appropriate choice depends on whether the application prioritizes additional scene coverage or greater image magnification.
A common sensor size reference:
|
Sensor Format |
Approximate Sensor Width |
Approximate Sensor Height |
Diagonal |
|
1/4" |
3.6 mm |
2.7 mm |
4.5 mm |
|
1/3" |
4.8 mm |
3.6 mm |
6.0 mm |
|
1/2" |
6.4 mm |
4.8 mm |
8.0 mm |
|
1/1.8" |
7.2 mm |
5.4 mm |
9.0 mm |
|
2/3" |
8.8 mm |
6.6 mm |
11.0 mm |
|
1" |
12.8 mm |
9.6 mm |
16.0 mm |
|
1.1" |
14.1 mm |
10.6 mm |
17.6 mm |
Note that sensor format designations (1/2", 2/3", 1") are historical conventions from the vidicon tube era and do not correspond to their literal dimensions. Always use the active sensor dimensions provided in the camera datasheet when performing field-of-view calculations.
Step 2: Verify the Image Circle Covers the Sensor
Every lens projects a circular image onto the sensor plane. The diameter of this projected image is referred to as the image circle. If the image circle is smaller than the sensor's diagonal, the corners of the image typically appear dark, a condition known as vignetting.
The lens specification typically states the maximum sensor format it supports. A lens rated for 2/3" covers a sensor with up to approximately 11 mm diagonal. A lens rated for 1" covers up to 16 mm. Using a lens with a smaller image circle than the sensor diagonal will produce vignetting regardless of aperture or camera settings.
As a general rule, the lens image circle should be equal to or larger than the sensor diagonal. When in doubt, select a lens rated for a larger format than the sensor. Selecting a lens rated for a larger sensor format provides additional flexibility if the system is later upgraded to a larger sensor while retaining the same lens.
Step 3: Select the Correct Mount Type
The lens mount defines the mechanical interface between the lens and the camera. It also establishes the flange focal distance (the distance between the mounting surface and the image sensor), which must be compatible between the lens and the camera.
C-Mount
C-mount is the most widely used lens mount in industrial machine vision. It uses a 1-inch 32 TPI threaded mount with a flange focal distance of 17.526 mm. The majority of industrial cameras from The Imaging Source, including the 38U, 33U, 38G, and 33G series, use C-mount or CS-mount. C-mount lenses are available for sensor formats up to approximately 1.1".
CS-Mount
CS-mount uses the same 1-inch 32 TPI thread as C-mount but with a shorter flange focal distance of 12.526 mm. A C-mount lens can be used on a CS-mount camera by inserting a 5 mm adapter ring, which extends the flange distance to match the C-mount specification. The reverse does not work: a CS-mount lens cannot be mounted on a C-mount camera body because the shorter flange focal distance cannot be accommodated by a C-mount camera body.
S-Mount (M12)
S-mount, also called M12, uses a 12 mm threaded mount and is commonly used in compact embedded vision systems and board-level cameras. The Imaging Source S-Pro and S-Ultra lens series are designed for the company's S-mount cameras, including the 36S MIPI CSI-2 series as well as board-level USB3 and GigE cameras. The lenses use a fixed aperture, simplifying the mechanical design and improving durability in vibration-prone environments.
|
Mount |
Thread |
Flange Distance |
Typical Sensor Coverage |
TIS Lens Series |
|
C-mount |
1" 32 TPI |
17.526 mm |
Up to 1.1" diagonal |
C-Pro, C-Ultra, Macro |
|
CS-mount |
1" 32 TPI |
12.526 mm |
Up to 2/3" diagonal |
(C-mount with adapter) |
|
S-mount (M12) |
M12 |
Varies by design |
Up to 1/2" typical |
S-Pro, S-Ultra |
Step 4: Match Lens Resolution to Sensor Resolution
To take full advantage of an image sensor, the lens should provide sufficient optical resolution to support the sensor's pixel size. If the lens cannot resolve individual pixels, because its optical resolution is lower than the sensor's pixel density, the result is softness or blur and image processing cannot fully restore detail that was not captured by the optics.
Lens resolution is typically specified in line pairs per millimeter (lp/mm) or, more commonly in industrial machine vision, as a recommended sensor megapixel rating. A lens specified for a 5 MP sensor is generally intended for sensors with a similar pixel density and may not fully utilize the resolving capability of a 12 MP sensor with a finer pixel pitch. Selecting a lens with an optical resolution that matches the sensor helps ensure that the imaging system can make effective use of the available sensor resolution.
The Imaging Source organizes its lens portfolio into two performance tiers for each mount type:
C-mount: The C-Pro Series covers resolutions from 6 MP to 20 MP and is suited to standard industrial imaging tasks where high performance and value are both priorities. The C-Ultra Series covers 6 MP to 45 MP and is designed for applications requiring the highest optical performance, with low distortion for precision measurement. The Macro Series provides fixed-focus, low-distortion lenses for close-up inspection tasks where the working distance is short and magnification is high.
S-mount (M12): The S-Pro Series provides cost-efficient, fixed-aperture M12 lenses for standard embedded and board-level imaging applications. The S-Ultra Series offers higher optical precision with distortion below 1%, designed for compact systems where image accuracy is a design requirement.
For metrology applications (where the vision system makes dimensional measurements), low distortion is a key lens parameter. Barrel and pincushion distortion introduce geometric error at the image edges, which translates directly into measurement error. The C-Ultra and S-Ultra series are specified for this type of application.
Step 5: Select the Aperture for the Application
The aperture, expressed as an f-number (for example, f/1.4, f/2.8, or f/8), determines how much light reaches the image sensor and has a significant influence on depth of field.
A lower f-number (wider aperture) admits more light and typically produces a shallower depth of field. A higher f-number (smaller aperture) admits less light but generally increases the range of distances that appear acceptably sharp. Selecting an appropriate aperture therefore involves balancing available light, required depth of field, and exposure time for the application.
Depth of field vs. illumination tradeoff:
|
f-number |
Light Transmission |
Depth of Field |
Typical Use Case |
|
f/1.4 - f/2.8 |
High |
Shallow |
Low-light environments; single-plane inspection |
|
f/4 - f/5.6 |
Medium |
Moderate |
General-purpose inspection with adequate lighting |
|
f/8 - f/11 |
Low |
Deep |
Dimensional measurement; variable-height objects |
|
f/16 and above |
Very low |
Very deep |
Rarely used; requires high-intensity illumination |
For inspection tasks where the object has significant height variation (components on a conveyor that are not perfectly flat, for example), a higher f-number provides the depth of field to keep the full object in focus. The tradeoff is that more light is needed to maintain adequate exposure. This is why aperture selection and lighting design are typically addressed together during system commissioning.
S-mount lenses typically have a fixed aperture, which simplifies this decision but also means the depth of field and light transmission are fixed at purchase. This is acceptable for most embedded vision applications where the lighting is controlled and object geometry is consistent.
Step 6: Consider Specialized Lens Options
Most machine vision applications use a standard fixed focal length lens. Some applications, however, have requirements that are better addressed by specialized lens types.
Macro lenses are designed for short working distances and high magnification. They are appropriate for applications requiring high magnification and short working distances, such as inspecting solder joints, microelectronics, or small mechanical components. Standard lenses have a minimum focus distance that may be too long for these tasks.
Telecentric lenses are designed to maintain nearly constant magnification despite small variations in object distance. For dimensional measurement applications where the object may not be at a perfectly consistent working distance, telecentricity minimizes perspective error that would otherwise cause apparent size changes. Telecentric lenses are bulkier and more expensive than standard lenses, and typically provide a smaller field of view for a given lens size.
Zoom and autofocus lenses Zoom lenses are useful when different fields of view are required without changing the camera position. Autofocus lenses are beneficial when the working distance varies and focus must be adjusted automatically. The Imaging Source product portfolio includes the Z Series zoom cameras and the Aptiris and AFU Series autofocus cameras for applications requiring adjustable optics.
Using the Lens Calculator
The Imaging Source Lens Calculator provides an interactive tool for working through the focal length and field of view calculations described in steps 1 and 2. Entering the sensor format, working distance, and required field of view returns the calculated focal length and suggests compatible lenses from The Imaging Source portfolio. It can also be used in reverse: entering a known focal length and working distance returns the resulting field of view, which is useful when adapting an existing lens to a new application.
Frequently asked questions
Both use the same 1-inch 32 TPI thread, but the flange focal distance differs: 17.526 mm for C-mount and 12.526 mm for CS-mount. A C-mount lens can be used on a CS-mount camera with a 5 mm adapter ring. A CS-mount lens cannot be used on a C-mount camera body. Industrial cameras from The Imaging Source are typically C-mount; CS-mount is more common in security and compact camera applications.
Compare the lens's stated maximum sensor format to the diagonal of your sensor. If the lens is rated for 2/3" (approximately 11 mm diagonal) and your sensor has a 1" diagonal (approximately 16 mm), the lens will not cover the sensor and vignetting will occur. Use the sensor dimensions from the camera datasheet for this calculation, not the format designation alone.
Focal length determines field of view and magnification but does not directly determine optical resolution. Resolution is a function of the lens's optical design and construction quality. However, longer focal lengths combined with smaller fields of view require the lens to resolve finer angular detail, which places higher demands on optical performance. For high-resolution sensors (20 MP and above) with long focal lengths, the C-Ultra Series is appropriate because the optical design is optimized for this operating range.
Yes, provided the mount type is compatible and the image circle covers the sensor diagonal of each camera. Moving a lens from a camera with a smaller sensor to one with a larger sensor may introduce vignetting if the image circle does not cover the new sensor. Moving the same lens to a camera with a different pixel pitch also changes the effective resolution performance: a lens optimized for a 5 MP sensor may not fully resolve the pixel-level detail of a 20 MP sensor.
For most factory inspection applications with controlled lighting, f/5.6 to f/8 is a common starting range. This provides moderate depth of field without requiring extremely high illumination intensity. Adjustments from this baseline depend on the specific lighting setup, the required exposure time, and whether depth of field or light sensitivity is the more critical constraint for the application.