Optoelectronics Basics #04
How to Calculate Lens Focal Length from Field of View and Working Distance
"I need to see a part 100 mm wide, and the camera can only be mounted 300 mm away. What focal length should the lens be?"
This is the question asked most often in selection, and also the one most easily miscalculated with a formula that "looks perfectly reasonable". This article sets out the correct calculation and shows with real numbers how far off the common approximation is.
1. How three numbers relate
The whole matter involves only three quantities:
- Sensor size S: the actual width of the sensor chip in that direction (mm)
- Field of view FOV: the real-world extent you need to capture (mm)
- Working distance WD: the distance from the front of the lens to the object (mm)
Dividing the sensor size by the field of view gives the magnification:
m = S / FOV
Magnification is the pivot of the whole calculation. Once you have it, the focal length is fixed:
f = WD · m / (1 + m)
2. Example: 100 mm field of view, 300 mm working distance
Calculating with a 2/3-inch 5 MP sensor. Note that you must use the actual active area width here: 2448 pixels × 3.45 µm = 8.45 mm, not a number converted from the nominal name "2/3 inch".
- Magnification
m = 8.45 / 100 = 0.0845 - Correct focal length
f = 300 × 0.0845 / 1.0845 = 23.4 mm - Approximation
f = 300 × 8.45 / 100 = 25.4 mm
The approximation overestimates by 8.5 %. The larger the magnification, the larger the error.
8.5 % does not sound like much, but the consequence is concrete: going by the approximation you buy a 25 mm lens expecting a field of view of exactly 100 mm, but it is actually only 93 mm and the edges of the part do not fit in, and this is usually discovered only after the mechanism is built and the camera mounted.
3. There is no 23.4 mm lens on the market
Machine vision lenses come in standard focal lengths: 8, 12, 16, 25, 35, 50 and 75 mm. You cannot buy the 23.4 mm you calculated, so the real process is to calculate the ideal focal length, choose the nearest standard focal length, then work back to the actual field of view.
The formula for working back inverts the one above:
m = f / (WD − f), FOV = S / m
4. Three things to check after choosing a focal length
4.1 Does the lens's image circle cover the sensor?
The "supported sensor size" in a lens specification is a hard condition. Pair a lens rated for 1/1.8-inch with a 2/3-inch sensor, and the four corners go dark or even black (vignetting). The lens's supported size must be greater than or equal to the sensor size; the reverse pairing works, it just wastes resolution.
4.2 Minimum working distance
Every lens has a minimum object distance (MOD). If the calculated working distance is shorter than the MOD, the lens cannot focus: you then need extension tubes, a macro lens, or a redesigned mechanism that moves the camera further away.
4.3 Is the resolution enough?
The focal length decides the field of view, and the field of view divided by the number of pixels is the real size each pixel represents:
GSD = FOV / horizontal pixels = 92.9 / 2448 = 38.0 µm
A defect must cover at least 3 to 5 pixels to be caught reliably. With this configuration, the lower limit is about 0.11 to 0.19 mm. To go smaller there are only three ways: narrow the field of view (several shots, longer cycle time), use a camera with more pixels, or shorten the working distance with a longer focal length. The trade-offs among the three are explained in full in the vision inspection station section of the industrial automation page.
5. When to use a telecentric lens
An ordinary lens gives a perspective projection: things closer to the lens look bigger. That makes no difference to "seeing whether there is a scratch", but it is fatal for "measuring dimensions": if the part sits 2 mm higher or lower in the fixture, the measured size changes with it.
In a telecentric lens the chief rays are parallel to the optical axis, so as the object moves back and forth within the depth of field, the image size hardly changes. The costs:
- The front of the lens must be larger than the object: measuring a 100 mm part needs a lens with an aperture over 100 mm, and the size and price are considerable
- The field of view is fixed and cannot be fine-tuned by adjusting the working distance
The rule of thumb is simple: to "measure" dimensions use telecentric; to "see" flaws use an ordinary lens.
6. A quick reference table
| Nominal size | Common model | Actual active area | Diagonal |
|---|---|---|---|
| 1/2.8-inch | IMX290 series 1920 × 1080 @ 2.9 µm | 5.57 × 3.13 mm | 6.4 mm |
| 1/1.8-inch | IMX178 3096 × 2080 @ 2.4 µm | 7.43 × 4.99 mm | 9.0 mm |
| 2/3-inch | IMX264 2448 × 2048 @ 3.45 µm | 8.45 × 7.07 mm | 11.0 mm |
| 1.1-inch | IMX253 4112 × 3008 @ 3.45 µm | 14.19 × 10.38 mm | 17.6 mm |
The calculation in four steps:
m = S / FOV: use the actual active width (pixel count × pixel pitch), not the inch figuref = WD · m / (1 + m): do not drop the (1+m)- Choose the nearest standard focal length and work back to the actual field of view with
FOV = S·(WD − f) / f - If it is slightly off, adjusting the working distance is easier than changing the lens
Closing: calculate first, then buy
The lens is one of the few parts of a vision system that "can be calculated": the focal length does not have to come from trial or experience, and the final working distance is then confirmed from manufacturer data or measurement. Ten minutes spent working through these four steps is far cheaper than buying the wrong lens and replanning the mechanism.
What really needs judgment is the question before all this: how small a defect must be seen. That number sets the upper limit of the field of view, the field of view sets the focal length, and the focal length sets how much space the mechanism must leave. Do it in the reverse order, and you usually discover that you cannot see it only after the mechanism is built.


