Camera Lens and Focal Length Calculation: Field of View and Distance

Camera lens calculation: formulas for sensor width, focal length and field of view, worked examples, the difference between varifocal and motorized lenses, and a selection table by distance.
Technical summary
Technology
IP camera optics, rectilinear lenses, varifocal and motorized lenses, IR-corrected lenses, IEC 62676-4
Topic
Calculating focal length, field of view and field width
Level
Intermediate
Prerequisites
  • Basic trigonometry
  • The habit of reading camera datasheets
In this article7 sections

In a site survey, the decision “let’s put a 4 mm here” is often made by habit rather than measurement. The result shows up at commissioning: either a narrow frame showing half a door, or a wide image in which nobody can be identified. A camera lens calculation catches both mistakes before mounting; it gives how much width will be seen at a given distance and with how many pixels that width will be recorded. Below we work through the relationship between sensor, focal length and field of view with formulas, worked examples and a selection table by distance.

Focal length, sensor and field of view

Focal length (f, mm) is the distance between the lens’s optical center and the sensor plane. On its own it doesn’t express an angle. The field of view is determined by the focal length together with the sensor’s effective image area. For an ideal lens that keeps straight lines straight (rectilinear), the horizontal field of view is:

HFOV = 2 × arctan( w / (2 × f) )

w : effective horizontal width of the sensor (mm)
f : focal length (mm)

For the vertical angle, enter the sensor height in the same formula; for the diagonal angle, the diagonal. Datasheets give all three angles. Use the horizontal angle (HFOV) for comparison; the width to be covered on the plan is horizontal.

Optical format names such as “1/2.8 inch” and “1/1.8 inch” are left over from the tube camera era and aren’t the sensor’s actual size. A typical 1/2.8-inch sensor with a 16:9 ratio and a diagonal of about 6.4 mm has an effective width of about 5.6 mm. The exact value varies with the sensor model and the readout area the camera uses. The safest way is to calculate backwards from the field of view the manufacturer gives.

The formula is for an ideal lens. With wide-angle lenses of 2.8 mm and below, barrel distortion becomes pronounced; the angle measured by the manufacturer may come out wider than the formula. In practice, this means a person at the edge of the frame looks smaller and bent. If you expect identification at the edge, a wide-angle lens is the wrong tool.

Field width formula

What you really need on site isn’t the angle but the field width at the target distance. From similar triangles:

W = D × w / f          (field width, m)
f = w × D / W          (required focal length, mm)
W = 2 × D × tan(HFOV / 2)   (from the datasheet angle)

D : horizontal distance between the camera and the target plane (m)
W : field width at that distance (m)

Once the width is found, pixel density is calculated: px/m = horizontal resolution ÷ W. Whether this value is enough for detection, observation, recognition or identification is compared with the DORI references in the IEC 62676-4:2014 table. These values are design targets; in testing, target distance, face angle, lighting, motion blur and compression are assessed together. The IEC 62676-4:2025 edition uses different categories and test charts; details of the thresholds are in the IP camera system design guide. Here we only look at the optical side.

Don’t skip mounting height when measuring distance. If the camera is at 6 m height and the target is 8 m away horizontally, the real distance is about 10 m (√(6² + 8²)). Calculating with horizontal distance for high mounts makes the field width look smaller and the pixel density larger than they are. This is a common calculation error. Other effects of height and tilt are in the camera mounting height and angle article.

Fixed, varifocal and motorized lenses

In enterprise camera systems, two questions determine the lens type: how precise is the survey data, and will the frame change after installation?

Lens type Advantage Limitation When it fits
Fixed Low cost, small housing, no adjustment errors The frame can’t be changed afterwards Doors, corridors and checkouts with measured distances
Manual varifocal Focus and zoom adjusted on site Takes time during installation; focus may shift with IR switching Points where survey data is partly uncertain
Motorized varifocal Remote zoom/focus, automatic focus correction More expensive; contains moving parts Hard-to-reach mounts, façades, poles
Long focal length / zoom block High pixel density at long distances Narrow field, shallow depth of field, sensitive to vibration Perimeter lines, long roads, large sites

A rarely discussed advantage of motorized lenses is that they can correct the focus shift when switching from day to IR night mode. Visible light and infrared around 850 nm don’t focus at the same point. IR-corrected lenses reduce this difference but don’t eliminate it completely at long focal lengths. On a manual varifocal camera, if focus is set during the day and not checked at night, the night image stays soft. You notice it at the first incident review.

The match between lens and sensor is a separate check item too. On a box camera (C/CS mount), if a separately purchased lens’s image circle doesn’t cover the sensor, the corners darken (vignetting). A lens without a stated megapixel class blurs detail on a high-resolution sensor. The pixel count goes up; the detail doesn’t.

Aperture and depth of field

The F-number (for example F1.6) determines the light reaching the sensor; the smaller the F-number, the more light and the narrower the depth of field. When a long focal length and a large aperture come together, the sharp zone can shrink to a few meters. If you’re watching a long corridor or a deep car park lane with a single camera, set focus on the zone where identification is expected and accept that the rest will stay soft. On cameras supporting P-iris, the aperture can be fixed in software; this helps preserve depth of field during the day.

Example calculations

The calculations are for a 1/2.8-inch sensor with an assumed effective width of 5.6 mm. In your own project, use the value from the datasheet.

Example 1: The lens’s field of view

f = 4 mm  → HFOV = 2 × arctan(5.6 / 8)  ≈ 70°
f = 6 mm  → HFOV = 2 × arctan(5.6 / 12) ≈ 50°
f = 8 mm  → HFOV = 2 × arctan(5.6 / 16) ≈ 38.6°
f = 12 mm → HFOV = 2 × arctan(5.6 / 24) ≈ 26.3°

Example 2: Field width at a given distance

A camera with a 4 mm lens watches a target plane at 10 m: W = 10 × 5.6 / 4 = 14 m. If the camera is 2 MP (1920 pixels), density is 1920 / 14 ≈ 137 px/m. This is slightly above the recognition reference (125 px/m) in the IEC 62676-4:2014 table, and clearly below the identification reference (250 px/m). With the same lens, a 4 MP (2560-pixel) camera gives ≈ 183 px/m. Still not enough for identification.

Example 3: Calculating back from the target to the lens

On a vehicle entry lane, an identification density of 250 px/m is wanted at a point 15 m from the camera; the camera is 2560 pixels wide. Required field width W = 2560 / 250 = 10.24 m. Required focal length f = 5.6 × 15 / 10.24 ≈ 8.2 mm. An off-the-shelf 8 mm fixed lens widens the field slightly (W = 10.5 m, ≈ 244 px/m) and falls just below the threshold. The right move is to set a 2.8–12 mm varifocal lens to around 8.5–9 mm, or to move the camera closer to the target.

This is a typical decision point. If the calculation falls between standard lens values, either the lens type or the mounting position changes. Meeting the threshold “approximately” and moving on loses identification level once night noise and compression loss are added. The 244 px/m on paper is less in the recording.

Lens selection table by distance

The table calculates focal length by required width and distance with the same 5.6 mm sensor width, and gives pixel density at two resolutions. Use it as a starting point and verify the angle against the datasheet.

Distance / width Calculated f At 1920 px At 2560 px
5 m / 10 m ≈ 2.8 mm 192 px/m 256 px/m
10 m / 10 m ≈ 5.6 mm 192 px/m 256 px/m
15 m / 8 m ≈ 10.5 mm 240 px/m 320 px/m
20 m / 10 m ≈ 11.2 mm 192 px/m 256 px/m
30 m / 8 m ≈ 21 mm 240 px/m 320 px/m
50 m / 10 m ≈ 28 mm 192 px/m 256 px/m

Two things can be read from the table. First: pixel density depends only on the required field width; as distance increases, focal length rises proportionally to keep the same width. Second: the upper end (12 mm) of a 2.8–12 mm varifocal lens on this sensor carries identification density to about 16 m on a 1920-pixel camera and about 22 m on a 2560-pixel camera. For identification targets beyond these distances, a camera with a long focal length lens, a zoom block camera or a PTZ is needed. How to plan a PTZ together with fixed cameras is in the PTZ camera placement article.

Common mistakes in lens selection

  • Mistaking the diagonal angle for the horizontal one: The largest angle on the datasheet is usually the diagonal. If it’s used in a horizontal calculation, the field is planned wider than it is.
  • Expecting both an overview and identification from a single camera: A wide angle gives coverage; a narrow angle gives detail. At critical passages, two cameras, one for the overview and one for identification, often do a better job than a single high-resolution camera.
  • Increasing resolution without changing the lens: Moving from 2 MP to 8 MP doubles horizontal density (from 1920 to 3840 pixels). But smaller pixels can reduce night performance. Narrowing with the lens is often the more efficient route.
  • Setting the frame by day and not checking focus at night: Focus shift when switching to IR mode only shows up in a night test.
  • Counting digital zoom as optical zoom: Enlarging after recording doesn’t create new pixels. Identification density must be achieved at the moment of recording.
  • Not accounting for the dome: A varifocal lens inside a dome can bring the dome’s edge or reflections into the frame at extreme settings. Check the setting with the dome fitted.

A lens decision has no meaning on its own; it’s made together with camera positioning and blind spot analysis. To carry out these calculations systematically across a facility, see our IP camera system design and camera positioning and blind spot analysis services. For the framework of the measurement approach, the IEC 62676-4 application guidelines among IEC publications can be used as a reference.

Frequently asked questions

Does a larger mm value show farther away?

No, it shows narrower. As the focal length increases, the field of view narrows and the same horizontal resolution is spread over a smaller area; that’s why a distant target appears with more pixels. The cost is losing coverage of the camera’s immediate surroundings.

Why do two cameras with the same mm value give different fields of view?

Focal length alone doesn’t determine the angle; the sensor’s effective width also enters the calculation. A 4 mm lens gives different angles on a 1/2.8-inch and a 1/1.8-inch sensor. Distortion in wide-angle lenses also moves the datasheet angle away from the formula result.

Should varifocal lenses be preferred in every project?

No. If survey measurements aren’t precise, or the scene will change after installation, a varifocal or motorized lens lowers the risk. If distance and width have been measured with a laser meter, a fixed lens is cheaper, smaller and less prone to adjustment errors.

Does a lens calculation replace a DORI calculation?

No, it complements it. The lens calculation gives the field width at a given distance; DORI tells you whether the pixels falling on that width are enough for the target task. A lens decision isn’t made until both are done together.

Support

Contact us for support or a discovery session on this topic.

Contact form
[email protected]

Eretek Video Surveillance

IP cameras, recording and central management infrastructure. We plan blind spots, retention periods and the camera network around the risks of each site.

Knowledge Center

Other articles