PIXELBANKv8.2.1
Menu

Perspective Projection with Intrinsics

Implement a perspective projection that maps 3D world points to 2D image coordinates using a camera's intrinsic matrix. This process is crucial in computer vision for understanding how 3D scenes are projected onto 2D images.

The intrinsic matrix, denoted as KK, encapsulates the camera's internal parameters, including focal lengths (fxf_x, fyf_y) in pixels and the principal point (cxc_x, cyc_y), which represents the optical center of the camera. The intrinsic matrix KK is given by K=(fx0cx0fycy001)K = \begin{pmatrix} f_x & 0 & c_x \\ 0 & f_y & c_y \\ 0 & 0 & 1 \end{pmatrix} To project a 3D point (XX, YY, ZZ) to a 2D image point, the following steps are involved:

  1. Perform perspective division by dividing the XX and YY coordinates by ZZ.
  2. Apply the intrinsic matrix KK to the normalized coordinates. The projection equation can be represented as p=K[X/Z,Y/Z,1]T\mathbf{p} = K \cdot [X/Z, Y/Z, 1]^T.
K=(fx0cx0fycy001)K = \begin{pmatrix} f_x & 0 & c_x \\ 0 & f_y & c_y \\ 0 & 0 & 1 \end{pmatrix}

This technique is widely used in 3D reconstruction and image processing applications.

Example:

Input:
points_3d = [[0, 0, 10], [5, 5, 10]]
K = [[500, 0, 320], [0, 500, 240], [0, 0, 1]]
Output:
[[320.0, 240.0], [570.0, 490.0]]
Reasoning:

Point [0,0,10]:

  • Normalized: [0/10, 0/10, 1] = [0, 0, 1]
  • Projected: K @ [0,0,1]^T = [320, 240, 1]
  • Pixel: [320, 240]

Point [5,5,10]:

  • Normalized: [0.5, 0.5, 1]
  • Projected: K @ [0.5,0.5,1]^T = [250+320, 250+240, 1] = [570, 490]

Constraints:

  • points_3d: List of [X, Y, Z] world points
  • K: 3×3 intrinsic matrix
  • Return: List of [u, v] pixel coordinates
  • Round to 2 decimal places
Editor

Test Results

0/0
Run code to see test results.