How Much Depth of Field Do I Need in Machine Vision? A Practical Lens Guide for Parts With Height Variation
Selecting a machine vision lens becomes considerably more difficult when the object being inspected is not always at exactly the same distance from the camera. A flat label fixed on a rigid fixture may remain close to one focus plane, but real industrial components rarely behave so conveniently. Cast parts vary in height, packages arrive with different thicknesses, connectors stand above printed circuit boards, molded components contain steps and ribs, trays position products at slightly different elevations, and conveyor systems introduce mechanical movement along the optical axis. When these variations occur, the practical question is no longer simply whether the lens can focus on the object. The more important question is whether every feature that matters to the inspection remains sufficiently sharp throughout the complete expected height range.
That requirement is called depth of field, commonly abbreviated as DOF. For buyers searching for a machine vision lens with high depth of field, industrial camera lens for parts with height variation, C-mount lens for uneven objects, machine vision lens for different object heights, lens for inspection with Z-axis variation, or best machine vision lens for three-dimensional parts, depth of field is one of the most important specifications to understand before finalising the optical design. It can determine whether an inspection works only on carefully positioned samples or continues to produce stable results after the system is installed on a production line.
Kyptec Automation® provides a specialised Machine Vision Lens portfolio covering multiple focal lengths, sensor formats and resolution levels. This gives OEMs, system integrators and machine builders the ability to choose a lens around the actual imaging geometry rather than treating depth of field as an isolated adjustment. The right lens is ultimately the one that maintains sufficient usable detail throughout the real production height tolerance while still delivering the field of view, working distance and resolution required by the inspection.
What Does Depth of Field Mean in Machine Vision?
Depth of field is the range of object distances over which an image remains sufficiently focused for the intended inspection. The word “sufficiently” is important because focus is not an absolute boundary. There is no physical line in space where an image suddenly changes from perfectly sharp to completely blurred. Instead, image detail gradually becomes softer as the object moves away from the best-focus plane.
For machine vision, acceptable depth of field should therefore be defined according to the inspection task rather than according to whether the image still looks reasonably clear to a human observer. A barcode reader may tolerate a degree of softness while continuing to decode reliably. A presence-check application may tolerate even more. A dimensional measurement algorithm looking for a narrow edge, however, may require considerably higher contrast. A small surface-defect inspection may become unreliable with only a modest change in focus.
This leads to one of the most useful principles in machine vision lens selection: required depth of field is not simply the physical height of the object; it is the range of object positions over which the critical inspection feature remains reliably detectable or measurable.
A component might be 30 mm tall, but if every inspected feature lies on a top surface that changes by only ±1 mm, the relevant depth-of-field requirement may be much smaller than 30 mm. Conversely, a component only 8 mm thick may require nearly its entire height to remain sharp if the vision system must inspect features at both its highest and lowest surfaces.
Start With Z-Height Variation, Not With the Lens
A common mistake is to start lens selection by asking which model has the “largest depth of field.” That question places the optical solution before the production requirement has been defined. The better starting point is to quantify how far the critical feature can move toward and away from the camera.
Suppose the nominal working distance is 300 mm. Production samples show that the relevant inspection surface may appear at 297 mm in one part and 304 mm in another. The vision system therefore needs to accommodate a 7 mm object-distance range. This does not automatically mean the optical depth of field must be exactly 7 mm, because the selected focus position and acceptable blur criterion also matter, but it provides the engineering requirement around which the lens setup can be developed.
This simple measurement is frequently overlooked. Engineers sometimes specify only the nominal working distance while the actual machine introduces fixture tolerance, conveyor movement, product thickness variation and assembly tolerance. The result is a lens that produces an excellent commissioning image but unstable production images.
Before comparing machine vision lenses, record the nearest expected position of the critical feature, the farthest expected position and the nominal position used during setup. These three values provide a practical depth-of-field budget.
Why Nominal Working Distance Alone Is Not Enough
Working distance normally describes the distance between the lens system and the object at a chosen operating position. It is essential for field-of-view calculations and mechanical integration, but it does not describe the complete range of positions the object may occupy.
A system designed for 250 mm nominal working distance may actually operate between 247 mm and 255 mm because of component height tolerance. Another installation may nominally operate at 500 mm but hold the object within less than 1 mm of variation because of a rigid fixture. The first system may therefore demand greater depth-of-field tolerance despite operating at the shorter nominal distance.
When requesting or purchasing a machine vision lens for variable working distance, buyers should specify both nominal working distance and the expected Z variation. This gives a much more useful description than providing only the camera-to-object distance.
For Kyptec Automation® lens selection, this application-based approach is especially valuable because the Machine Vision Lens portfolio contains several focal lengths and resolution classes. A buyer can therefore evaluate field of view, working distance, sensor format and depth requirement together rather than forcing a predetermined lens into an unsuitable geometry.
How Much Depth of Field Do You Actually Need?
The most practical rule is to design for the complete expected production height range plus a reasonable engineering margin, while avoiding excessive depth-of-field requirements that compromise other parts of the optical system.
If the critical surface normally varies by ±2 mm, designing a system that works only across exactly 4 mm leaves very little allowance for fixture drift, installation tolerance or future production variation. On the other hand, demanding 40 mm of depth of field for a process that realistically changes by only 4 mm may force unnecessary optical compromises.
The requirement should therefore come from measured production data. Inspect representative parts from the lower and upper ends of dimensional tolerance. Measure fixture repeatability. Consider conveyor runout where applicable. Identify whether different product variants will use the same camera station. Determine whether operators can alter the part position during loading. These factors collectively define the real Z envelope.
Once that envelope is known, the lens and imaging geometry can be designed to keep the critical features usable throughout it.
Depth of Field Is Not Usually Symmetrical Around the Focus Plane
Another useful point for system designers is that the usable focus region should not automatically be assumed to extend equally in front of and behind the nominal focus position. The distribution changes with optical geometry and magnification.
This matters when choosing where to focus during commissioning. Simply focusing on the centre of the physical part height may not produce the most useful tolerance at both extremes. The correct focus plane should be established experimentally or through optical calculation so that the nearest and farthest critical positions both remain within the required image-quality threshold.
For example, if the inspection surface can travel between two known Z positions, engineers should capture representative targets at both extremes and adjust the nominal focus position until adequate feature quality is achieved across the complete range. This is more reliable than setting focus using only a nominal sample.
Magnification Has a Major Effect on Depth of Field
Magnification is one of the strongest factors influencing usable depth of field. As magnification increases, depth of field generally becomes more limited. This is why close inspection of small features frequently has less tolerance to object-height variation than a lower-magnification inspection covering a larger area.
Consider two applications. One camera observes a relatively large component across a broad field of view. Another camera magnifies a tiny feature so that it occupies a substantial number of pixels. The second system may provide excellent detail, but the focus region can become considerably narrower. Even a small Z shift may noticeably soften the feature.
This trade-off is particularly important when specifying a machine vision lens for small parts with height variation. Buyers often want both very high magnification and very large depth of field. Those requirements can oppose each other. The solution may involve adjusting working distance, field of view, focal length, aperture and mechanical positioning rather than searching for a lens that somehow eliminates the relationship.
The correct objective is therefore not “maximum magnification and maximum depth of field.” It is enough magnification to resolve the smallest required feature while retaining enough depth of field for the actual Z tolerance.
Why Field of View Changes the Depth-of-Field Problem
Field of view determines how much of the object appears in the image. When a smaller field of view is required on the same sensor, magnification increases. As magnification rises, focus tolerance generally becomes more demanding.
This means depth of field should be considered at the same time as field of view rather than after the lens has already been selected. If a buyer specifies an unnecessarily tight field of view because they want the part to fill almost the entire sensor, they may create a depth-of-field problem that could have been avoided with slightly lower magnification.
The correct field of view should provide enough pixels across the smallest important feature while leaving sensible framing tolerance. Once that requirement is established, an appropriate focal length and working distance can be selected and the achievable depth of field evaluated.
The Kyptec Automation® Machine Vision Lens range includes focal lengths from short wide-field options through longer focal-length models, allowing the optical geometry to be chosen around different inspection envelopes rather than relying on a single focal length for every installation. The current collection contains multiple 5 MP, 10 MP and 25 MP lens families intended for industrial imaging.
Focal Length Does Not Tell You Depth of Field by Itself
Searches such as “does a 16 mm machine vision lens have more depth of field than a 35 mm lens?” are common, but focal length alone does not provide a reliable answer. Depth of field is affected by the complete optical configuration, including magnification, aperture, focus distance, sensor format and acceptable blur.
A 16 mm lens and a 35 mm lens used from different working distances to obtain the same field of view may produce less dramatic depth-of-field differences than a simple focal-length comparison suggests. For this reason, engineers should not select a shorter focal length purely because they believe it automatically guarantees high depth of field.
Focal length should first solve the required field of view at a mechanically suitable working distance. Depth of field should then be evaluated within that configuration.
For example, the Kyptec Automation® KL-1238 16 MM 25 MegaPixel 1.1" Machine Vision Lens is a high-resolution C-mount option with a published F2.8–16 range, while the Kyptec Automation® KL-1242 35 MM 25 MegaPixel 1.1" Machine Vision Lens provides a longer 35 mm focal length with the same published resolution class and F2.8–16 aperture range. These models give system designers different geometrical options, but the depth of field obtained in a real installation will depend on how each lens is used rather than focal length alone.
The Relationship Between Aperture and Depth of Field
Aperture remains an important control because increasing the F number generally increases depth of field. However, for a depth-of-field-specific lens selection problem, aperture should be regarded as one tool within the broader optical design rather than as the entire solution.
If a system does not have enough depth of field, stopping the aperture down can improve focus tolerance. But reducing the aperture opening also reduces light reaching the camera and can eventually increase diffraction-related loss of fine image detail. The previous aperture-focused design question therefore becomes part of a larger system decision: how much stopping down is actually needed to cover the measured Z-height range?
A sensible machine vision setup uses only as much depth of field as the application requires. If the required object variation is already covered at a moderate aperture, further stopping down provides little practical benefit.
The Kyptec Automation® KL-1208 25 MM 5 MegaPixel 2/3" Machine Vision Lens, for example, is specified with a C-mount, 25 mm focal length and F1.4–16 adjustment range. That flexibility allows the lens to be tuned after the system geometry has been established, rather than forcing the designer to work with one aperture condition.
Working Distance Can Be Used as a Design Tool
Increasing working distance can sometimes help reduce magnification for a given configuration or allow a different focal-length choice, potentially making the depth-of-field requirement easier to manage. However, this must be balanced against mechanical space, required field of view, lens resolution and the number of pixels available across the inspection feature.
A common design mistake is to place the camera extremely close simply because space is available, only to discover that the resulting high magnification makes Z tolerance difficult. In other installations, the camera is placed too far away, forcing a longer focal length and creating unnecessary mechanical sensitivity.
The most effective working distance is therefore not always the shortest or longest possible distance. It is the distance that creates a practical combination of field of view, magnification, focus tolerance and machine integration.
When selecting a machine vision lens for objects with height variation, testing two or three possible working-distance configurations can be more productive than trying to optimise aperture after the mechanical design has already been fixed.
Sensor Size Also Changes the Optical Geometry
Sensor format influences the field of view produced by a given focal length and working distance. A larger sensor sees a larger field through the same lens geometry, while a smaller sensor captures a narrower portion of the image circle.
Because field of view and magnification influence depth of field, sensor size indirectly becomes part of the DOF design process. This is why a lens cannot be selected solely from focal length or F number. It must correctly support the camera sensor and required image circle while meeting the desired field of view.
Kyptec Automation® offers Machine Vision Lens options for multiple image formats, enabling buyers to match the lens to their industrial camera rather than attempting to compensate for a sensor mismatch through working distance changes. The Kyptec Automation® KL-1230 35 MM 10 MegaPixel 2/3" Machine Vision Lens, for example, is specified for a 2/3" image format with C-mount, 10 MP resolution and F2.8–16.
Depth of Field for Parts With Steps, Shoulders and Multiple Surfaces
A stepped machined component illustrates the practical difference between object height and inspection depth. Imagine that the vision system needs to inspect a hole on the upper surface and an edge on a recessed surface several millimetres below it. Both features must be sufficiently sharp in the same image.
The required depth of field must therefore cover the difference between those two feature planes, plus any additional production variation in their absolute position. If the part itself can move another ±1 mm within the fixture, the required focus range is greater than the nominal step height.
This approach is useful for machined parts, castings, stamped components and molded parts because it converts a vague request for “high depth of field” into an actual dimensional requirement.
Before purchasing a lens, identify the highest critical feature, the lowest critical feature and the positional tolerance of the complete part. Those values provide a far stronger basis for lens selection than the overall component dimensions.
Depth of Field for PCB and Electronic Component Inspection
Electronics inspection often contains multiple Z planes within a single field. The board surface lies at one level, small passive components at another, integrated circuits may be higher, and connectors or taller components may extend significantly above the PCB.
If the machine vision system must inspect features across several of these planes in one exposure, depth of field becomes a primary optical requirement. However, electronics inspection can also require very fine spatial detail, so simply closing the aperture as far as possible is not a desirable strategy.
A better approach is to identify which heights actually contain features required by the algorithm. If the inspection only verifies component presence on the top surfaces, the relevant depth range may be smaller than the complete component-height range. If solder joints, leads and top markings must all be evaluated simultaneously, the requirement becomes larger.
For high-resolution applications of this type, a model such as the Kyptec Automation® KL-1242 35 MM 25 MegaPixel 1.1" Machine Vision Lens provides a 25 MP optical platform that can be integrated into a system where both detail and height tolerance are considered during setup. The product page specifies a 35 mm focal length, C-mount and F2.8–16 aperture range.
Depth of Field for Packaging With Variable Product Height
Packaging applications frequently experience larger Z variation than precision-machined fixtures. Boxes may differ slightly in height, flexible packaging may bulge, bottles can move vertically, labels may not lie perfectly flat, and products may bounce or shift while travelling on a conveyor.
For barcode reading, label verification, print inspection or seal inspection, the system should be designed around the full expected package-height range. A camera that is perfectly focused on the average package may become unreliable when the tallest and shortest products arrive.
The optical design should begin with the minimum and maximum distance from the lens to the inspected surface. The camera should then be positioned so that a practical focal length and magnification cover the required field while providing enough focus tolerance.
If different package sizes will share the same inspection station, buyers should include all intended formats before choosing the lens. A lens selected around only one SKU can become inadequate when a taller or shorter package is introduced later.
Depth of Field for Robot Pick-and-Place Targets
Robot guidance creates another type of Z-height problem. Parts may arrive at slightly different heights because they are stacked, randomly oriented, resting on variable surfaces or positioned within containers.
For a two-dimensional vision system, sufficient depth of field helps maintain feature clarity when a target shifts moderately toward or away from the camera. However, depth of field does not convert a 2D optical system into a true 3D measurement system. It simply increases the range over which the target remains acceptably focused.
This distinction is important. If the robot must accurately determine substantial three-dimensional height information, additional sensing methodology may be required. If the primary requirement is stable X-Y localisation despite modest Z variation, optimising machine vision lens depth of field can substantially improve robustness.
The lens should therefore be chosen according to the permitted height variation of the localisation feature, not simply according to the total physical height of the part.
Depth of Field for Barcode, OCR and Label Reading
Machine-readable information often appears on products whose surface position is not tightly controlled. Labels on cartons, codes printed on containers and text on molded components may move through several millimetres of Z variation.
The depth-of-field requirement should be evaluated using the smallest code module or narrowest character stroke expected in production. A larger code may continue to decode even when slightly defocused, while small text may lose reliable edge contrast much earlier.
This means one optical configuration can appear satisfactory during testing with a large reference barcode but fail when smaller production markings are introduced. Qualification should therefore use the most demanding code or text size within the product range.
The best machine vision lens for barcode or OCR applications with variable height is not necessarily the lens with the shortest focal length or smallest aperture. It is the lens configuration that keeps the required code detail readable across the complete object-distance range while providing an acceptable field of view and working distance.
Depth of Field for Dimensional Inspection
Measurement applications require a stricter definition of acceptable focus than many pass/fail inspections. The software may need to determine an edge location with sub-pixel precision. As the object moves away from best focus, that edge spreads across more pixels and the detected position may become less stable.
A system may therefore appear visually sharp over 10 mm of depth but provide measurement-grade performance over only part of that range. This is why depth of field should be qualified according to the actual algorithm and tolerance rather than by looking at an image on a monitor.
When setting up dimensional inspection, measure the same reference feature at several known Z positions within the expected production range. If the reported dimension changes as the object moves, the acceptable depth-of-field region should be narrowed until measurement stability satisfies the required tolerance.
For applications requiring high-resolution edge information, Kyptec Automation® 10 MP and 25 MP Machine Vision Lens families provide multiple focal-length options that can be evaluated against the required sensor format, field of view and measurement geometry. The current portfolio includes 8 mm, 12 mm, 16 mm, 25 mm, 35 mm and 50 mm options across its higher-resolution ranges.
Depth of Field for Surface Defect Inspection
Surface inspection presents a different challenge because the smallest defect can determine the acceptable focus threshold. A tiny scratch, pit, crack or contamination mark may lose contrast before the entire object appears visibly blurred.
If the inspected surface is curved, warped or mechanically variable, the system must maintain enough depth of field to keep the smallest defect detectable across that shape. The required DOF should therefore be validated with actual defect samples placed at the closest and farthest expected object positions.
This is particularly important for dark, low-contrast or texture-dependent defects. A feature that is obvious at perfect focus may disappear quickly as the surface moves outside the optimum plane.
The depth-of-field requirement for defect inspection should thus be specified using the minimum detectable defect at the worst expected Z position, not merely the overall appearance of a good sample.
What If the Required Depth of Field Is Too Large?
Sometimes the initial requirement is simply unrealistic for the chosen field of view, magnification and resolution. In this situation, continually stopping down the lens is rarely the best answer.
The first step is to determine whether every part of the requested depth range genuinely needs inspection. Reducing the required Z envelope can substantially simplify the optics. Mechanical fixturing may also be improved so that the component is presented more consistently. Working distance and focal length can be reconsidered. The field of view may be expanded slightly to reduce magnification if sufficient pixel resolution remains. The focus plane can be repositioned so that the available depth is distributed more effectively across the important features.
In some systems, separating inspections performed at significantly different height planes may be more reliable than demanding one optical configuration that resolves everything simultaneously.
A useful lens-selection process therefore treats an excessive depth-of-field requirement as a system-design issue rather than automatically assuming a different lens will solve it.
Why Higher Resolution Does Not Automatically Solve Focus Variation
A higher-megapixel camera and lens can provide greater spatial sampling, but additional pixels do not compensate for an object that has moved too far out of focus. If optical detail is blurred before reaching the sensor, the camera cannot recreate information that was not formed clearly by the lens.
In fact, a high-resolution system may make focus tolerance more noticeable because the inspection relies on finer image structure. The acceptable depth of field can therefore become more demanding as the smallest feature requirement becomes smaller.
This is why buyers should not assume that moving from 5 MP to 25 MP automatically increases inspection tolerance. Higher optical resolution is useful when more detail is required, but the depth-of-field requirement still has to be solved through appropriate imaging geometry, focus and aperture.
The Kyptec Automation® portfolio provides several resolution classes so that buyers can select the level of optical detail appropriate for the inspection rather than choosing megapixel rating in isolation. For example, the Kyptec Automation® KL-1208 25 MM 5 MegaPixel 2/3" Machine Vision Lens and Kyptec Automation® KL-1238 16 MM 25 MegaPixel 1.1" Machine Vision Lens serve different resolution and format requirements and should be evaluated within their intended imaging systems.
Why Longer Focal Lengths Can Still Be Useful in Variable-Height Applications
A longer focal length should not automatically be rejected because a system requires depth of field. Longer focal lengths can be useful when the camera must be positioned farther from the object, when mechanical clearance is required, or when a narrower field of view must be obtained from a greater distance.
The relevant question is whether the resulting magnification and aperture can provide adequate focus tolerance for the actual Z variation.
For installations requiring substantial camera-to-object distance, Kyptec Automation® also lists the Kyptec Automation® KL-1302 75 MM 1.5 MegaPixel 2/3" Machine Vision Lens, a C-mount 75 mm option in the Machine Vision Lens category. Its role is different from higher-resolution shorter focal-length products, illustrating why focal length should be selected around working geometry rather than according to a simple rule that shorter is always better for depth of field.
How to Test Depth of Field Before Finalising a Lens
The most dependable test uses the actual camera, candidate machine vision lens, intended working distance, production lighting and representative inspection feature. Focus the system at the planned nominal plane and establish the required field of view.
Then move the inspection target progressively toward and away from the lens while recording the Z position. At each position, evaluate the actual algorithm rather than only visual sharpness. For barcode inspection, measure decoding reliability. For OCR, measure recognition stability. For dimensional inspection, compare measured values. For defect detection, determine whether the smallest accepted defect remains consistently detected.
The nearest and farthest positions that satisfy the required performance define the usable application depth of field. This is more meaningful than an abstract optical number because it incorporates the lens, camera, illumination, algorithm and actual inspection target.
The test should also be repeated at expected production extremes such as low-contrast parts, smallest features or worst-case surface conditions. If the system performs reliably only on ideal samples, the qualified depth-of-field range is overly optimistic.
Allow Margin for Production, Not Just Laboratory Samples
A machine vision system should not be designed so that the tallest and shortest permissible parts sit exactly at the edge of acceptable focus. Real machines change. Fixtures wear, camera mounts experience small shifts, products vary, and maintenance operations can introduce alignment differences.
A reasonable optical margin helps prevent these normal variations from immediately producing false rejects. The amount of margin depends on the application tolerance and mechanical stability, but the principle is universal: qualify beyond the nominal requirement whenever possible.
For example, if production data indicates a 6 mm expected Z range, test slightly beyond those extremes. If inspection performance collapses immediately outside the 6 mm interval, the setup may be too sensitive for comfortable production operation.
A good machine vision lens selection is therefore not only capable of working on the specified range; it gives the system enough optical robustness to tolerate realistic operating conditions.
When Mechanical Control Is Better Than More Depth of Field
Optics cannot compensate indefinitely for poor mechanical repeatability. If part height varies far more than the inspection actually requires, improving the fixture may produce a better result than trying to create enormous optical depth of field.
This is particularly relevant for high-magnification measurement and tiny-defect applications. A few millimetres of uncontrolled Z movement can make the optical design much more difficult. Reducing that movement mechanically may allow the system to operate at a more favourable magnification and aperture while preserving higher image detail.
Lens selection and mechanical design should therefore be coordinated. The least expensive optical solution can become unreliable if the fixture is unstable, while an excessively complex optical solution may be unnecessary if the part can be positioned more consistently.
The objective is not to demand maximum depth of field from the lens. The objective is to create the most stable total inspection system.
Choosing a Kyptec Automation® Machine Vision Lens for Height Variation
When evaluating a Kyptec Automation® Machine Vision Lens for an application involving variable object height, begin with the camera sensor format and required field of view. Determine the nominal working distance permitted by the machine. Calculate or estimate the resulting magnification, then specify the nearest and farthest positions of the critical inspection features.
Next, establish how much image detail the algorithm requires at those positions. A presence check, OCR inspection, dimensional measurement and micro-defect inspection will not share the same acceptable focus criterion. Once that requirement is known, the aperture can be adjusted to obtain the required focus range without unnecessarily compromising available light or fine detail.
Kyptec Automation® is particularly useful for this selection approach because its Machine Vision Lens category contains multiple focal lengths within several resolution families. An OEM or integrator can therefore compare a 16 mm, 25 mm or 35 mm option, for example, within a broader optical design instead of treating one focal length as a universal solution. Relevant products such as the Kyptec Automation® KL-1208 25 MM 5 MegaPixel 2/3" Machine Vision Lens, Kyptec Automation® KL-1230 35 MM 10 MegaPixel 2/3" Machine Vision Lens, Kyptec Automation® KL-1238 16 MM 25 MegaPixel 1.1" Machine Vision Lens and Kyptec Automation® KL-1242 35 MM 25 MegaPixel 1.1" Machine Vision Lens provide different combinations of focal length, format and optical resolution for industrial imaging requirements.
Frequently Asked Questions About Machine Vision Depth of Field
1. How do I calculate how much depth of field my machine vision system needs?
Start with the mechanical requirement rather than an optical formula. Identify the closest possible position of the feature being inspected and the farthest possible position under normal production conditions. Include product tolerance, fixture repeatability, conveyor movement and any difference between product variants. The distance between those extremes is the minimum Z range the optical system must tolerate. Then add a sensible operating margin and verify the result experimentally using the actual inspection algorithm. This approach is more useful than selecting a generic “high depth of field” lens because it connects the optical requirement directly to the production process. Kyptec Automation® offers multiple Machine Vision Lens focal lengths and resolution families, making it possible to build the optical geometry around this measured requirement rather than trying to force one lens into every depth range.
2. If my part height varies by 10 mm, do I need exactly 10 mm depth of field?
Not necessarily. What matters is the movement of the critical inspection feature, not always the total physical height of the part. A component may vary by 10 mm overall while the inspected surface changes position by only 3 mm. In another application, different inspected features may lie on surfaces separated by the entire 10 mm, meaning substantially more of the object must remain usable. The correct specification should therefore combine feature-height separation with whole-part positional variation. Once those values are known, test the system at the nearest and farthest required planes and include additional focus margin rather than designing exactly to the theoretical boundary.
3. What is the best machine vision lens for parts with different heights?
There is no universal focal length or model that is automatically best for all parts with different heights. The suitable machine vision lens depends on sensor size, field of view, working distance, required resolution, magnification and the amount of Z variation. A 16 mm lens may be appropriate for one wide-field installation, while a 35 mm lens may be preferable where the camera must be positioned farther away. The Kyptec Automation® Machine Vision Lens range provides several focal lengths across 5 MP, 10 MP and 25 MP families, allowing the lens to be selected from the full application geometry rather than simply choosing the shortest available focal length.
4. How can I increase depth of field without changing the machine vision lens?
The first option is normally to reduce the aperture opening by using a higher F number, provided sufficient illumination and image resolution remain available. However, aperture is not the only way to improve focus tolerance. Reducing magnification, slightly increasing the field of view, reconsidering working distance or improving mechanical control of the object position can also make the application more robust. If the existing system is operating near its optical limits, improving fixture repeatability can sometimes produce a greater practical benefit than stopping the lens down further. The best solution depends on whether the current limitation comes from insufficient focus range, insufficient light, excessive magnification or uncontrolled part movement.
5. Why is my machine vision image sharp for one part height but blurry for another?
The most likely optical explanation is that the second object position lies outside the system's usable depth of field. The lens is focused for a particular object plane, and image sharpness gradually decreases as the object moves away from it. If production parts vary in height, a system with narrow focus tolerance may therefore produce sharp images for some parts and softer images for others. Measure the Z positions of both samples and compare the difference. If the variation is expected in normal production, the optical setup should be adjusted through aperture, magnification, working distance, focus position or lens selection so that both positions remain within the qualified inspection range.
6. Does a shorter focal length always give more depth of field in machine vision?
No. Focal length cannot be evaluated independently because working distance and magnification usually change when a different focal length is installed. If two lenses are positioned differently to produce the same field of view, the resulting depth-of-field relationship is more complicated than simply saying the shorter lens will always be better. Buyers should first choose a focal length that produces the required field of view at a practical working distance and then evaluate depth of field in that exact configuration. The Kyptec Automation® KL-1238 16 MM 25 MegaPixel 1.1" Machine Vision Lens and Kyptec Automation® KL-1242 35 MM 25 MegaPixel 1.1" Machine Vision Lens illustrate two different focal-length choices within the same high-resolution family, but their actual DOF must be assessed according to how each is integrated into the system.
7. Does increasing working distance improve machine vision depth of field?
It can in some configurations because working distance changes magnification and the required focal-length geometry, but increasing distance should not be treated as an automatic depth-of-field solution. Moving the camera changes field of view, object magnification, required focal length and the number of pixels covering the inspection feature. A longer working distance that improves focus tolerance may simultaneously reduce available feature detail unless the focal length is changed appropriately. The correct approach is to compare candidate geometries while keeping the required field of view and pixel resolution in mind.
8. How much extra depth-of-field margin should I allow for production?
There is no fixed percentage suitable for every machine. Margin should reflect the stability of the mechanical system and confidence in the measured production tolerance. A rigid fixture with tightly controlled component dimensions may need less margin than a moving conveyor carrying flexible packages. The practical method is to determine the expected minimum and maximum Z positions and then validate the inspection slightly beyond both limits. If reliable performance disappears immediately outside the nominal production range, the system has little tolerance for future fixture drift or alignment change. A robust design should maintain acceptable inspection performance across the expected range with reasonable additional headroom.
9. Can a high-megapixel lens give me more depth of field?
Higher optical resolution does not inherently create more depth of field. A 25 MP lens is designed to support finer spatial detail than a lower-resolution lens when used with an appropriate sensor, but focus tolerance is still governed by magnification, aperture, working distance and acceptable blur. In fact, high-resolution inspections can have stricter focus requirements because the algorithm depends on smaller image structures. Kyptec Automation® offers 25 MP options such as the Kyptec Automation® KL-1238 16 MM and Kyptec Automation® KL-1242 35 MM Machine Vision Lenses, but these should be selected when the application requires the corresponding optical detail and format, not simply as a method of increasing depth of field.
10. How do I test depth of field on a production line?
Use a representative inspection target and move it through known Z positions while keeping the camera and lens fixed. Record where the actual inspection remains reliable. For OCR, evaluate recognition accuracy; for barcode reading, track decode rate; for dimensional inspection, compare measured values; and for defect inspection, verify detection of the smallest required defect. The usable depth-of-field range is the region where the application continues to meet its performance requirement. Testing only visual sharpness is insufficient because different algorithms tolerate different levels of defocus. Production validation should also include challenging samples rather than only ideal reference pieces.
11. Can I focus halfway between the highest and lowest surface?
Sometimes, but the physical midpoint should not automatically be assumed to be the optimum focus position. Usable depth of field is not necessarily distributed equally on both sides of the focus plane, particularly as magnification changes. A better approach is to place representative inspection features at the nearest and farthest required positions, adjust focus, and determine the setting that gives acceptable feature quality at both extremes. In measurement applications, compare numerical measurement stability rather than simply visual appearance. The optimum focus position is the one that maximises usable inspection performance throughout the required Z envelope.
12. What happens if my required depth of field is larger than the lens can provide?
The optical system should be redesigned rather than continually trying to force more depth of field from the existing configuration. Possible changes include reducing magnification, expanding the field of view slightly, changing working distance, selecting another focal length, improving object positioning or dividing the inspection into different height regions. Aperture may also provide additional focus range, but very small apertures can create illumination and diffraction trade-offs. If the Z variation is caused mainly by poor mechanical repeatability, improving the fixture is often the more effective solution. Kyptec Automation® offers multiple Machine Vision Lens focal lengths, allowing system integrators to compare alternative geometries when the first configuration does not provide sufficient production tolerance.
13. Is depth of field more important for measurement or defect detection?
It is important for both, but the acceptable focus criterion can be different. Measurement depends on stable edge localisation, so even moderate defocus may change the calculated position of an edge before the image looks obviously blurred. Small-defect inspection can be equally demanding because tiny scratches, pits or contamination marks may lose contrast as they move away from best focus. In either case, depth of field should be qualified using the actual feature and algorithm. A lens should not be considered suitable simply because the overall object remains recognisable throughout the Z range.
14. How does part curvature affect machine vision depth of field?
A curved surface naturally places different areas of the same object at different distances from the lens. The required depth of field must therefore cover the difference between the nearest and farthest critical regions of that surface, plus any movement of the complete part within the fixture. If the inspection targets only a small central area, the requirement may be modest. If the camera must inspect detail across a strongly curved object, a substantially larger focus range may be necessary. Before choosing a machine vision lens, map the actual height difference across the inspected region rather than relying only on the overall part dimensions.
15. What information should I provide when asking for a machine vision lens for height variation?
Provide the camera sensor format, required field of view, nominal working distance, nearest and farthest expected feature positions, smallest feature to be inspected, required measurement or defect tolerance and any mechanical restrictions on camera placement. Also explain whether multiple height planes must appear sharp in the same image or whether the entire part simply shifts toward and away from the camera. These details allow a lens to be selected around the real optical problem. Kyptec Automation® provides multiple Machine Vision Lens models across different focal lengths and resolution classes, which is particularly useful when an OEM or integrator needs to compare alternative geometries rather than simply purchase a lens by focal length.
16. Why does my depth of field become smaller when I zoom in on a smaller feature?
When the optical system is configured to make a smaller feature occupy more of the sensor, magnification increases. Higher magnification generally reduces the range of object positions that remain acceptably focused. This creates a common machine vision trade-off: the system needs enough magnification to resolve the defect or edge but also enough depth of field to tolerate part-height variation. Instead of maximising magnification, determine how many pixels the feature actually requires for reliable inspection. Using only the necessary magnification can preserve valuable focus tolerance and simplify the lens setup.
17. Should I choose a 5 MP, 10 MP or 25 MP machine vision lens for an object with height variation?
Resolution class should be selected from the smallest feature and camera resolution requirement rather than from height variation alone. If a 5 MP optical system provides enough pixels across the feature, a higher-resolution lens is not automatically necessary for depth of field. If very small defects or precise edges must be resolved, 10 MP or 25 MP optics may be appropriate, but the increased detail requirement must still be maintained throughout the required Z range. Kyptec Automation® provides 5 MP, 10 MP and 25 MP Machine Vision Lens families, allowing buyers to match optical resolution to the actual inspection requirement while independently designing for depth of field.
18. Can one machine vision lens inspect several product heights on the same line?
Yes, provided the complete range of inspected surfaces remains within the usable optical depth of field and the field of view remains suitable for every product. The important step is to qualify the tallest and shortest products rather than assuming the average configuration will cover everything. If the products vary substantially in height, a compromise optical setup may reduce image quality for all variants. In that situation, changing camera position, improving product presentation or using separate configurations can be more reliable. When a shared station is practical, selecting from several Kyptec Automation® Machine Vision Lens focal lengths gives the integrator more flexibility to create a geometry that accommodates the complete product family.
Final Perspective: Design Depth of Field Around Real Production Variation
The question “How much depth of field do I need?” should ultimately be answered with a production tolerance, not with a generic statement such as “as much as possible.” Excessive depth of field can introduce unnecessary compromises, while insufficient depth of field produces systems that work during commissioning but become unstable when normal product variation appears.
Begin by identifying the closest and farthest positions of the actual inspection features. Separate total component height from relevant inspection height. Include fixture repeatability, package variation, conveyor movement and differences between product variants. Then define the field of view, working distance and smallest feature that must be resolved. These values determine the necessary magnification and provide the foundation for choosing the machine vision lens.
Once the geometry is established, aperture can be used to provide the required focus range, but it should not be expected to compensate for an unnecessarily high magnification or poorly controlled object position. If the required depth is excessive, reconsider working distance, focal length, field of view or mechanical presentation before sacrificing image detail.
This is where a broad, specialised product range becomes useful. Kyptec Automation® provides Machine Vision Lens options across several focal lengths, resolution classes and sensor formats, allowing OEMs, machine builders and system integrators to design around the actual inspection envelope. Rather than selecting optics from focal length alone, buyers can evaluate models such as the Kyptec Automation® KL-1208 25 MM 5 MegaPixel 2/3" Machine Vision Lens, Kyptec Automation® KL-1230 35 MM 10 MegaPixel 2/3" Machine Vision Lens, Kyptec Automation® KL-1238 16 MM 25 MegaPixel 1.1" Machine Vision Lens, Kyptec Automation® KL-1242 35 MM 25 MegaPixel 1.1" Machine Vision Lens and Kyptec Automation® KL-1302 75 MM 1.5 MegaPixel 2/3" Machine Vision Lens according to the required field of view, camera format, resolution, working distance and installation constraints. Their current specifications and availability are published within the Kyptec Automation® Machine Vision Lens collection.
The strongest machine vision system is therefore not the system with the theoretical maximum depth of field. It is the system with enough verified depth of field to preserve the required inspection information across every realistic production height, while maintaining the resolution, field of view and optical stability needed by the application. When depth of field is treated as an engineering tolerance instead of a vague lens specification, machine vision lens selection becomes more predictable, commissioning becomes easier, and the finished inspection system is considerably better prepared for real factory conditions.

Share:
Machine Vision Lens Aperture Guide: How F Number Affects Brightness, Depth of Field, Sharpness and Inspection Accuracy
Which Machine Vision Lens Do I Need? Calculate Focal Length from Field of View, Sensor Size and Working Distance