Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to compute intrinsic camera matrix for a camera

📅 2015-Sep-08 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ camera matrix, intrinsic camera matrix, primesense ⬩ 📚 Archive

The intrinsic camera matrix is useful in depth cameras to obtain the 3D position of any given pixel in the camera coordinate system. The pinhole camera model used for the intrinsic camera matrix is explained beautifully here.

The intrinsic camera matrix is of the form:

f_x s   x
0   f_y y
0   0   1

Here, f_x and f_y are the focal lengths of the camera in the X and Y directions. s is the axis skew and is usually 0. x and y are the X and Y dimensions of the image produced by the camera, measured from the center of the image. (So, they are half the length and width of the image.)

We typically know the dimensions of the image produced by the camera. What is typically not provided are the focal lengths. Instead camera manufacturers provide the field of view (FOV) angle in the horizontal and vertical directions.

Using the FOV angles, the focal lengths can be computed using trigonometry. For example, given the FOV a_x in the horizontal direction, the focal length f_x can be computed using:

f_x = x / tan(a_x / 2)

We divide the FOV by 2 because this angle spans the entire horizontal or vertical view.

As an example, consider the Primesense Carmine 1.09 depth camera. It produces a VGA (640x480) image. Its specifications state a horizontal FOV of 57.5 degrees and vertical FOV of 45 degrees.

Using the above information, we can compute its intrinsic camera matrix as:

583.2829786373293 0.0               320.0
0.0               579.4112549695428 240.0
0.0               0.0               1.0

© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘📧