v9.1.1
Menu

Construct Intrinsic Matrix

easyFREECamera CalibrationCalibrationCV: Structure from Motion and SLAM

Construct a camera intrinsic matrix from its parameters.

The camera intrinsic matrix KK describes the internal parameters of a camera that transform 3D camera coordinates to 2D pixel coordinates:

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 (horizontal and vertical)
  • (cx,cy)(c_x, c_y) is the principal point (usually near image center)
  • ss is the skew coefficient (usually 0 for modern cameras)

The focal length in pixels is computed as: fpixels=fmm×image_widthsensor_widthf_{pixels} = f_{mm} \times \frac{image\_width}{sensor\_width}

For a standard camera with square pixels, fx=fyf_x = f_y and s=0s = 0.

Example

Input
intrinsic_matrix(1000, 1000, 320, 240, 0)
Output
[[1000, 0, 320], [0, 1000, 240], [0, 0, 1]]
Reasoning
  • Inputs: fx =1000= 1000 and fy =1000= 1000 are the horizontal and vertical focal lengths in pixels, (cx,cy)=(320,240)(c_x, c_y) = (320, 240) is the principal point (the centre of a 640×480640 \times 480 image), and skew =0= 0 means the pixel axes are perfectly perpendicular.
  • Top row: horizontal pixel position depends on fxf_x, the skew ss and the offset cxc_x, so it reads (1000, 0, 320)(1000,\ 0,\ 320).
  • Middle row: vertical position does not depend on the camera's xx coordinate, so its first entry is 00; then fy=1000f_y = 1000 and cy=240c_y = 240, giving (0, 1000, 240)(0,\ 1000,\ 240).
  • Bottom row: (0, 0, 1)(0,\ 0,\ 1) never changes. It carries depth through so the result can be divided by it.
  • Check: a point on the optical axis, (0,0,1)(0, 0, 1), maps to K(0,0,1)T=(320,240,1)K(0,0,1)^T = (320, 240, 1), which is exactly the principal point.
  • Output: [[1000, 0, 320], [0, 1000, 240], [0, 0, 1]], an upper triangular 3×33 \times 3 matrix. Notice that a nonzero skew such as 0.10.1 would change only the top row, second column.

Constraints

  • fx, fy: focal lengths in pixels (positive floats)
  • cx, cy: principal point coordinates in pixels
  • skew: skew coefficient (default 0)
  • Return 3x3 matrix as nested list

Learn this in

More from CV: Structure from Motion and SLAM

solution.py

Test results

Sign in to run your code against the test cases.