Techniqueadvanced
Sliding window bundle adjustment
Also called local bundle adjustment, windowed bundle adjustment.
Optimize only the latest keyframes and the points they see, holding older ones fixed or marginalized, to keep visual odometry accurate at bounded cost.
In plain words
Bundle adjustment fixes all camera poses and all 3D points together so that the points project where they were seen. It gives the best answer, but its cost grows with the length of the path, so it cannot run for every frame of a long video. Sliding window bundle adjustment does the same, but only for the last few keyframes and the points they see. When a new keyframe comes in, an old one leaves. The old one can simply be frozen, or its information can be folded into a summary term, called a prior, that pulls the remaining keyframes toward what the old one said about them.
When it applies
- The problem is a chain: frames come in order, and each one shares points mostly with its recent neighbors. This is the case in visual odometry.
- The cost per frame must stay bounded, so the full optimization over all frames is too slow.
- The errors are mostly local: the accuracy of the newest pose depends mostly on the recent frames.
- The window is at most a few dozen keyframes. Within the window the problem is a small bundle adjustment, solved with the reduced camera system and the Schur complement.
The template
WINDOW-STEP(window đ˛ of keyframes, points, prior (Ĥ, bĖ), new keyframe K)- 1
add K and its observations to đ˛ - 2
minimize ÎŖ Ī(|r|²) + prior over the poses of đ˛ and their points ⡠hole: residuals, solver, robust loss Ī, gauge - 3
if đ˛ has more than W keyframes then - 4
m â the keyframe to remove ⡠hole: oldest, farthest, least visible - 5
either fix m (and drop it later), or marginalize m and its points into (Ĥ, bĖ) ⡠hole: fix or marginalize - 6
return đ˛, the points and (Ĥ, bĖ)
The prior from marginalization. Write the Gauss-Newton system of line L2 at the current state as , and split the unknowns into the ones that stay, , and the ones that leave, (the pose of and the points that only still observes). The Gauss-Newton model of the cost, minimized over , is a quadratic in with
This is a theorem about quadratics: for each , the minimum over of is plus a constant. The term , where is the change of the remaining unknowns since the marginalization, is then added to every later cost. For a linear problem with Gaussian noise, the window with the prior gives the same estimate of the remaining unknowns as the full problem; for the nonlinear problem it is an approximation, because the prior is a linearization made once.
Example. Two unknowns have the costs : one measurement says , another says . Remove . The matrix is , so , and the prior is . Check by hand: for fixed , the best is the mean of and , and then . If instead is fixed at , the remaining cost is , twice as confident as it should be, because the uncertainty of is lost. If the measurements of are simply dropped, is not constrained at all.
Classic examples
- The sliding window filter (Sibley, Matthies and Sukhatme, 2010). A window of states is optimized by Gauss-Newton, and old states are marginalized with the Schur complement. With a window of one state it is close to an extended Kalman filter with relinearization; with a window that holds everything it is full batch optimization (see extended Kalman filter).
- Local bundle adjustment in visual odometry. Many feature-based systems optimize the last keyframes and the points they see, and keep the older poses that see these points fixed. The fixed poses hold the gauge and the scale. Fraundorfer and Scaramuzza describe this windowed bundle adjustment as a standard step of visual odometry.
- Keyframe-based visual-inertial odometry (Leutenegger and others, 2015). A window of keyframes and recent frames with reprojection and inertial errors; old states are marginalized, and some observations are dropped first so that the prior does not fill the whole matrix.
- Direct sparse odometry. A window of 7 keyframes with the photometric error, inverse depths and affine brightness terms. Old keyframes are marginalized, and the residuals of other points into the leaving keyframe are dropped. See direct sparse odometry.
Variations
- Fix or marginalize. Fixing old poses is simple and keeps the problem sparse, but it throws away their uncertainty and their information. Marginalization keeps the information as a dense prior on the remaining unknowns.
- Keeping the problem sparse. Marginalizing a pose whose points are also seen by other keyframes connects all of those keyframes with each other in . Systems drop some observations before they marginalize, so that the prior stays small. Dropping is an approximation: the dropped observations are lost.
- Consistency. If later Gauss-Newton steps evaluate the Jacobians of the variables in the prior at new values, the prior and the new terms can claim information that the data do not have, for example about the gauge. The First Estimate Jacobians used by DSO evaluate those Jacobians at the values of the marginalization.
- Solver. Gauss-Newton or Levenberg-Marquardt, with a robust loss such as the Huber function, and the Schur complement over the points.
- Window contents. Keyframes only, or keyframes plus the last few frames; a fixed number of keyframes, or a fixed time span.
Pitfalls
- Gauge. Inside the window the problem has the same free motion as full bundle adjustment: 6 degrees of freedom for a stereo or inertial system and 7 for one camera. Hold some poses fixed, or rely on a prior that fixes them, or the matrix is singular.
- Overconfidence. Fixing old poses, or relinearizing the prior variables, makes the estimate more confident than it should be. It can then resist corrections and drift in a consistent direction.
- Fill-in. Marginalizing a pose with many shared points makes dense over all keyframes that saw those points. Plan which observations to drop.
- Bad starts. The window is solved by a local method. A new keyframe with a bad pose, or new points with wrong depths, can pull the window into a wrong minimum. Use a robust loss and check the result.
- Window size. A short window gives more drift and less accuracy; a long window costs for the reduced system per iteration. The size is a trade-off, tuned by experiment.
Exercises
- In the example, add a third measurement with the cost after is marginalized. Find the estimate of with the prior, and check that the full problem over and gives the same . (Answer: minimize , so . The full problem gives the same, because all costs are linear least squares.)
- A window has keyframes and points, and each point is seen by every keyframe. Show that one Gauss-Newton iteration with the Schur complement over the points costs , and compare with a dense solve, .
- Keyframes and share no point. Keyframe sees a point that keyframe also sees, and a point that keyframe also sees. Which new nonzero blocks does get if you marginalize alone, and which if you marginalize , and ? (Answer: marginalizing a variable connects all its neighbors. With alone, and become connected. With , and , keyframes and become connected.)
References
- Gabe Sibley, Larry Matthies and Gaurav Sukhatme, Sliding window filters and their application to planetary landing, Journal of Field Robotics 27(5), 2010, 587-608, the sliding window filter: a window of states optimized by Gauss-Newton, with old states removed by marginalization through the Schur complement
- Friedrich Fraundorfer and Davide Scaramuzza, Visual odometry, Part II: matching, robustness, optimization, and applications, IEEE Robotics and Automation Magazine 19(2), 2012, 78-90, windowed bundle adjustment over the last frames for visual odometry
- Stefan Leutenegger, Simon Lynen, Michael Bosse, Roland Siegwart and Paul Furgale, Keyframe-based visual-inertial odometry using nonlinear optimization, International Journal of Robotics Research 34(3), 2015, 314-334, the window of keyframes and recent frames, and the marginalization of old states into a linear prior, with observations dropped to keep the problem sparse
- Jakob Engel, Vladlen Koltun and Daniel Cremers, Direct sparse odometry, IEEE Transactions on Pattern Analysis and Machine Intelligence 40(3), 2018, 611-625, Section 2 (the windowed optimization, the marginalization with the Schur complement and the First Estimate Jacobians)
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W0 stub |
|
Tag 902D1T Edit this page History Report an error Markdown