v9.1.1
Menu

Multi-View Triangulation Error

mediumFREEBundle Adjustment for SfMSfMCV: Structure from Motion and SLAM

Compute the total reprojection error for a 3D point observed in multiple camera views.

In Structure from Motion (SfM), we triangulate 3D points from multiple 2D observations. The quality of a triangulated point is measured by its reprojection error - how well it projects back to the observed 2D locations.

For each view ii, the reprojection error is: ei=∣∣π(Ki,Ri,ti,X)−pi∣∣2e_i = ||\pi(K_i, R_i, t_i, X) - p_i||^2

where π\pi projects the 3D point XX to 2D, and pip_i is the observed 2D point.

Total error is the sum across all views: Etotal=∑iei=∑i((ui−u^i)2+(vi−v^i)2)E_{total} = \sum_i e_i = \sum_i ((u_i - \hat{u}_i)^2 + (v_i - \hat{v}_i)^2)

Lower error indicates better triangulation.

Example

Input
triangulation_error([0, 0, 10], [([[1000,0,320],[0,1000,240],[0,0,1]], [[1,0,0],[0,1,0],[0,0,1]], [0,0,0], [320, 240])])
Output
0.0
Reasoning
  • Inputs: the world point is X=(0,0,10)X = (0, 0, 10), seen by one camera with focal lengths fx=fy=1000f_x = f_y = 1000 pixels, principal point (cx,cy)=(320,240)(c_x, c_y) = (320, 240), identity rotation, zero translation, and observed pixel p=(320,240)p = (320, 240).
  • Camera frame: Xc=RX+t=(0,0,10)X_c = RX + t = (0, 0, 10). The point sits 10 units straight ahead of the camera.
  • Pinhole projection: u^=fxXcZc+cx=1000⋅010+320=320\hat{u} = f_x \frac{X_c}{Z_c} + c_x = 1000 \cdot \frac{0}{10} + 320 = 320 and v^=fyYcZc+cy=1000⋅010+240=240\hat{v} = f_y \frac{Y_c}{Z_c} + c_y = 1000 \cdot \frac{0}{10} + 240 = 240.
  • Error: (320−320)2+(240−240)2=0(320 - 320)^2 + (240 - 240)^2 = 0. With a single view, Etotal=0E_{total} = 0, which is 0.0 once rounded to 4 decimal places.
  • Notice: a point on the optical axis always lands on the principal point, whatever its depth. Had the observation been (321,241)(321, 241), the error would be 12+12=21^2 + 1^2 = 2: the error is the squared pixel distance, not the distance.

Constraints

  • point_3d: [X, Y, Z] in world coordinates
  • observations: list of (K, R, t, pixel) tuples for each view
  • Return total squared reprojection error rounded to 4 decimal places

Learn this in

More from CV: Structure from Motion and SLAM

solution.py

Test results

Sign in to run your code against the test cases.