Vergence & rectification

Our eyes turn towards what we look at, and cameras of a stereo rig are often turned inwards too. That shares more of the view between them, but corresponding points no longer lie on the same row. Turn the cameras towards a fixation point, then rectify: warp both images onto a common plane, so that every point is found again on its own scanline.

Top view nearer than the fixation point, d>0d > 0 farther, d<0d < 0 d=0d = 0 direction after rectification
Images of the verged cameras click a point to select it epipolar line row of the point in the left image + fixation point
Rectified images the outline is the original image after warping with HLH_L and HRH_R

Vergence

In the simple stereo setup the optical axes are parallel and meet only at infinity. Human eyes instead turn towards the point they look at, the fixation point. With the eyes or cameras a distance cc apart and the angle θ\theta between their axes, the fixation point lies at the distance

D=c2tan⁡(θ/2)D = \frac{c}{2 \tan(\theta / 2)}

A large angle means a near point, a small angle a far one. The angle changes quickly only for near points, which is why vergence helps human depth perception only up to about 2–2.5 m; beyond that we rely on other cues such as motion parallax, perspective and occlusion.

The fixation point appears at the same position in both images, so its disparity is zero. A point nearer than the fixation point is seen further outward in each image and has a positive disparity d=xL−xR>0d = x_L - x_R > 0; a farther point a negative one. In the top view, all points with zero disparity lie on the circle through both centers and the fixation point.

Turning the cameras inwards makes the parts of the scene that both see larger and allows a larger baseline, which improves the accuracy. But the image rows are no longer aligned: the epipolar line of a point is slanted, and its match lies above or below its row.

Rectification

Rectification restores the simple setup without moving the cameras. Each camera is turned virtually about its own center to a common orientation RrectR_\text{rect}: the xx axis along the baseline and both optical axes perpendicular to it. Both images are then reprojected onto one common image plane parallel to the baseline. A change of orientation alone maps pixels through a homography:

x′∼Hi x,Hi=K Rrect Ri⊤K−1\mathbf{x}' \sim H_i\, \mathbf{x}, \qquad H_i = K\, R_\text{rect}\, R_i^\top K^{-1}

K−1K^{-1} turns a pixel into a viewing ray in camera coordinates, Ri⊤R_i^\top into world coordinates, RrectR_\text{rect} into the rectified camera, and KK back into a pixel. Afterwards the epipoles lie at infinity, all epipolar lines are horizontal, and corresponding points share their row. The search for a match becomes a search along a scanline, and the depth follows from Z=f c/dZ = f\,c / d with only positive disparities.

The warp stretches the images into trapezoids, and the stretching grows with the angle between the views. Where the warped image is enlarged, the new pixels are interpolated from fewer original ones.

Try this