Triangulation of 3D Points
Implement a linear triangulation method to estimate 3D points from two camera views. This technique is crucial in Structure from Motion (SfM) and Bundle Adjustment for reconstructing 3D scenes from 2D images.
The goal is to find the 3D point that minimizes the reprojection error between the observed 2D points and in two camera views, given the camera matrices and .
Here are the steps to follow:
- For each point pair, build a matrix from the camera matrices and the 2D points (below), where is the -th row of .
- Apply Singular Value Decomposition (SVD) to to find the homogeneous point with .
- Dehomogenize: divide by to get .
Return the 3D points as a NumPy array of shape , one row per point pair.
This technique is widely used in computer vision applications, such as 3D reconstruction and Simultaneous Localization and Mapping (SLAM).
Example
P1 = K @ [I | 0] # First camera at origin P2 = K @ [R | t] # Second camera pts1 = [[u1, v1], ...] pts2 = [[u2, v2], ...]
3D points [[X, Y, Z], ...]
- Inputs: are projection matrices;
pts1andpts2hold matching image points , one per row. Take , , with and . - Rows of : , , , .
- Null space: a homogeneous point projecting onto both pixels satisfies ; here that unit vector is . With noisy pixels, take the unit minimising .
- Dehomogenise: dividing by gives . Check: it reprojects to and .
- Output: an array, here one row . Notice depth comes from disparity: a shift of over a baseline of gives . Identical pixels in both views mean parallel rays and : a point at infinity.
Constraints
- P1, P2: Camera projection matrices (3, 4)
- pts1, pts2: Corresponding 2D points (N, 2)
- Return: 3D points (N, 3)