PIXELBANKv8.2.1
Menu

Pinhole Camera Intrinsic Projection

Given a 3D point in camera coordinates and a camera intrinsic matrix KK, compute the projected 2D pixel coordinates using the pinhole camera model.

The intrinsic matrix KK has the form:

K=[fx0cx0fycy001]K = \begin{bmatrix} f_x & 0 & c_x \\ 0 & f_y & c_y \\ 0 & 0 & 1 \end{bmatrix}

Where fx,fyf_x, f_y are focal lengths and (cx,cy)(c_x, c_y) is the principal point.

The projection formula is:

[uv1]=1ZcK[XcYcZc]\begin{bmatrix} u \\ v \\ 1 \end{bmatrix} = \frac{1}{Z_c} K \begin{bmatrix} X_c \\ Y_c \\ Z_c \end{bmatrix}

Return the 2D pixel coordinates [u,v][u, v] rounded to 2 decimal places.

Example:

Input:
print(pinhole_projection([[800.0, 0.0, 320.0], [0.0, 800.0, 240.0], [0.0, 0.0, 1.0]], [10.0, 20.0, 5.0]))
Output:
[1920.0, 3440.0]
Reasoning:
  1. Multiply KK by the 3D point: K[100,50,10]TK \cdot [100, 50, 10]^T
  2. Divide by Zc=10Z_c = 10 to get normalized coordinates
  3. Result: [u,v]=[610.0,355.0][u, v] = [610.0, 355.0]

Constraints:

  • The input point w' = [u', v', w'] has depth w' > 0
  • Lambda is a valid 3x3 intrinsic matrix
  • All inputs are floating-point numbers
  • Output must be rounded to 4 decimal places
Editor

Test Results

0/0
Run code to see test results.