Gather hundreds of strangers' photos of the same landmark taken at a tourist spot, and recover a 3D model of that building along with every shooting position — that's Structure from Motion (SfM). From a set of images whose shooting order, relative camera positions, and even which lens was used are all unknown in advance, it jointly recovers a geometrically consistent 3D point cloud and camera poses. Where Visual-SLAM and VO/VIO track a robot or camera's "current" position in real time, SfM is mostly run offline, prioritizing accuracy to build out an entire scene. This article works through SfM's internal structure from the ground up, centered on this distinction.

0. 30-Second Summary

1. What Does SfM Take as Input, and What Does It Output?

The input is a set of images \{I_1,\dots,I_N\} whose shooting order and relative positions are unknown. Each image can even have been taken with a different camera, a different lens, and at a different time. The output consists of three things:

Where the Camera Calibration Primer recovers a single camera's intrinsic parameters from a fixed calibration pattern, SfM is a larger inverse problem: simultaneously recovering the intrinsic and extrinsic parameters of many uncalibrated or partially-calibrated cameras, along with scene structure, purely from geometric constraints between corresponding points. If EXIF metadata includes a focal length, it's used as an initial value, but final accuracy depends on the geometric constraints from the images themselves.

2. The Basic Pipeline

The basic SfM pipeline A diagram showing the flow from an unaligned set of images, through feature extraction, matching, and geometric verification, to recovering pose and structure via either Incremental SfM or Global SfM, and finally refining with Bundle Adjustment. Image set Feature extractionexhaustive/nearby matching Geometric verificationF/E/H + RANSAC Incremental SfMinitial pair → add via PnP→ triangulate Global SfMrotation averaging → translation averaging→ triangulate all points BundleAdjustment

The earlier steps — feature extraction, matching, and geometric verification — are exactly the same elemental techniques covered in the Feature Detection Primer and the Epipolar Geometry Primer. SfM-specific design decisions come into play at the stage after each image-pair relationship has been found: how to assemble every image and every point into one consistent coordinate frame with no contradictions — which is where the two strategies of Incremental SfM and Global SfM diverge.

3. Incremental SfM: Adding Cameras One by One

Incremental SfM starts by choosing an initial image pair with sufficient parallax and enough correspondences, and building the first two-view reconstruction by estimating the Essential/Fundamental Matrix from epipolar geometry. From there, it repeats the following:

  1. Choose a new image that already has 2D correspondences to registered 3D points, and find that image's pose via PnP.
  2. Triangulate points not yet reconstructed in 3D, from correspondences between the new image and the existing ones.
  3. Refine pose and structure with local or global bundle adjustment every so many images.
  4. Return to step 1 until every image has been processed, or no more images can be added.

This approach, widely used since Snavely et al.'s Photo Tourism (2006), is also adopted by COLMAP's standard pipeline as Incremental SfM. Because it only increases a small number of unknowns at a time, sequentially, it's a robust implementation, and it's easy to detect and exclude a bad image pair. On the other hand, because poses are stacked up one image at a time, small errors early on propagate to later images, and datasets containing large loops (a group of images revisiting the same place) tend to accumulate drift. Periodic bundle adjustment, together with revisit detection equivalent to loop closure, is the key to keeping this accumulated error in check.

4. Global SfM: Solving All Pairwise Relationships at Once

Global SfM doesn't register images sequentially — it first finds the relative pose (R_{ij},\mathbf{t}_{ij}/\|\mathbf{t}_{ij}\|) for every (or a selected subset of) image pair. It then jointly estimates the whole graph in two stages.

Rotation averaging finds a globally minimally-inconsistent set of camera rotations \{R_i\} from the set of pairwise relative rotations R_{ij}. A commonly used error metric uses the logarithm map on the Lie group SO(3):

\min_{\{R_i\}}\sum_{(i,j)\in\mathcal E}\rho\left(\left\|\mathrm{Log}\left(R_{ij}^\mathsf{T}R_i^\mathsf{T}R_j\right)\right\|^2\right)

\rho is a robust loss, which suppresses the influence of wrong relative poses acting as outliers.

Translation averaging, once rotations are fixed, finds camera positions \{\mathbf{t}_i\} from the set of relative translation directions \mathbf{t}_{ij}. Since a monocular relative translation only gives a direction (see the scale ambiguity discussed in the Epipolar Geometry Primer), you need to solve for a consistent configuration from many pairwise directional constraints — approaches like 1DSfM, which include outlier removal, have been proposed for this.

Because Global SfM uses information from every image simultaneously, it's, in principle, less prone to the sequential drift that Incremental SfM sees, and it's also easier to parallelize computationally. But if outliers are mixed into individual relative poses, the whole global solution gets distorted unless they're detected and excluded at the averaging stage. Moulon et al.'s work (ICCV 2013) is a representative example that greatly improved Global SfM's practicality, combining robust rotation averaging with translation-direction estimation using the trifocal tensor.

Aspect Incremental SfM Global SfM
How reconstruction proceeds Adds one image at a time from an initial pair Solves all pairwise relationships first, then optimizes jointly
Resistance to drift Prone to sequential propagation and accumulated error Little accumulated error since it's globally optimal
Resistance to outliers Easy to detect and remove individually when adding an image Outlier removal before averaging determines accuracy
Computational cost Sequential in the number of images, tends to get heavy at large scale Parallelizable, but requires global optimization for averaging
Implementation difficulty Plenty of implementation examples, easy to tune for robustness Theory and implementation of rotation/translation averaging are more difficult
Representative examples Bundler, COLMAP (default), VisualSFM openMVG (Global SfM pipeline), Theia

In practice, rather than treating the two as a strict either/or, hybrid designs are also being researched — building a rough global pose with Global SfM and then refining it incrementally, or using only the high-confidence pairs in a Global fashion and adding the rest incrementally.

5. Triangulation and Track Management

Once poses are found for a group of images, triangulating corresponding points to obtain 3D points is itself an extension of the basic two-view geometry operation. What's SfM-specific is how to manage the correspondence, called a "track," when the same physical point is observed across three or more images.

6. The Bridge to Bundle Adjustment

The pose and structure obtained from linear triangulation or sequential PnP are, at best, initial values. Simultaneously minimizing the reprojection error over all images —

\min_{\{K_i,R_i,\mathbf{t}_i,\mathbf{X}_j\}} \sum_{(i,j)\in\mathcal{O}}\rho\left(\left\|\pi\left(K_i(R_i\mathbf{X}_j+\mathbf{t}_i)\right)-\mathbf{u}_{ij}\right\|^2\right)

— is Bundle Adjustment, and it's what ultimately determines SfM's final accuracy. Why this optimization has a sparse structure, and why the Schur complement makes it solvable even at large scale, are computational questions covered in depth in the Bundle Adjustment Primer. What's worth keeping in mind here is the difference in how it's used: Incremental SfM interleaves local bundle adjustment every few images added, while Global SfM runs a single full bundle adjustment once every global pose is in place.

7. Differences and Commonalities With Visual-SLAM

SfM and Visual-SLAM share the same mathematical tools — feature matching, epipolar geometry, PnP, and bundle adjustment. The difference lies in their goals and constraints.

Aspect Structure from Motion Visual-SLAM
Processing style Mostly offline batch processing Online, real-time sequential processing
Input ordering Can be unordered (any order, multiple cameras mixed in is fine) Assumes chronologically continuous frames
Primary goal High-quality 3D reconstruction prioritizing accuracy and completeness Maintaining current self-position in real time
Optimization scope Global bundle adjustment over all images is possible Local/global optimization limited to keyframes, under strong compute-budget constraints
Handling revisits Can verify every pair offline Must detect and correct loop closure online
Representative implementations COLMAP, openMVG, Bundler ORB-SLAM family, VINS family

In practice, combinations like using a high-precision 3D map built by SfM as SLAM's initial map or scale reference, or post-processing SLAM's keyframe trajectory offline with SfM to boost accuracy, are also common. The two aren't competing technologies — they complement each other across the offline/online time axis.

8. Representative Implementations

When choosing a library, "newer means more accurate" isn't the right criterion — judge based on the number of images you're handling, GPU/CPU resources, the reliability of EXIF focal length, the matching strategy (exhaustive/sequential/vocabulary tree), and whether you want a single consistent pipeline all the way through MVS and texture generation.

9. Difficult Conditions and Common Failure Cases

10. Practical Choices

11. Summary

Structure from Motion is a technology that jointly recovers camera poses and 3D structure, via feature matching and geometric verification, from an unordered set of images, using either the Incremental SfM or Global SfM strategy. Incremental is robust but prone to drift, and Global resists drift but is sensitive to outliers — a symmetric tradeoff. Under either strategy, final accuracy is carried by bundle adjustment, which connects directly onward to Visual-SLAM, its sibling technology operating on a different time axis, and to Multi-View Stereo, a dense-reconstruction technology.

References

#Structure from Motion #SfM #COLMAP #3D Reconstruction #Bundle Adjustment #Computer Vision