v9.1.1
Menu

Camera Calibration Matrix Decomposition

easyFREECamera modelCamera ModelComputer Vision 1

Decompose a 3×33 \times 3 upper-triangular camera intrinsic matrix KK into its individual parameters.

The intrinsic matrix KK has the form:

K=(fxscx0fycy001)K = \begin{pmatrix} f_x & s & c_x \\ 0 & f_y & c_y \\ 0 & 0 & 1 \end{pmatrix}

where:

  • fx,fyf_x, f_y are the focal lengths (in pixels) along the x and y axes
  • cx,cyc_x, c_y is the principal point (where the optical axis meets the image plane)
  • ss is the skew coefficient (usually 0 for modern cameras)

Given such a matrix, extract and return these parameters as a dictionary with keys 'fx', 'fy', 'cx', 'cy', and 'skew'.

This decomposition is a fundamental step in camera calibration and is used extensively in 3D reconstruction, augmented reality, and visual SLAM.

Example

Input
K = [[800.0, 0.0, 320.0],
     [0.0, 800.0, 240.0],
     [0.0, 0.0, 1.0]]
Output
{'fx': 800.0, 'fy': 800.0, 'cx': 320.0, 'cy': 240.0, 'skew': 0.0}
Reasoning
  • Input: K is a 3×33 \times 3 intrinsic matrix in pixel units. Matching it against the template (fxscx0fycy001)\begin{pmatrix} f_x & s & c_x \\ 0 & f_y & c_y \\ 0 & 0 & 1 \end{pmatrix} tells you what each number means.
  • Diagonal: the first two diagonal entries are the focal lengths, so fx=800.0f_x = 800.0 and fy=800.0f_y = 800.0. Since fx=fyf_x = f_y, the pixels are square (equal scale horizontally and vertically).
  • Last column: the top two entries give the principal point, (cx,cy)=(320.0,240.0)(c_x, c_y) = (320.0, 240.0). For a 640×480640 \times 480 image that is the exact centre, where the optical axis would hit.
  • Above the diagonal in the first row: the skew is s=0.0s = 0.0, so the sensor's x and y axes are perpendicular.
  • Output: {'fx': 800.0, 'fy': 800.0, 'cx': 320.0, 'cy': 240.0, 'skew': 0.0}. Notice the bottom row (0,0,1)(0, 0, 1) never appears in it; it is the same for every camera. With s=10s = 10 in that first-row slot, only 'skew' would change.

Constraints

  • Input: A 3x3 upper-triangular intrinsic matrix K as a list of lists
  • K[2][2] is always 1
  • Return a dictionary with keys 'fx', 'fy', 'cx', 'cy', 'skew'
  • Values should be floats

Learn this in

More from Computer Vision 1

solution.py

Test results

Sign in to run your code against the test cases.