Article sections
Lens selection: focal length and depth of fieldHow should a focal length calculation be interpreted?What checks are needed for a lens acceptance test?How to read a lens's image quality graphsFrequently asked questionsLens selection: focal length and depth of field
The camera and lens are not two independent products. Camera sensor size, the area to be viewed, working distance, and the required detail directly constrain the lens. Pairing a good sensor with an unsuitable lens prevents you from realizing the device's full potential in the field.
How should lens focal length and working distance be selected together?
Field of view (FOV) describes how much of the part you image; working distance describes the spacing between the lens and the part; magnification describes how much space a distance on the object occupies on the sensor.
As a simplified first approximation, if the sensor's horizontal width is 8 mm and the required horizontal field of view is 160 mm the magnification is approximately 0.05×. Taking the working distance as approximately 400 mm, a thin-lens assumption gives an initial focal length estimate on the order of 20 mm.
This value is not a purchasing decision. In real lenses, the positions of the principal planes, the focusing mechanism, close-up conditions, and the manufacturer's working distance limits affect the result. The calculation must be verified against the product's optical drawings and by acquiring images in the field. [5]
The lens determines not only how much we see, but also how well we see it
Two lenses may provide the same field of view without transferring the same detail. This is where the concept of MTF (modulation transfer function) comes in. Simply put, MTF describes how well a lens preserves the contrast of details of different sizes. It can be critical to the visibility of edges and fine lines.
When reviewing manufacturer data, consider sensor format compatibility, center and edge performance, distortion, and the aperture to be used together. As sensor resolution increases, the detail the lens can transfer does not become less important; instead, its importance becomes more apparent.
The relationship between depth of field, aperture, and lighting
If parts do not sit at the same height every time, they all need to appear sufficiently sharp. Depth of field is the range of object distances over which acceptable sharpness is maintained. Stopping down the aperture generally increases this range, but reduces the light reaching the sensor. Stopping down too far can impair fine detail through diffraction.
So 'let's increase the f-number to make everything sharp' is an easy but incomplete solution. Good design first establishes the tolerance range, then adjusts the lens, working distance, lighting, and aperture together.
How is lens resolution matched to sensor pixels?
Marketing a lens as '12 MP compatible' is not, by itself, a sufficient technical specification. You need to examine the contrast with which the lens transfers fine detail to the sensor. The manufacturer's MTF curves help you understand center and corner performance at the spatial frequency of interest.
Example: 3.45 µm pixel pitch
For a monochrome sensor with a pixel pitch of 3.45 µm, the Nyquist sampling frequency at the sensor plane is approximately 145 line pairs/mm. This does not mean the lens transfers good contrast at this frequency; it only specifies the sampling limit.
Evaluate this value alongside the lens's MTF curve at the relevant aperture and images of actual samples. If defect contrast is very low, a high sampling count alone will not be sufficient.
Geometric distortion can often be modeled through calibration, but calibration does not restore the lost contrast of a blurred line. For the same reason, a sharper sensor cannot compensate for information lost through a poor lens.
How does changing from f/4 to f/8 affect exposure?
With the same lens and conditions, changing from f/4 to f/8 ideally reduces the light flux reaching the sensor to approximately one quarter. Maintaining the same signal level then requires stronger lighting or a longer exposure. On a moving line, however, extending exposure can cause blur. At a very small aperture, diffraction can also weaken fine detail. Depth of field, sharpness, and light cannot be adjusted independently.
What physical limits should you check after calculating focal length?
Calculating a focal length of approximately 19-20 mm is a useful starting point, but in a real installation the lens's physical length, focusing mechanism, front working clearance, and mounting orientation are also decisive. Some catalogs define working distance from the front of the lens, while some technical drawings use another reference plane. Applying the thin-lens equation directly to the product drawing of a specific lens system can lead to errors.
Particularly on a line close to mechanical arms, the lens body may collide with the product, a wide-angle lens's perspective may make measurements at the edges difficult, or a long focal length may leave insufficient working distance within the enclosure. Before selecting a model, therefore, draw the sensor size, field of view, optical axis position, and available working clearance together.
How is depth of field verified in actual production?
A part's nominal surface may appear sharp while an edge a few millimeters above it is out of focus. Catalog depth of field depends on the definition of sharpness used and on magnification. Rather than imaging a part only at its nominal height, you must also take measurements at the permitted nearest and farthest positions.
A simple but effective test is to move the part height to the lower and upper limits of its mechanical tolerance, image the same target at each position, and record edge sharpness and defect visibility in the relevant regions. Even if focus at the center is good, field curvature can produce different results at the image edges. Changing the aperture may help, but reduced light, increased exposure, and diffraction reenter the equation.
When should a telecentric lens be used?
With a normal lens, an object closer to the camera appears larger in the image. If the part's height in front of the camera changes by a few millimeters, this effect can become a measurement error. Object-space telecentric lenses are designed to substantially reduce this magnification change within a specified working range. They are particularly advantageous for precision dimensional inspection. [6]
However, a telecentric lens may be more expensive, bulkier, and more restrictive in field of view. Not every surface defect project needs one. The right question is: Does variation in the part's position produce an unacceptably large measurement error?
How do you check sensor, image circle, and mount compatibility?
The lens must produce an image circle large enough to cover the entire sensor. Otherwise, dark corners, loss of sharpness, or unacceptable distortion may occur. Optical format descriptions such as 'suitable for a 2/3-inch sensor' are not numerically identical to the actual physical diagonal dimension; the active imaging area and supported format in the sensor and lens data sheets must be checked together.
Mount compatibility is not just a matter of matching threads. With connections such as C-mount/CS-mount, flange distance, back focus, and adapter requirements matter. Enclosure glass, filter thickness, extension rings, and mechanical locking in vibrating environments can affect image quality. Especially with a high-resolution sensor, test that the lens provides sufficient MTF at the corners as well as at the center.
Details that complicate lens selection
In the field, issues not covered in the catalog are often decisive. Is the part's highest point sharp in the frame? Is there protective glass in front of the lens? Does the enclosure or robot arm obstruct the view? Does mechanical vibration shift focus? Is the required resolution achieved across the entire field? Is the lens's focus stability sufficient under the environmental conditions?
When these issues are discovered later, a more powerful AI model is usually not an adequate solution. The problem is in the image itself, not in classification.
How should a focal length calculation be interpreted?
We first need to know the sensor's physical width and the desired field of view. For example, a sensor 2,448 pixels wide with a 3.45 µm pixel pitch has a horizontal width of 8.4456 mm. For a field of view of 160 mm, the required magnification is approximately 8,4456 / 160 = 0,0528. The thin-lens approximation can establish an approximate relationship between working distance and magnification; however, it does not give an exact result, especially for close-ups and real multielement lenses.
Magnification m ≈ 0.0528. Assuming an object-to-lens distance of 350 mm in the thin-lens model gives an approximate focal length of f ≈ m·u/(1+m) = 17.5 mm. Options in the 16 mm or 18 mm class can be tested in practice. Here, u is measured from the lens's appropriate reference plane; it may not be identical to the mechanical distance measured from the lens's front glass. Verification against the lens manufacturer's FOV/WD table is essential.
Why should MTF not be considered independently of pixel count?
MTF (Modulation Transfer Function) indicates how well a lens preserves contrast at different spatial frequencies. A smaller pixel pitch allows higher-frequency detail to be sampled, but if the lens cannot transfer that detail's contrast to the sensor, the practical benefit of theoretical resolution remains limited. A sensor with a 3.45 µm pixel pitch has a Nyquist frequency at the sensor plane of approximately 145 lp/mm. The lens's MTF curve for the relevant image region should be checked up to this range; a nominal MTF value at a single point is not sufficient.
Why does stopping down not always make the image sharper?
Stopping down the aperture can increase depth of field and reduce some optical aberrations. However, it reduces the amount of light, and diffraction becomes stronger at very small apertures. A higher f-number should therefore not automatically be interpreted as greater sharpness. Repeating the test at the part's nearest and farthest permitted positions, for both the image center and corners, is more reliable.
What checks are needed for a lens acceptance test?
The lens must illuminate the sensor, and its image circle must cover the entire sensor. The mounting connection must be suitable; evaluate the lens's back focal distance, mechanical clearance inside the enclosure, polarization/filter holder, and focus shift under vibration. Check corner-to-center sharpness and distortion using a calibration target; where possible, base acceptance on images of actual defects.
How to read a lens's image quality graphs
Manufacturers publish MTF curves for some lenses at different apertures, fields of view, and wavelengths. In such graphs, high performance at the center alone is not enough; if the part approaches the image edge, performance in that field region also matters. Comparing the same lens at different apertures makes the balance between sharpness and depth of field tangible.
Practical selection sequence: First match the field of view to the sensor size, then check the required working distance, image circle, and mounting constraints. Next, test on real samples that the lens transfers the smallest detail with sufficient contrast. Keeping lighting conditions constant during these steps makes the comparison more meaningful.
Frequently asked questions
What happens as lens focal length increases?
With the same sensor and working distance, the field of view usually becomes narrower; the actual relationship depends on the lens design.
Is MTF necessary for lens selection?
For fine defects or precision measurement, how well the lens preserves contrast at the relevant spatial frequency can be critical.
When is a telecentric lens advantageous?
It can offer an advantage when the aim is to reduce the effect of small changes in part height on image magnification and measurement.
Technical references
The text contains explanations supported by technical references and numerical examples for teaching purposes. The system values in the examples are not measurement results from an actual facility.