Camera Center from Projection Matrix
Given a projection matrix , compute the camera center in world coordinates.
The camera center is the point in 3D space where all projection rays converge. It satisfies:
where is the camera center in homogeneous coordinates. This is the null space of .
Algorithm using SVD:
- Compute the SVD of :
- The camera center in homogeneous coordinates is the last column of (or last row of )
- Convert from homogeneous to Euclidean by dividing by the last element:
Round each coordinate to 4 decimal places.
Example
P = [[1, 0, 0, -5],
[0, 1, 0, -3],
[0, 0, 1, -2]][5.0, 3.0, 2.0]
- Input:
Pis a camera matrix acting on homogeneous world points . Here its left block is the identity and its last column is . - Math: the center is the 4-vector that sends to zero. Row by row, , , . Three equations in four unknowns leave one free direction: every multiple of .
- Normalised to unit length (sign arbitrary), that direction is .
- Back to 3D: divide the first three entries by the fourth, using exact values: , and likewise and . The and any sign flip cancel.
- Output:
[5.0, 3.0, 2.0], rounded to 4 decimal places. Notice that for the last column is just . Scaling 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