Skip to content

Homography and RANSAC

Estimate a projective mapping between two views of a plane, rejecting inconsistent point matches.

Try it on your image ↓

VISUAL WALKTHROUGHGeometry
REFERENCE INPUTTentative correspondences

Eight tentative matches include two inconsistent pairs, shown in orange.

RESULTRecover the projective plane

The accepted mapping bends a rectangular grid into perspective. Every grid intersection uses the same projective transform as the inlier points.

STEP 03 / 03

Refine the mapping using the accepted correspondences.

Illustrative example. The stages explain the method; they are not a live OpenCV execution.

Try it on an image

YOUR IMAGE · REAL OPENCV

Experiment at pixel level

Open full lab ↗

Map the four image corners to a trapezoid and warp the image. This experiment isolates projective warping; correspondence fitting is a separate step.

The engine loads on your first run. Your images stay in this browser.

Input448 × 320
OutputWaiting for a result

Scroll over either image to zoom at the pointer. Use the scrollbars to pan both views over the same relative area. Zoom is relative to the input; pixel coordinates belong to each image. Warps can change scene correspondence.

Pixel inspector RGBA · native values · matched scale · 9 × 9 output pixels
Hover to inspect. Click to pin a pixel.
Input
Select a pixel

Output
Select a pixel

Sample models and licenses

When to use it

Locate a poster, rectify a document, or align a planar surface seen from a new viewpoint.

How it works

  1. 01Propose a homography from a small sample of correspondences.
  2. 02Measure reprojection errors and mark the agreeing matches as inliers.
  3. 03Refine the mapping using the accepted correspondences.

s[x′,y′,1]ᵀ = H[x,y,1]ᵀ

What to tune

Choose a robust estimation method and reprojection threshold in pixel units. Inspect the inlier mask, spatial coverage and reprojection error.

Where it breaks down

Parallax from a 3D scene cannot generally be explained by one homography. Collinear points and repeated texture make estimation unstable.

TypeScript API

Open an entry for its exact overloads, parameter descriptions, result ownership and pinned upstream source.

All of these calls execute on the CPU. Native objects need explicit disposal. See matrices and ownership and build compatibility.