# Calculation of focal length

Hello, I have to calculate the focal length. My parameters are the Matrix of the intrinsic parameters, Nx and Ny(number of pixel in x and y direction). Someone can help me? Thanks.

This forum is disabled, please visit https://forum.opencv.org

Calculation of focal length

add a comment

0

```
FL=(d/2)/tan(a/2)
```

where `FL`

is the focal length, `d`

is the sensor diagonal and `a`

is the diagonal field of view.

The resolution (`Nx`

and `Ny`

) and the other parameters of the camera don't have any incidence on the focal length.

N.B. this formula is true in the other side of the lens too. For example to get the height of the image (the object that fits in the image) `OH`

at a given distance `D`

given a vertical angle of view `av`

:

```
OH=2*D*tan(av/2)
```

More details on angle of view, focal length and image area here.

Thanks for your answer. The problem is that I don't have d and a, in your formula. Maybe I can do something with intrinsic matrix?. It's something like this: K =[1. 3, 0, 0.3; 0, 1.3, 0.3; 0, 0,0.001]; Thanks again.

That is probably not enough. The intrinsic camera matrix doesn't contain any information about the physical dimensions of the sensor, which is needed to get the focal distance.

Take a look at this document for explanation of the camera matrix and how to get the focal length from it.

Asked: **
2018-10-26 03:51:55 -0600
**

Seen: **1,241 times**

Last updated: **Oct 26 '18**

Copyright OpenCV foundation, 2012-2018. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.