Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

SfmLevenbergMarquardt

The SfmLevenbergMarquardtOptimizer class is an easy entry point for structure from motion. Together with SfmLevenbergMarquardtParams, it runs CPU Levenberg–Marquardt and lets users choose whether landmarks are eliminated through a Schur complement.

Open In Colab

Build a small structure-from-motion problem

We first create two cameras, four landmarks, and their image measurements. The graph stores poses, points, and a shared calibration as separate variables. Priors fix the gauge, while deliberately perturbed initial values give the optimizer something to improve.

Configure and run the optimizer

SfmLevenbergMarquardtParams extends the usual LM parameters with a landmark-elimination mode. Here we select Schur elimination, ask CreateReducedOrdering() for the non-landmark ordering expected by that mode, and pass the parameters to SfmLevenbergMarquardtOptimizer. The final graph error confirms that the optimization improved the initial estimate.

reduced variables: 7
error: 845.7689790759512 -> 3.236514773600142e-27

When to use it

Use SfmLevenbergMarquardtOptimizer as a direct entry point for bundle adjustment when the graph contains explicit Point3 or Unit3 landmarks. Full mode solves the joint system; Schur mode removes those landmarks before solving the reduced camera system. Shared calibration remains in the reduced system.

SfmData can build standard SFM graphs, and GeneralSFMFactor explains the reprojection factor used in this example.

Source

SfmLevenbergMarquardt.h

AI assistance caveat

AI was used to help draft this documentation, and inaccuracies could be present.