DL0184 Structure from Motion with Deep Learning

What is Structure from Motion (SfM), and how do deep learning models such as DUSt3R, MASt3R, and VGGT replace traditional keypoint matching and bundle adjustment pipelines?

Answer

Structure from Motion is the problem of recovering both the 3D geometry of a scene (structure) and the camera poses that observed it (motion) from a set of unordered 2D images, up to a global similarity transform. The classical solution is a long pipeline of separately engineered stages: detect keypoints, match descriptors across image pairs, reject outliers with RANSAC on an epipolar constraint, register cameras incrementally with PnP and triangulation, and finally run bundle adjustment, a sparse nonlinear least-squares refinement of all cameras and points against reprojection error. The learned replacements collapse that chain into a regression problem. DUSt3R takes two uncalibrated images and directly predicts dense pointmaps, one 3D point per pixel for both images expressed in the coordinate frame of the first camera, so depth, intrinsics, and relative pose fall out of the output instead of being estimated by geometry. MASt3R adds a dense local-feature head so the same network also emits pixel-accurate correspondences, and VGGT generalizes the idea to many views at once, returning cameras, depth maps, pointmaps, and point tracks for tens or hundreds of frames in a single forward pass with no optimization loop at inference time.

(1) What SfM Actually Solves: recover camera intrinsics and extrinsics plus scene points from images alone, with scale unobservable without an external reference. Everything downstream (MVS, SLAM, NeRF, Gaussian splatting) depends on those poses.
(2) The Classical Chain Is Brittle At Its Joints: keypoints → matching → RANSAC → incremental registration → bundle adjustment. Each stage discards information, and a failure at the front (textureless walls, repeated facades, tiny baselines) cannot be recovered later.
(3) Pointmap Regression Replaces Triangulation: DUSt3R regresses X^{1,1} and X^{2,1} in one shared frame, so the network solves calibration, depth, and relative pose jointly instead of chaining three estimators.
(4) MASt3R Restores Pixel-Level Precision: a 24-dimensional dense descriptor head trained with an InfoNCE matching loss plus fast reciprocal matching gives sub-pixel correspondences that pure 3D regression blurs, and MASt3R-SfM builds a full reconstruction pipeline on top with no RANSAC.
(5) VGGT Removes The Optimizer: alternating frame-wise and global self-attention over all views, with camera and register tokens, yields cameras, depth, pointmaps, and tracks feed-forward in seconds. Bundle adjustment becomes an optional post-hoc refinement rather than the core algorithm.
(6) The Trade-off Is Priors Versus Guarantees: learned models succeed where geometry is degenerate (near-zero baseline, no texture, minimal overlap) but their accuracy is bounded by training data, output is up to scale, and global attention is quadratic in total token count.

Three stacked pipeline rows compared: the classical row runs keypoint detection, pairwise matching over N(N-1)/2 pairs, RANSAC epipolar verification, incremental PnP with triangulation, and bundle adjustment; the DUSt3R and MASt3R row runs an image pair through a shared ViT encoder, two intertwined decoders, pointmap and confidence heads, and a global alignment of pairwise pointmaps in 3D; the VGGT row runs N images through DINOv2 patch tokens with camera tokens, alternating frame-wise and global attention, prediction heads for cameras depth pointmaps and tracks, and an optional bundle adjustment refinement

Figure 1: The same task, three levels of learned integration. The classical row has five hand-designed stages with five distinct failure modes; DUSt3R keeps only a lightweight 3D global alignment over pairwise predictions; VGGT keeps nothing optimization-based at all, and bundle adjustment survives only as an optional refinement.

The conceptual pivot is the pointmap. A depth map is defined only relative to its own camera, so combining two of them requires knowing intrinsics and relative pose first. A pointmap for image v expressed in the frame of camera 1, written X^{v,1}, already lives in a shared space. Once both images are mapped into that space, the classical unknowns are read out rather than solved for: focal length comes from fitting a pinhole model to the ray field of X^{1,1}, relative pose comes from Procrustes alignment or PnP between X^{2,1} and camera 2’s own rays, and correspondence becomes a nearest-neighbour query in 3D rather than a descriptor comparison. That is why DUSt3R needs neither intrinsics nor an initial pose guess, and why it degrades gracefully instead of failing outright when overlap is small.

Diagram showing two pixel grids for images I1 and I2 on the left feeding a network box labelled F of I1 and I2, whose output on the right is a single 3D point cloud drawn in the coordinate frame of camera 1: blue points come from the pixels of I1 and orange points from the pixels of I2, they overlap on a shared floor and wall surface, the camera-1 axes sit at the origin, and a dashed camera-2 frustum marks the pose recovered from the second pointmap rather than supplied as input

Figure 2: Both pointmaps are regressed in one coordinate frame, the frame of camera 1. Because pixels of I^2 land directly in that frame, the relative pose is implied by the output rather than required as input, and a match between the two images is just a pair of nearby 3D points.

Classical Objective (Bundle Adjustment):
E_{BA} = \sum_{(i,j) \in \mathcal{V}} \| \pi_i(X_j) - x_{ij} \|^2
\pi_i(X) = K_i (R_i X + t_i)

Where:

  • E_{BA} is the total reprojection error, minimized over cameras and points jointly by Levenberg-Marquardt with a Schur-complement trick on the sparse normal equations.
  • X_j \in \mathbb{R}^{3} is a triangulated scene point and x_{ij} the 2D keypoint where camera i observed it.
  • \mathcal{V} is the visibility set, that is the surviving inlier matches; every match RANSAC rejected is simply absent, so the objective can only refine, never repair, the front end.
  • K_i, R_i, t_i are the intrinsics, rotation, and translation of camera i, all unknown and all coupled through the same residuals.

Learned Objective (DUSt3R Pointmap Regression):
F(I^1, I^2) = (X^{1,1}, X^{2,1}, C^1, C^2)
X^{v,1} \in \mathbb{R}^{H \times W \times 3}
\ell_i = \| X_i / z - \bar{X}_i / \bar{z} \|
\mathcal{L} = \sum_i C_i \ell_i - \alpha \log C_i

Where:

  • F is the transformer that consumes the raw pair with no camera parameters, built from a shared ViT encoder and two decoders that exchange information by cross-attention.
  • X^{v,1} is the pointmap of view v in the frame of camera 1, so X^{2,1} is what encodes the relative pose, and C^v is the per-pixel confidence.
  • i indexes valid pixels, \bar{X}_i is the ground-truth point, and z, \bar{z} are scale normalizers (mean distance to the origin) that make the loss scale-invariant.
  • \alpha > 0 weights the log-confidence regularizer, letting the network downweight sky, transparent surfaces, and non-overlapping regions instead of hallucinating them with full certainty.
  • Multi-view reconstruction then optimizes a 3D alignment loss over a graph of pairwise predictions, not a reprojection loss, which is why the global step takes seconds rather than the minutes a full bundle adjustment needs.

VGGT changes the scaling story. Instead of predicting pairs and stitching them, it patchifies all N frames with a DINOv2 backbone, appends per-frame camera tokens and register tokens, and then alternates two attention types for 24 blocks: frame-wise attention that reasons within one image, and global attention that reasons across every token of every image. The first frame’s camera token is given a distinct embedding, which is how the network fixes the output coordinate frame to camera 1 without any positional trick. Heads then decode a 9-dimensional camera parametrization (rotation quaternion, translation, field of view), a DPT depth map, a pointmap, and dense tracking features, all supervised directly.

Feed-Forward Multi-View Prediction (VGGT):
G(\{I_i\}_{i=1}^{N}) = \{(g_i, D_i, P_i, T_i)\}
g_i \in \mathbb{R}^{9}
P = (518/14)^2 = 1369
N P = 32 \times 1369 = 43808
\mathrm{global} : O(N^2 P^2 d)
\mathrm{frame} : O(N P^2 d)

Where:

  • g_i holds camera i‘s pose and intrinsics, D_i its depth map, P_i its pointmap, and T_i its tracking features, all produced in one forward pass.
  • P is the token count per frame at 518-pixel input with 14-pixel patches, and N P the total sequence length that global attention must span.
  • d is the model width; alternating the cheap frame-wise term with the expensive global term is what keeps hundreds of views tractable, and the quadratic global term is what eventually exhausts GPU memory.
Log-log chart of reconstruction latency in seconds against number of input views for four approaches: classical incremental SfM with exhaustive matching and bundle adjustment rising steeply as N squared, DUSt3R with exhaustive pairwise inference plus global alignment also rising as N squared, MASt3R-SfM with a retrieval-sparsified image graph rising close to linearly, and VGGT feed-forward inference lowest of all but ending at about 200 views where an annotation marks the single-GPU memory wall

Figure 3: Feed-forward inference wins by orders of magnitude at small and medium view counts, but two quadratic terms remain in the field: exhaustive pairing (which retrieval-based graphs in MASt3R-SfM sparsify to roughly kN pairs) and global attention (which sets VGGT’s memory ceiling). VGGT timings follow the published single-GPU measurements; the other curves are illustrative scaling.

PropertyClassical SfM (COLMAP-style)DUSt3R / MASt3RVGGT
Required inputImages, ideally with EXIF focal priors and good overlapAn uncalibrated image pair, no intrinsics, no pose initOne to hundreds of uncalibrated, unordered images
Core computationDescriptor matching, RANSAC, and nonlinear least squaresPairwise transformer inference plus a 3D global alignmentA single forward pass of alternating frame and global attention
Correspondence sourceExplicit keypoint descriptors with geometric verificationNearest neighbours in 3D, plus a dense descriptor head in MASt3RA tracking head over global features, no matching stage
Scaling in viewsQuadratic pairing, plus repeated bundle adjustment as views registerQuadratic in pairs unless a retrieval graph sparsifies itQuadratic in total tokens, memory-bound rather than time-bound
Dominant failure modeHard failure on textureless, repetitive, or low-baseline inputDrift when many pairwise predictions must be fusedOut-of-distribution scenes and a hard memory ceiling on view count
Metric scaleUp to scale unless a known baseline or GPS is suppliedUp to scale by construction (scale-normalized loss)Up to scale, with scale partly inherited from training priors

Login to view more content


Log in to track your progress

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *