Determining the Camera Calibration Matrix: Unraveling the Process from Hardware Specifications

1. What are camera models?
The most basic camera model is the pinhole camera model, which explains the process of projecting a 3D point from camera space onto a 2D image space.

A calibration matrix can be used to articulate the relationship between a 3D spatial point and its corresponding 2D image point.

The camera calibration matrix (also called camera intrinsic matrix) can become increasingly intricate, potentially incorporating factors such as skew parameters, separate focal lengths, and offsets for the principal point in both the x-axis and y-axis.

2. How can we calculate the camera’s calibration matrix if we have limited knowledge of the hardware information?
If you possess limited knowledge about the camera’s hardware details such as sensor size and camera focal length, employing computer vision software packages like OpenCV becomes essential for the automated estimation of the camera’s intrinsic matrix. The fundamental concept involves using multiple real-world 3D and 2D measurements to compute the mathematical mapping, of which the calibration matrix is an integral component. We would like to suggest OpenCV’s Camera Calibration and 3D Reconstruction for your reference on this topic.
3. What if the hardware’s information is provided?
If we happen to know the sensor’s size in millimeters and the camera's focal length in millimeters, the camera’s intrinsic matrix can be expressed as follows:
focal_length = 0.0036
sensor_size = (0.00367, 0.00274)
intrinsic_camera_matrix = np.array([
[focal_length, 0, sensor_size[0] / 2],
[0, focal_length, sensor_size[1] / 2],
[0, 0, 1]
])The intrinsic matrix defined above doesn’t directly incorporate the image size, and it’s typically not part of the intrinsic matrix itself. However, we can indirectly incorporate the image size into the intrinsic matrix construction by calculating the focal lengths based on the sensor size and the desired field of view (FOV).
import numpy as np
# Given parameters
focal_length = 0.0036
sensor_size = (0.00367, 0.00274)
image_size = (640, 480)
# Calculate focal lengths based on desired FOV and sensor size
fov_x = 2 * np.arctan((sensor_size[0] / 2) / focal_length)
fov_y = 2 * np.arctan((sensor_size[1] / 2) / focal_length)
f_x = (image_size[0] / 2) / np.tan(fov_x / 2)
f_y = (image_size[1] / 2) / np.tan(fov_y / 2)
# Construct the intrinsic matrix
intrinsic_camera_matrix = np.array([
[f_x, 0, image_size[0] / 2],
[0, f_y, image_size[1] / 2],
[0, 0, 1]
])We utilize the following diagram to illustrate the connection between them, adhering to the subsequent principles:
- The aspect ratio of the sensor matches that of the image in terms of width and height.
- FOV angle can be categorized into horizontal FOV and vertical FOV. When the image FOV is specified in one direction and the aspect ratio of the image is provided, it allows us to compute the FOV in the orthogonal direction.
fov_h = math.degree(2*math.atan(math.tan(math.radiants(fov_v/2))/(img_width/image_height))))

The limitation of using hardware information to determine the calibration matrix, however, is that we cannot estimate other parameters such as skew within the matrix.
4. How will focus length impact the output image?
As you can see, the focus length plays a critical role in the calibration matrix, and then how will it have an impact on the generated image?
We developed a Python script (empowered by pytransform3d) to examine its impact, see test_focol_length.py for more details.

It’s evident that with a shorter focal length, one can anticipate a broader field of view, increased depth of field, and a heightened sense of perspective exaggeration.




