PIXELBANKv9.1.0
Menu

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:
  • Building intrinsic matrix with fx=fy=1000, center at (320, 240):
  • Row 0: [fx, skew, cx] = [1000, 0, 320]
  • Row 1: [0, fy, cy] = [0, 1000, 240]
  • Row 2: [0, 0, 1] = [0, 0, 1]
  • Result: standard pinhole camera matrix with square pixels.

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
solution.py

Test Results

0/0
Run code to see test results.