v9.1.1
Menu

Camera Center from Projection Matrix

mediumPROCamera modelCamera ModelComputer Vision 1

Given a 3×43 \times 4 projection matrix PP, compute the camera center CC in world coordinates.

The camera center is the point in 3D space where all projection rays converge. It satisfies:

P⋅C~=0P \cdot \tilde{C} = \mathbf{0}

where C~=[Cx,Cy,Cz,1]T\tilde{C} = [C_x, C_y, C_z, 1]^T is the camera center in homogeneous coordinates. This is the null space of PP.

Algorithm using SVD:

  1. Compute the SVD of PP: P=UΣVTP = U \Sigma V^T
  2. The camera center in homogeneous coordinates is the last column of VV (or last row of VTV^T)
  3. Convert from homogeneous to Euclidean by dividing by the last element: C=[V0,3/V3,3,V1,3/V3,3,V2,3/V3,3]C = [V_{0,3}/V_{3,3}, V_{1,3}/V_{3,3}, V_{2,3}/V_{3,3}]

Round each coordinate to 4 decimal places.

Example

Input
P = [[1, 0, 0, -5],
     [0, 1, 0, -3],
     [0, 0, 1, -2]]
Output
[5.0, 3.0, 2.0]
Reasoning
  • Input: P is a 3×43 \times 4 camera matrix acting on homogeneous world points (X,Y,Z,W)(X, Y, Z, W). Here its left 3×33 \times 3 block is the identity and its last column is (−5,−3,−2)(-5, -3, -2).
  • Math: the center is the 4-vector that PP sends to zero. Row by row, X−5W=0X - 5W = 0, Y−3W=0Y - 3W = 0, Z−2W=0Z - 2W = 0. Three equations in four unknowns leave one free direction: every multiple of (5,3,2,1)(5, 3, 2, 1).
  • Normalised to unit length (sign arbitrary), that direction is (5,3,2,1)/39≈(0.8006,0.4804,0.3203,0.1601)(5, 3, 2, 1)/\sqrt{39} \approx (0.8006, 0.4804, 0.3203, 0.1601).
  • Back to 3D: divide the first three entries by the fourth, using exact values: 5/391/39=5\frac{5/\sqrt{39}}{1/\sqrt{39}} = 5, and likewise 33 and 22. The 39\sqrt{39} and any sign flip cancel.
  • Output: [5.0, 3.0, 2.0], rounded to 4 decimal places. Notice that for P=[I∣−C]P = [I \mid -C] the last column is just −C-C. Scaling PP by 2 leaves the center unchanged, because the null direction stays the same.

Constraints

  • Input: A 3x4 projection matrix P as a list of lists
  • Use numpy for SVD computation
  • Return: A list [X, Y, Z] representing the camera center
  • Round to 4 decimal places
  • The last element of the null space vector is guaranteed to be non-zero

Learn this in

More from Computer Vision 1

PRO

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test results

Sign in to run your code against the test cases.