Corresponding points on "the same plane" — a tabletop, a poster, a road surface — captured in two images are related by a much simpler relationship than a general 3D scene. No matter where the camera is, points on that plane can be transformed to one another using nothing but a single 3\times3 matrix. This matrix is the homography (a projective transform). Where the Epipolar Geometry Primer deals with correspondence constraints that presuppose scene depth, homography is a contrasting case in that it handles correspondences that don't depend on depth at all — and only by being able to use both appropriately do you get the full picture of two-view geometry.

0. 30-Second Summary

1. What Is Homography: Planar Projective Transform

When homogeneous coordinates \tilde{\mathbf{x}}=(x,y,1)^\mathsf{T}, \tilde{\mathbf{x}}'=(x',y',1)^\mathsf{T} on two images satisfy the relation

\tilde{\mathbf{x}}' \sim H\tilde{\mathbf{x}}

via some 3\times3 matrix H, we call H a homography. \sim means equal up to scale — multiplying H by any nonzero constant represents the same transform — so H's degrees of freedom are 9-1=8.

Two viewpoints capturing the same plane, and the homography H A diagram showing a single plane π in the world photographed from different positions by camera 1 and camera 2, with corresponding points across the two images linked directly by the homography H. Plane π (normal n, distance d) C1 C2 x Image 1 x′ Image 2 x′ ∼ H x

There are broadly two physical conditions under which a homography holds. First, all the corresponding 3D points lie on a single plane. Second, even for a scene with general 3D structure, if the camera translates not at all and only rotates purely (pan/tilt), the relationship can be described by a homography regardless of depth. This is because when the camera only rotates, no parallax arises at all.

2. Estimation via the DLT Method

From a single correspondence (x,y)\to(x',y'), we can derive a linear constraint on each element h_1,\dots,h_9 of H (writing \mathbf{h}=\operatorname{vec}(H)). Expanding the condition that the cross product \tilde{\mathbf{x}}'\times H\tilde{\mathbf{x}}=\mathbf{0} vanishes gives the following two independent equations per correspondence.

\begin{bmatrix} -x & -y & -1 & 0 & 0 & 0 & x'x & x'y & x' \\ 0 & 0 & 0 & -x & -y & -1 & y'x & y'y & y' \end{bmatrix}\mathbf{h}=\mathbf{0}

With 4 correspondences, you get 8 equations, which (in general position) uniquely determines the 8-degree-of-freedom H. In the realistic case where 5 or more correspondences are available, you find the least-squares solution to A\mathbf{h}=\mathbf{0} for the matrix A stacking all correspondences — that is, the right singular vector corresponding to A's smallest singular value, via SVD. This is the DLT (Direct Linear Transform) method.

Just as with the 8-point algorithm in epipolar geometry, using raw pixel coordinates directly tends to be numerically ill-conditioned. The standard implementation is Hartley's normalized DLT: apply a similarity transform T,T' to each image's point set so it has zero centroid and average distance \sqrt{2}, solve in that normalized frame, then transform coordinates back with H=T'^{-1}H_{\text{norm}}T.

3. Robust Estimation via RANSAC

Since real correspondences include mismatches, applying DLT directly to every correspondence lets outliers badly distort the solution. RANSAC repeats the following:

  1. Randomly select 4 correspondences, and build a hypothesis for H via DLT.
  2. For every correspondence, compute the reprojection error between the position predicted by H and the actual corresponding point.
  3. Adopt the hypothesis with the most correspondences (inliers) within the threshold.
  4. Solve DLT once more using all final inliers, and finish with nonlinear optimization (direct minimization of reprojection error) if needed.

The number of iterations needed can be estimated, given an inlier ratio w, minimal sample size s=4, and target success probability p, as

N=\frac{\log(1-p)}{\log\!\left(1-w^{s}\right)}

For the same inlier ratio, homography's s=4 requires fewer iterations than Essential/Fundamental Matrix estimation, which needs s=58. This is one reason it's common practice, right after SIFT or ORB matching, to first do a coarse geometric verification with homography before moving on to full 3D estimation.

4. Decomposing H: Extracting Rotation, Translation, and Plane Normal

If the camera is calibrated and the intrinsic parameters K_1,K_2 are known, the normalized homography \tilde H = K_2^{-1}HK_1 can be written, using the plane's unit normal \mathbf{n} (in camera 1's coordinate frame), distance to the plane d, and relative pose R,\mathbf{t}, as

\tilde H = R+\frac{\mathbf{t}\,\mathbf{n}^\mathsf{T}}{d}

If the camera undergoes pure rotation with no translation, \mathbf{t}=\mathbf{0}, so \tilde H=R — the rotation matrix itself.

The process of recovering R,\mathbf{t}/d,\mathbf{n} from \tilde H is called homography decomposition. Several algorithms are known, including the classical Faugeras–Lustman method and the analytic Malis–Vargas method, which obtain a closed-form solution using the eigendecomposition of \tilde H^\mathsf{T}\tilde H. However, purely from the math, as many as 4 physically possible solutions can remain (including ones corresponding to sign flips or reflections). In practice, these are narrowed down using:

OpenCV's decomposeHomographyMat performs this decomposition and provides filter functions (such as filterHomographyDecompByVisibleRefpoints, which selects the solution close to a known plane normal) that help evaluate the multiple candidates.

5. Relationship to Epipolar Geometry: When H Is the Right Answer

As we saw in the Epipolar Geometry Primer, two-view correspondence in a general 3D scene is described by the Fundamental/Essential Matrix. Homography is a special case of that, and the choice between them is as follows.

Situation Suitable Model Reason
General 3D structure, with translation F (uncalibrated) / E (calibrated) Parallax depends on depth and can't be squeezed into a single plane
The whole scene, or the region of interest, is a single plane H Points on a plane are exactly described by a homography
Camera undergoes pure rotation (pan/tilt only) H With no translation, there's no parallax, so F/E degenerates
Viewing a distant scene, or parallax is minuscule H (practical approximation) Parallax due to depth differences gets buried in pixel noise

The problem is that "many inliers for H" and "the scene truly is planar or the camera is truly purely rotating" can sometimes be hard to distinguish from observations alone. Even in a general 3D scene, a wall or table dominating the field of view can strongly fit a homography. ORB-SLAM's initialization process handles this ambiguity by estimating both H and F in parallel via RANSAC, scoring the goodness-of-fit of each, and automatically selecting the model suited to the scene structure and camera motion. The implementation-level key point is using a score that accounts for the difference in each model's degrees of freedom (an idea related to GRIC), rather than simply comparing inlier counts.

6. Applications: Image Stitching, AR Plane Tracking, and Ground-Plane Estimation

Image stitching (panorama composition) — combining multiple images shot by rotating the camera in place into a single image — is a representative application of homography. The homography between adjacent images is estimated, and each is warped into a common reference frame and blended. When the assumption that the camera is nearly purely rotating breaks down (shooting while walking, or a nearby subject in the scene), parallax produces ghosting and doubled images.

Plane-anchor tracking in AR detects a plane, such as a desk or poster, in the first frame, and by tracking the homography to each subsequent frame, can stably determine the relative pose to that plane, frame by frame. Using the decomposed R,\mathbf{t}/d, you can overlay a virtual object anchored to the plane's coordinate frame without visual inconsistency.

Ground-plane estimation exploits the strong prior knowledge that a road or floor surface is "nearly planar." Ground-plane detection in vehicle cameras or robots uses methods that track the homography between consecutive frames and detect regions that deviate from it (obstacles, non-ground objects). This is an approach that detects a breakdown of geometric consistency, rather than recognizing the object itself.

7. Implementation Example in OpenCV

import cv2 as cv
import numpy as np

orb = cv.ORB_create(nfeatures=3000)
kp1, des1 = orb.detectAndCompute(img1, None)
kp2, des2 = orb.detectAndCompute(img2, None)
matches = cv.BFMatcher(cv.NORM_HAMMING).knnMatch(des1, des2, k=2)
good = [m for m, n in matches if m.distance < 0.75 * n.distance]

p1 = np.float32([kp1[m.queryIdx].pt for m in good]).reshape(-1, 1, 2)
p2 = np.float32([kp2[m.trainIdx].pt for m in good]).reshape(-1, 1, 2)

# threshold is the allowed reprojection error, in pixels. USAC_MAGSAC is also selectable in place of RANSAC.
H, mask = cv.findHomography(p1, p2, method=cv.RANSAC, ransacReprojThreshold=3.0)
inliers = mask.ravel().astype(bool)

# if K is known, decompose into candidate solutions
num_solutions, Rs, ts, ns = cv.decomposeHomographyMat(H, K)

Note that the H returned by findHomography is scale-ambiguous. As with the Essential Matrix in the Epipolar Geometry Primer, the translation vector obtained from decomposition also determines only a direction — its absolute scale must be supplied by some other means (a known plane distance, a stereo baseline, an inertial sensor, and so on).

8. Difficult Conditions

9. Summary

Homography is a framework that exactly represents two limited but practically frequent situations — correspondence on a plane, or a camera undergoing pure rotation — with a single 3\times3 matrix. The DLT method is the least-squares starting point, RANSAC is the countermeasure for outliers, and decomposition is the final stage that extracts the physical rotation, translation, and normal. Above all, what matters is judging when homography is the right model, and when you should switch to the Fundamental/Essential Matrix — get that boundary wrong, and you end up trying to recover depth that doesn't exist, in a scene that's nothing but a plane.

References

#Homography #DLT #RANSAC #Image Stitching #AR #Computer Vision