CodeSLAM

Bloesch 2018 · Paper

One-line summary — CodeSLAM (CVPR 2018) represents each keyframe’s dense depth map as a small latent code from an image-conditioned variational autoencoder, making dense geometry compact enough to optimize jointly with camera poses.

Problem

The representation of geometry in real-time 3D perception remains a critical open issue. Dense maps capture complete surface shape but their high dimensionality makes them costly to store and process, and unsuitable for rigorous probabilistic inference; sparse feature-based representations allow joint probabilistic inference of structure and motion, but capture only partial scene information and are mainly useful for localisation. Yet natural scene geometry is highly ordered — neighbouring depth values are strongly correlated — so a dense representation should not actually need a large number of parameters. CodeSLAM seeks a representation that is dense yet compact and optimisable: full surface geometry in few enough parameters to sit inside joint probabilistic optimization.

Method & architecture

Intensity-conditioned depth auto-encoding. A variational autoencoder compresses a keyframe’s depth map, but conditioned on the intensity image so the code only retains what the image alone cannot predict:

D=D(I,c)D = D(I, \boldsymbol{c})

where II is the intensity image and c\boldsymbol{c} the latent code (128-D in the reference network). A U-Net decomposes II into multi-scale features that are concatenated into the depth encoder/decoder at matching resolutions; the variational bottleneck (two 512-channel fully connected layers, KL-regularised) keeps the code-to-depth mapping smooth. Setting c=0\boldsymbol{c}=0 yields the most likely single-view depth prediction D(I,0)D(I,0).

Uncertainty-aware training. The network predicts a per-pixel mean μ\mu and uncertainty bb, trained with the negative log-likelihood of a Laplace distribution over observed depth d~\tilde{d} at four pyramid levels:

logp(d~μ,b)=d~μb+log(b)-\log p(\tilde{d}\mid\mu,b) = \frac{|\tilde{d}-\mu|}{b} + \log(b)

Depths are re-parametrised as proximity p=a/(d+a)p = a/(d+a) (average depth aa), mapping [0,][0,\infty] to [0,1][0,1]. Training uses SceneNet RGB-D with ADAM (lr 10410610^{-4}\to10^{-6}, 6 epochs). A linear decoder is used so the Jacobian D/c\partial D/\partial\boldsymbol{c} (otherwise up to ~1 s to evaluate) can be pre-computed once per keyframe.

Dense warping and joint optimization. With pose TAB=(RAB,BtAB)\boldsymbol{T}_A^B=(\boldsymbol{R}_A^B, {}_B\boldsymbol{t}_A^B) between views, each pixel u\boldsymbol{u} warps as

w(u,cA,TAB)=π(RABπ1(u,DA[u])+BtAB)w(\boldsymbol{u},\boldsymbol{c}_{A},\boldsymbol{T}_{A}^{B})=\pi\big(\boldsymbol{R}_{A}^{B}\,\pi^{-1}(\boldsymbol{u},D_{A}[\boldsymbol{u}])+{}_{B}\boldsymbol{t}_{A}^{B}\big)

with π,π1\pi,\pi^{-1} the projection/inverse-projection operators and DA[u]D_A[\boldsymbol{u}] a pixel lookup. An N-frame structure-from-motion back-end assigns every frame an unknown code (init 0) and pose (init identity) and minimizes photometric and geometric residuals over all overlapping pairs,

Epho=Lp(IA[u]IB[w(u,cA,TAB)]),Egeo=Lg(DA[u]DB[w(u,cA,TAB)])E_{\mathrm{pho}} = L_{p}\big(I_{A}[\boldsymbol{u}]-I_{B}[w(\boldsymbol{u},\boldsymbol{c}_{A},\boldsymbol{T}_{A}^{B})]\big), \qquad E_{\mathrm{geo}} = L_{g}\big(D_{A}[\boldsymbol{u}]-D_{B}[w(\boldsymbol{u},\boldsymbol{c}_{A},\boldsymbol{T}_{A}^{B})]\big)

where the losses Lp,LgL_p, L_g mask invalid correspondences, weight the two error types, apply Huber weighting, and down-weight slanted or occluded pixels. A damped Gauss–Newton solver updates all codes and poses. Tracking aligns the current frame to the last keyframe with the same machinery (photometric cost only, coarse-to-fine); the full PTAM-style system alternates tracking and mapping, marginalising old keyframes into a linear prior.

Results

Why it matters for SLAM

CodeSLAM answered a question that had blocked dense SLAM since DTAM: how to include dense geometry inside joint probabilistic optimization instead of fusing it after the fact. Its core lesson — put a learned low-dimensional parameterization between the optimizer and the dense map — is one of the most influential ideas in learned SLAM (CVPR 2018 best paper honourable mention), spawning SceneCode, DeepFactors, NodeSLAM and CodeMapping, and conceptually anticipating neural-implicit SLAM (iMAP, NICE-SLAM) where network parameters again serve as compact optimizable geometry.