Open Source Robotics

A curated collection of high-quality open source robotics projects, tools, and software to propel the robotics community forward.

Homography

  • Also called: projective transformation, planar homography, collineation
  • Category: Foundations & spatial maths › Frames & transforms
  • Tags: computer-vision, projective-geometry, calibration, spatial-math, image-alignment

A 3×3 projective transformation that maps points on one plane to another, such as a flat surface seen by two cameras, or two images taken by a camera that only rotates.

Definition

A homography is an invertible linear map between two projective planes. In homogeneous coordinates a point x in one image maps to x′ ≅ Hx in the other, where H is a 3×3 matrix and ≅ means equal up to scale. Because the overall scale of H does not matter, it has eight degrees of freedom. A homography preserves straight lines but not parallelism, lengths or angles, which is how it can turn a rectangle seen at an angle into its front-on view. Affine and similarity transforms are special cases of it.

Two situations give an exact homography between camera images: when all the observed points lie on a single plane, and when the camera rotates about its optical center without translating, in which case H = K R K⁻¹ with K the intrinsic matrix and R the rotation. A plane can also be related to its own metric coordinates in the image, with H = K[r₁ r₂ t] built from the first two columns of the rotation and the translation, which is the basis of Zhang's widely used camera calibration method with a planar target. For a general 3D scene viewed from two positions, points off the plane show parallax and no single homography fits them.

H is estimated from at least four point correspondences, no three of them collinear, with the direct linear transform on normalized coordinates, usually inside RANSAC to reject bad matches, and then refined by minimizing reprojection error. Lens distortion must be removed first, because it is not projective. For a calibrated camera, a homography can be decomposed into a rotation, a translation scaled by the distance to the plane, and the plane normal, although the decomposition gives up to four candidate solutions that must be disambiguated. Where camera intrinsics describe how a single camera projects 3D points and perspective-n-point recovers a camera pose from known 3D points, a homography is purely a mapping between two planes, and it is often a first step toward either.

Why it matters

Homographies are the standard tool whenever a camera looks at a flat surface: table and floor coordinates, fiducial markers, calibration targets, image stitching and bird's-eye views. They are cheap to estimate and easy to check, and knowing when the planar or pure-rotation assumption breaks avoids subtle errors.

Key applications

  • Top-down rectification of tables, floors and work surfaces
  • Camera calibration from planar targets
  • Pose estimation from planar fiducial markers
  • Image stitching and panoramas from rotating cameras
  • Inverse perspective mapping for bird's-eye views of roads
  • Homography-based visual servoing on planar targets

In practice

A robot painting on a flat canvas needs to know where its strokes actually land. The team has the robot paint a grid of dots at known commanded positions, photographs the canvas with a fixed camera, removes lens distortion and detects the dot centers. Fitting a homography with RANSAC between the detected centers and the commanded positions gives a mapping from camera pixels to canvas coordinates, which warps every new photo into a top-down canvas view that can be compared pixel by pixel with the planned image, and shows where and by how much the robot's strokes deviate from their targets. If residuals stay large near the edges, the canvas is not flat or distortion was not fully removed, and a single homography is not enough.

Common misconceptions

  • A homography can align any two images of a scene — it is exact only for planar scenes or a purely rotating camera; general 3D scenes viewed with camera translation show parallax
  • A homography is the same as an affine transform — affine maps keep parallel lines parallel, while a homography can make them converge
  • Raw pixel coordinates are fine for estimation — lens distortion must be removed and coordinates normalized for an accurate, well-conditioned estimate
  • Decomposing a homography gives a unique pose — it yields up to four candidate solutions, and extra constraints are needed to pick the physical one

Who should know this

  • Computer vision and calibration engineers
  • Developers of camera-guided manipulation on flat surfaces
  • Autonomous driving perception engineers
  • Robotics students learning projective geometry

Related technologies

  • OpenCV findHomography
  • Direct Linear Transform
  • AprilTag
  • Image Stitching
  • Inverse Perspective Mapping

Related terms

  • Camera Intrinsics
  • Perspective-n-Point
  • RANSAC
  • Extrinsic Calibration
  • Bird's-Eye View
  • Transform

Related projects

  • pySLAM: Hybrid Python/C++ visual SLAM pipeline with classic and deep-learning front-ends
  • AprilTag: The standard visual fiducial marker system for robot localization and pose estimation
  • MRPT: Comprehensive C++ toolkit for mobile robotics, SLAM, and sensor-based navigation
  • image_pipeline: The standard ROS camera stack: calibration, rectification, stereo and depth
  • PULP-Dronet: Visual navigation for nano-drones with CNN inference onboard a PULP processor.
  • OpenWeedLocator: Low-cost Raspberry Pi weed detector that uses computer vision for precision spot spraying

Videos

  • ENB339 lecture 9: Image geometry and planar homography: Peter Corke
  • Computing Homography | Image Stitching: First Principles of Computer Vision

This website requires JavaScript to function properly. Please enable JavaScript to explore our collection of open source robotics projects.