TL;DR
A single photo tells you the direction to a point but not how far away it is. Take a second photo from another position and each camera gives you a ray toward the same point. Triangulation finds the 3D point where those rays meet. In practice the rays never cross exactly because pixels are noisy, so the method picks the point that best fits all the measurements, usually by solving a small linear system.
Where you'll see it: in stereo depth sensing on phones and cars, in 3D reconstruction from photo collections, and as the final step of structure from motion, where each new 3D point is placed by triangulating its matched pixels.
Intuition
Two rays that meet
Stand at two spots a few metres apart and look at the same lamp post. From each spot you can point in the direction of the lamp. Draw both pointing lines on a map and they cross at the lamp. Your two bearings fix its position, and the distance between your spots, called the baseline, sets how accurately you can locate it.
A camera does the same thing. A pinhole camera turns a 3D point into a pixel, and the set of 3D points that land on that pixel is a ray from the camera centre. Given two cameras whose positions and internal settings are known, a point seen in both images sits where the two rays intersect.
Why it is not just a crossing
Real pixels are measured with error, so the two rays miss each other in 3D. They pass close to each other near the true point but do not cross exactly. Triangulation has to pick one point. The usual answer is the point that best explains the measured pixels in both images, the one whose projections land closest to the observed positions. That turns a geometric question into a least-squares problem.
The same logic extends to many cameras. Each extra view adds rays, and the estimate becomes more stable. Stereo depth, which makes a depth map from two side-by-side cameras, is the same method applied to every pixel of the image.
flowchart LR A[Matched pixels in view 1 and view 2] --> B[Known camera matrices P1 and P2] B --> C[Linear equations for the 3D point X] C --> D[Solve with SVD] D --> E[Divide by last coordinate] E --> F[3D point X]
The math
Setup
Each calibrated camera is a matrix from the pinhole model, where holds the internal settings, is rotation and is translation. A 3D point is written in homogeneous coordinates, and it projects to the image point , where means equal up to a nonzero scale. In a pixel with coordinates , the homogeneous image point is .
Write for the three rows of . Then has entries , and , and the projection to pixel coordinates is and .
Linear equations
Clear the denominator. Each observed pixel gives two equations that are linear in :
Each camera contributes two rows to a matrix , and the unknown is the 4-vector . For two cameras you get a system . This is the direct linear transform (DLT). In the noise-free case the system has a nonzero solution, and that solution is the point. With noise it has no exact solution, so we look for the unit vector that makes smallest.
Solving with SVD
The singular value decomposition writes , where the singular values in are sorted from largest to smallest. The unit vector that minimises is the last column of , the one paired with the smallest singular value. Divide its first three entries by its fourth to get in the world frame.
Roughly, the smallest singular value (after scaling the rows sensibly) reflects how well the rays agree: a tiny value means they nearly meet, and a large one means the measurements conflict. It is an algebraic residual, not a distance in pixels, which is why the tradeoffs section recommends refinement.
Depth from disparity
For a rectified stereo pair with focal length and baseline , a point at depth shifts between the two images by a disparity . Depth is therefore . Nearby points have large disparity and far points have small disparity, and the error in grows quickly as shrinks.
Worked examples
Use normalised cameras with . Camera 1 sits at the origin, so its coordinates are the world coordinates. Camera 2 is shifted by one unit along , so its camera coordinates are . The true point is .
- Camera 1 sees and .
- Camera 2 sees and .
- From the first camera, and . From the second, .
- Substitute into the second: , so and .
- Then and , recovering exactly.
With exact pixels this is just intersection. Note the disparity: (the sign only reflects which way camera 2 is shifted), which matches the depth-from-disparity formula with .
Keep the same rig, and , so .
- A point at depth has disparity .
- Suppose the pixel measurement is off by 0.01, so the measured disparity is . Then .
- Compare the error: the depth is off by about , which is about 3.8% of 4.
- Now take a far point at , where . The same measurement error of 0.01 gives and , an error of 3.3 units, or 17% of the depth.
- Interpretation: the same pixel error costs far more depth accuracy at long range. A wider baseline makes disparities larger, which is why stereo rigs are spread apart for distant sensing.
The curve below shows how depth falls as disparity grows, with the near point from the examples (, ) and two other points marked.
- Z = 1 / d
Tradeoffs and failure modes
Triangulation is only as good as the cameras and the matches behind it.
| Situation | What goes wrong | Better choice |
|---|---|---|
| Small baseline, distant points | Rays are nearly parallel, so depth is poorly determined. | Widen the baseline, or use more views. |
| Wrong pixel matches between views | One bad match pulls the point far off. | Reject outliers with a robust method such as RANSAC before triangulating. |
| Poor camera calibration | The matrices are wrong, so every point is biased. | Calibrate carefully, or refine the cameras jointly with the points. |
| Points behind a camera () | The division flips sign and the result is meaningless. | Check the sign of the depth and discard such points. |
| Plain linear (DLT) estimate with noise | The linear solve minimises an algebraic error, not the pixel error. | Refine with nonlinear least squares on the reprojection error. |
The linear method is fast and makes a good starting point. The true objective is the distance between the projected point and the measured pixel in each image, and that is nonlinear in . Refining with nonlinear least squares gives the optimal estimate, at a higher cost.
History
Triangulation is much older than computer vision. Surveyors used it for centuries to measure distances they could not reach, by sighting the same landmark from two known points. Stereo vision brought the same geometry to images in the 19th century, when stereoscopes let viewers fuse two photographs into one 3D scene.
In computer vision, the linear DLT approach was standard in the 1990s. In 1997 Richard Hartley and Peter Sturm analysed the optimal triangulation problem, showing that the best estimate minimises the pixel reprojection error and that the linear method can be improved considerably. Their work and the textbook by Hartley and Zisserman set the modern treatment, which is now the basis of structure from motion and multi-view reconstruction.
Check yourself
QuestionRecall: why does a single photo not determine a 3D point's position?Show answer
QuestionComputation: a rectified stereo pair has and . A point has disparity . What is its depth?Show answer
QuestionWhy: the two rays from a noisy pair of cameras do not intersect exactly. What should triangulation return instead?Show answer
QuestionApplied: a wide-baseline and a narrow-baseline rig both observe a distant building. Which one gives the more accurate depth, and why?Show answer
Sources
- Epipolar geometry, Wikipedia
- Pinhole camera model, Wikipedia
- Structure from motion, Wikipedia
- Richard Hartley and Andrew Zisserman, Multiple View Geometry in Computer Vision, Cambridge University Press, 2nd ed., 2003
- Richard Hartley and Peter Sturm, "Triangulation," Computer Vision and Image Understanding, 1997