---
title: "DSAC — Differentiable RANSAC for Camera Localization (2017)"
description: "DSAC makes RANSAC trainable by sampling a camera pose from scored candidates and minimizing the expected error after refinement."
canonical: "https://research.elamur.ai/free/en/papers/brachmann-2017-dsac-differentiable-ransac-camera-localization/"
---
Elamur: [Mova](https://md.mova.elamur.ai/free/en/) · [Parse](https://mova.elamur.ai/free/en/parse/) · [Dictionary](https://md.dictionary.elamur.ai/free/en/) · [Translate](https://md.translate.elamur.ai/free/en/) · **Research** · [Gali](https://md.gali.elamur.ai/free/en/) · [MCP](https://mcp.elamur.ai/) · [Locations](https://md.locations.elamur.ai/free/en/) · [Weather](https://md.weather.elamur.ai/free/en/) · [Constitution](https://md.constitution.elamur.ai/)

[Elamur Research](https://md.research.elamur.ai/free/en/) · [this page in HTML](https://research.elamur.ai/free/en/papers/brachmann-2017-dsac-differentiable-ransac-camera-localization/)

[Elamur Research](https://md.research.elamur.ai/free/en/) / [papers](https://md.research.elamur.ai/free/en/papers/) / [2017](https://md.research.elamur.ai/free/en/papers/2017/) / DSAC — Differentiable RANSAC for Camera Localization

# DSAC — Differentiable RANSAC for Camera Localization

Paper · 2017 · Eric Brachmann, Alexander Krull, Sebastian Nowozin et al.

**Authors:** [Eric Brachmann](https://md.research.elamur.ai/free/en/authors/eric-brachmann/), [Alexander Krull](https://md.research.elamur.ai/free/en/authors/alexander-krull/), [Sebastian Nowozin](https://md.research.elamur.ai/free/en/authors/sebastian-nowozin/), [Jamie Shotton](https://md.research.elamur.ai/free/en/authors/jamie-shotton/), [Frank Michel](https://md.research.elamur.ai/free/en/authors/frank-michel/), [Stefan Gumhold](https://md.research.elamur.ai/free/en/authors/stefan-gumhold/) and [Carsten Rother](https://md.research.elamur.ai/free/en/authors/carsten-rother/) · **Year:** 2017 · **Venue:** IEEE Computer Society Conference on Computer Vision and Pattern Recognition/Proceedings - IEEE Computer Society Conference on Computer Vision and Pattern Recognition/Proceedings · **Licence:** [arXiv — non-exclusive license to distribute](http://arxiv.org/licenses/nonexclusive-distrib/1.0/)

[**607** citations OpenAlex, 2026-10-14](https://openalex.org/works?filter=cites:W2556455135|W2950681848) · [IEEE Computer Society Conference on Computer Vision and Pattern Recognition/Proceedings - IEEE Computer Society Conference on Computer Vision and Pattern Recognition/Proceedings](https://openalex.org/S4210176548) · [licence](http://arxiv.org/licenses/nonexclusive-distrib/1.0/)

- [PDF](https://arxiv.org/pdf/1611.05705)
- [DOI 10.1109/cvpr.2017.267](https://doi.org/10.1109/cvpr.2017.267)
- [arXiv 1611.05705](https://arxiv.org/abs/1611.05705)
- [OpenAlex](https://openalex.org/W2556455135)

Citations: OpenAlex, 2026-10-14.

## Summary

A photograph may contain enough clues to locate the camera even when many of those clues point to the wrong place. DSAC, short for Differentiable Sample Consensus, addresses the problem of finding the camera’s position and orientation from a single color image of a known scene. The authors use a neural network to predict where points seen in the image lie in the scene. Small groups of predictions produce candidate poses, and a second network scores each candidate by how well it explains the image. This follows the logic of random sample consensus, or RANSAC, which can recover a plausible pose from a pool of unreliable correspondences.

In ordinary RANSAC, the highest-scoring candidate wins. Small score changes typically leave the winner unchanged, so the final pose error gives little guidance about how to change the scores. DSAC turns the scores into probabilities and samples a single candidate for refinement. During training, the authors minimize the expected error of the refined pose. The gradient accounts both for changes to a pose and for changes to its chance of being selected. The paper also tests a deterministic alternative, SoftAM, which uses the same probabilities as weights in an average of candidate poses.

On the indoor 7-Scenes [benchmark](https://md.research.elamur.ai/free/en/topics/evaluation-benchmarks/), the authors count a prediction as accurate when its position error is below 5cm and its orientation error is below 5°. Across the complete test set, DSAC reaches 62.5% after joint training, compared with 60.3% when its networks are trained separately and 55.2% for the strongest previously published system in the comparison. Joint training moves SoftAM in the other direction, from 61.6% to 57.8%. The contrast is especially visible in Office, where the jointly trained DSAC reaches 71.2% and the jointly trained SoftAM reaches 56.6%.

The comparison shows why the choice of training objective matters. An averaged pose can shift whenever any candidate receives weight, including a candidate far from the correct pose. With DSAC, such a candidate contributes to expected error in proportion to its chance of selection, while a different selection yields a separate pose to refine. The authors find that DSAC retains a broader distribution of scores and that its coordinate predictions change less sharply on an illustrated Office image. Stairs remains a difficult case. The authors associate its repeating structures with a weakness of predicting just one scene location for each image patch.

## Deep dive: DSAC — Differentiable RANSAC for Camera Localization

DSAC makes RANSAC trainable by sampling a camera pose from scored candidates and minimizing the expected error after refinement. · about 34 minutes to read

**In this deep dive**

1. [The problem and its context](#dd-the-problem-and-its-context)
2. [The method, step by step](#dd-the-method-step-by-step)
3. [Experiments and results](#dd-experiments-and-results)
4. [What the ablations show](#dd-what-the-ablations-show)
5. [Limitations](#dd-limitations)
6. [What came after](#dd-what-came-after)

### The problem and its context

#### From clues in an image to a camera pose

Camera localization asks where a camera was and which way it was facing when it captured an image. In the setting studied here, the scene is static and already known. Its coordinate frame gives the answer a fixed meaning: the same camera position can be described consistently across pictures taken at different times or from different viewpoints. The input at localization time is one RGB image. The output is a pose with 3D translation and 3D rotation, which the paper calls a 6D pose.

A point’s position in the image tells the system where the camera saw it. To use that observation for localization, the system also needs an idea of where the point is in the scene. Pairing an image location with a predicted scene location gives a 2D–3D correspondence. If a candidate camera pose is plausible, projecting that scene location through the candidate should bring it back near the original image location. A pose can explain many such correspondences at once even when some predictions are badly wrong.

There are several reasons for wrong predictions. A patch with little texture can offer weak evidence about its location. Motion blur can obscure the details a predictor depends on. A reflection can make what appears in an image hard to associate with a stable surface. Repeating structures raise a different problem. A patch can look informative in isolation while matching several places in the room. The paper illustrates all these difficulties in 7-Scenes. They make a direct fit to every predicted correspondence risky, since an unreliable prediction can pull the fit away from a pose supported by the useful ones.

RANSAC, introduced in 1981, organizes the search around small subsets of the observations. A subset supplies enough information to propose a candidate. The remaining observations help judge whether that candidate has broad support. A good subset can therefore lead to a useful estimate even when an attempt to fit all the data together would be poor. In camera localization, each proposal describes an entire camera pose, even though its starting evidence comes from only a few image locations.

The paper situates RANSAC in a wider family of computer vision problems where local predictions support a global geometric estimate. It mentions applications in multiview geometry, retrieval, pose estimation, and simultaneous localization and mapping. Earlier variants pursued faster search or better final estimates. For example, a preemptive search can spend further computation on promising candidates while eliminating weaker ones. The concern in DSAC is how to train the predictors that supply and evaluate the hypotheses in such a search.

#### What earlier localization systems learned

The approach closest to DSAC begins with scene coordinate regression forests, abbreviated SCoRF. An early version predicted a scene coordinate for a pixel, sampled groups of predictions, and used those groups to propose camera poses. A RANSAC procedure then verified and refined the candidates. The coordinate predictor supplied local information, while geometric fitting combined the information into a global answer. This division allowed the system to learn about a scene while keeping an explicit check on whether its local estimates agreed.

The paper describes extensions that made the predictions more expressive. Guzman-Rivera and colleagues trained a forest to return diverse coordinate predictions to handle ambiguity. Valentin and colleagues used a forest that could describe several plausible coordinate outcomes, giving the pose estimator more information about uncertainty. Earlier work by Brachmann and colleagues localized from RGB images using an auto-context forest, where contextual information strengthened the predictions. Its later pose optimization could use the uncertainty represented by the forest.

A related object pose system by Krull and colleagues learned to score hypotheses. It used a convolutional neural network to compare rendered and observed images. A learned score could use more information than a count of the observations deemed consistent. DSAC carries that idea over to camera localization with a different input: its scorer sees where the geometric projections disagree with the observed image locations. The prior systems discussed in this line of work learned their components separately.

The paper also describes another way to apply [machine learning](https://md.research.elamur.ai/free/en/concepts/machine-learning/) to the task. PoseNet predicts a pose directly from an RGB image with a convolutional network. This makes the output itself available as a training target without an intervening candidate-selection step. The scene coordinate approach makes a different commitment. It keeps explicit correspondence predictions and a geometric fitting procedure, then asks how the final error can train the parts that produce and assess those correspondences.

#### Why learning the whole pipeline was difficult

The broader context was a growing interest in building established vision procedures into trainable systems. The paper cites LIFT, which incorporates stages of sparse feature processing, and work on dense image matching that replaces a recursive decoding procedure with reverse convolutions. Place recognition offers another example. NetVLAD puts the aggregation of local visual descriptors into a convolutional architecture and softens descriptor assignment so that the aggregation can participate in training. [NetVLAD](https://md.research.elamur.ai/free/en/papers/arandjelovic-2016-netvlad-cnn-architecture-weakly-supervised/)

The problem with hard RANSAC selection is easiest to see by imagining two candidates. Suppose the first has a slightly higher score, although the second would give a better camera pose if chosen. A small change that raises the second score still leaves the first candidate in charge of the answer. The output changes abruptly only when the scores cross. A derivative through the selected candidate can say how its geometry should change, but does not tell the scorer to prefer the second one.

This issue also affects the coordinate predictor. Changing a coordinate can shift the pose generated from a sampled subset. It can also change the evidence for competing candidates, since the scorer looks at their agreement with the coordinate predictions. A derivative that simply follows the current winner leaves that competition out. The training challenge is to communicate the consequences of changing the selection while retaining the geometric search that gives the pipeline its robustness.

### The method, step by step

#### From a color image to a refined estimate

The Coordinate CNN, a convolutional neural network, examines patches of an RGB image. For each patch it estimates the scene location of the point associated with that patch’s image position. The prediction is expressed in the fixed scene coordinate frame. It answers a local question about where a visible point belongs, leaving the camera pose to be inferred from the relationships among many such answers.

The system draws small groups of these correspondences and fits a pose to each group. It then asks, for each candidate, where all the predicted scene points would appear if the camera had that pose. The distances between the projected and observed image positions form a grid of reprojection errors. The Score CNN turns the grid into a number that represents support for the candidate. A grid preserves the arrangement of the errors, so the network can in principle respond to where in the image a candidate fits as well as to how many small errors it produces.

DSAC converts the scores into a probability distribution and draws a candidate. The initial geometric fit used only its sampled correspondences. Refinement can bring in more evidence. Starting from the chosen pose, the system identifies additional correspondences that agree with it, fits again, and repeats. The pose at the end of refinement is what the system is judged on.

How DSAC estimates a camera pose The steps in order.

#### Correspondences, candidate poses, and reprojection errors

For an RGB image `I`, the Coordinate CNN supplies the set of scene coordinate predictions used throughout the pipeline.

```
Y_w = { y(I, i; w) | i indexes a processed image location }
```

`Y_w` is the collection of predictions for the current image, with the subscript `w` indicating its dependence on the Coordinate CNN’s parameters. `y` is the prediction function, `I` is the RGB image, `i` identifies an image location, and `w` is the parameter set used in that function. The braces collect the predictions, and the vertical bar introduces the condition determining which locations are included. Below, `yᵢ` denotes one prediction from this collection. The corresponding position in the image is known from the patch location.

The Coordinate CNN has a VGG-style architecture with 13 layers and 33M parameters. Its input for each prediction is a 42x42 pixel patch. The implementation uses 40x40 patches per image to reduce test time. Each prediction is a point estimate, meaning the network supplies one location in the scene for a patch. An image patch that resembles several places still produces one scene coordinate.

The candidate generator samples correspondence indices uniformly. The paper calls the small group needed by the solver a minimal set. In this application each subset contains four correspondences.

```
h_J = H(Y_J)
```

`J` identifies the sampled group by its correspondence indices. `Y_J` is the subset of predicted scene coordinates at those indices, used together with their image locations. `H` is the fitting function, and `h_J` is the resulting candidate pose. When it is useful to show the dependence on the coordinate predictor, the paper writes the candidate as `h_J^w`. The corresponding locations and the camera projection are understood as inputs to the geometric problem.

The fitting function uses perspective-n-point, abbreviated PnP. Given correspondences between points in a scene and their positions in an image, PnP estimates the pose that makes the points project to those positions. A sampled group can contain faulty correspondences, so the pipeline generates 256 pose hypotheses. The subsets come from uniform sampling. The learned parameter sets affect what coordinates are available, what poses the solver obtains from them, and how the poses are scored.

For each candidate the system measures how it projects a predicted scene coordinate into the image.

```
eᵢ = ‖pᵢ − C h_J yᵢ‖
```

`eᵢ` is the reprojection error at location `i`. `pᵢ` is the observed image position, `yᵢ` is the predicted scene point associated with that position, and `h_J` supplies the candidate transformation used to take the scene point into the camera frame. `C` is the camera projection matrix. The expression `C h_J yᵢ` represents the projected position in the image, and the norm `‖ ‖` gives the distance between that position and `pᵢ`. The subtraction takes place in image coordinates, so this error is measured in pixels.

```
eᵢ < τ
```

`eᵢ` is the error for one correspondence under the candidate being considered. `τ` is the inlier threshold, set to 10px in the implementation. The inequality is the rule for counting that correspondence as an inlier to the pose. An inlier under this rule agrees with a particular projection. Measuring whether a prediction agrees with its ground-truth location in the scene is a separate check used later in the paper’s analysis.

In conventional consensus scoring, the number of inliers can serve as the candidate’s score. Here, the errors for the 40x40 coordinate grid are arranged as a 40x40 input to the Score CNN. This is a separate VGG-style network with 13 layers and 6M parameters. The paper writes its scalar output as `s(h_J, Y; v)`, where `s` is the scoring function, `h_J` is the candidate, `Y` is the set of predictions used to build its reprojection grid, and `v` contains the scoring network’s parameters. The network receives the errors that result from the candidate and the predictions. It can use their magnitudes, which an inlier count would collapse into a pass or fail at the threshold.

#### The selection rule and the objective it creates

Standard hard selection chooses the candidate with the greatest score.

```
h_AM = argmax over h_J of s(h_J, Y; v)
```

`h_AM` is the pose selected by the argmax. `argmax` returns the candidate at which the score is greatest. `h_J` ranges over the generated hypotheses, `s` assigns their scores, `Y` supplies the scene coordinate predictions, and `v` specifies the scorer. For a fixed collection of candidates, a change to the scores only changes the selected index if it changes which candidate ranks first.

The selected pose is then refined, giving the following output for ordinary argmax selection.

```
h̃_AM = R(h_AM, Y)
```

`h̃_AM` is the refined pose, `R` is the refinement procedure, `h_AM` is its initial pose, and `Y` provides the predicted coordinates and their image associations. In the camera pipeline, `R` takes up to 100 correspondences that satisfy the inlier rule and solves PnP on them. The updated pose is used to find inliers for another fit, with 8 refinement steps in the reported configuration and an early stop when fewer than 50 inliers are found. The system scores the candidate pool once and spends this iterative computation on the selected pose. The previous preemptive pipeline could refine and score multiple candidates as it narrowed the pool.

The hard-selection version poses a training problem even if the geometric fit and the final loss can be differentiated. Here is the objective the authors would like to optimize, written with the per-image dependence implicit.

```
(w̃, ṽ) = argmin over w, v of Σ[I ∈ ℐ] ℓ(R(h_AM^(w,v), Y_w), h*)
```

`w̃` and `ṽ` are the parameter values sought by training, and `argmin` denotes a choice that minimizes the expression. `w` and `v` are the parameters of the coordinate predictor and scorer. `Σ[I ∈ ℐ]` sums over images `I` in the training collection `ℐ`. `h_AM^(w,v)` is the pose obtained by choosing the highest-scoring candidate using those parameters. `Y_w` is the set of predicted coordinates for the current image. `R` refines the chosen pose, `h*` is the ground-truth pose for that image, and `ℓ` measures pose error for training. The superscript `(w,v)` records dependence on the parameters.

Differentiating along the winning candidate’s path could account for changes in that candidate’s geometry and in the inputs to refinement. The missing information is how the competition among candidates responds to training. In particular, changing `v` changes the scores and hence potentially the choice. When the choice stays fixed, the scorer has no continuous route to influence the final pose. The authors report that early attempts to learn through hard selection by following the chosen candidate led to a training loss that rose immediately and failed to recover.

Both alternatives start by passing the scores through a softmax.

```
P(J | v, w) = exp(s(h_J^w, Y_w; v)) / Σ[J′] exp(s(h_J′^w, Y_w; v))
```

`P(J | v, w)` is the probability assigned to choosing candidate index `J` for the image and sampled pool under consideration. The bar expresses conditioning on the displayed parameter sets `v` and `w`. `exp` is the exponential function. `s` is the scoring function, `h_J^w` is the pose fitted from the subset indexed by `J`, and `Y_w` is the full coordinate prediction set. `Σ[J′]` sums the exponentiated scores over the whole pool, with `J′` a running candidate index and `h_J′^w` its pose. The denominator normalizes the probabilities. Higher scores give higher probabilities, while the separation among scores determines how concentrated those probabilities are.

SoftAM uses the probabilities to average the candidate parameters before performing refinement.

```
h_SoftAM^(w,v) = Σ[J] P(J | v, w) h_J^w
```

`h_SoftAM^(w,v)` is SoftAM’s initial pose, depending on both parameter sets. `Σ[J]` sums across the candidate pool. `P(J | v, w)` is the softmax weight of a candidate and `h_J^w` is that candidate’s pose. The weighted average gives changes to the scores a continuous route to the output: changing a weight shifts the pose that refinement receives. A pose far from the desired result can pull this average away from a useful starting point. The score therefore needs to suppress a candidate if even its partial contribution would be harmful.

DSAC uses the same distribution to choose a single candidate.

```
h_DSAC^(w,v) = h_J^w, with J ∼ P(J | v, w)
```

`h_DSAC^(w,v)` is the selected initial pose. `h_J^w` is the candidate at the drawn index `J`. The symbol `∼` means that `J` is sampled according to the distribution `P(J | v, w)`. The camera pose passed to refinement is the pose that PnP fitted to the selected subset. For a fixed draw, the poses of the other candidates play no part in forming that initial estimate.

The place of the average in the computation is central. SoftAM averages the candidates and then evaluates the loss after refinement. DSAC defines a loss for the outcome of selecting and refining a candidate, and during training takes an average of those possible losses weighted by their selection probabilities. Refinement starts from the actual outcome of the rule in each case. An average that falls between two plausible poses can have a very different error from either pose after refinement.

```
(w̃, ṽ) = argmin over w, v of Σ[I ∈ ℐ] 𝔼[J ∼ P(J | v, w)] [ℓ(R(h_J^w, Y_w), h*)]
```

`w̃` and `ṽ` are the parameter values sought, and `argmin` expresses minimization over `w` and `v`. `Σ[I ∈ ℐ]` aggregates training images from the collection `ℐ`. `𝔼` is an expectation, namely the probability-weighted average over `J` drawn from `P(J | v, w)` for the current image and pool. `h_J^w` is the drawn candidate, `Y_w` contains the coordinates available to refine it, `R` performs the refinement, and `ℓ` compares the refined pose with the ground truth `h*`. The candidate pool is itself generated from random minimal sets. The expectation displayed here concerns which member of a generated pool is selected.

#### How the gradient reaches the networks

For the derivatives, let `L_J` denote the loss after taking candidate `J`, refining it with the current predictions, and comparing the resulting pose with the ground truth. The authors use a policy gradient identity, familiar from reinforcement learning, to handle the discrete choice. It differentiates the average loss by accounting for changes in the probabilities and changes in the losses attached to those probabilities.

```
∂𝔼[J ∼ P(J | v, w)][L_J]/∂w = 𝔼[J ∼ P(J | v, w)][L_J ∂log P(J | v, w)/∂w + ∂L_J/∂w]
```

`𝔼` takes the expectation over the selection of `J` from the distribution `P(J | v, w)`. `L_J` is the selected candidate’s refined pose loss, `log` is the logarithm, and `∂/∂w` denotes differentiation with respect to the Coordinate CNN’s parameters. The first term inside the expectation describes the effect of changing how likely the candidate is to be selected. The second describes the effect of changing its refined pose while holding the selected index fixed. An analogous derivative with respect to `v` trains the scorer. In this pipeline the scorer affects the pose through the choice of index, since the refinement of a fixed candidate uses the coordinate predictions.

To see where the first term comes from, consider one candidate’s contribution to the expected loss. It is the product of selection probability and refined loss. When the parameters change, either factor can change. Dividing the probability derivative by the probability gives the derivative of its logarithm, so the probability itself can stay outside the product and serve as the weight in the expectation. This makes it possible to reason about how a discrete decision responds to a parameter change without assigning a derivative to the sampled index.

The log probability derivative has a simple form because the distribution is a softmax.

```
∂log P(J | v, w)/∂w = ∂s(h_J^w, Y_w; v)/∂w − 𝔼[J′ ∼ P(J′ | v, w)][∂s(h_J′^w, Y_w; v)/∂w]
```

`∂/∂w` is differentiation with respect to the coordinate parameters, and `log P(J | v, w)` is the logarithm of the selected index’s probability. `s` gives a candidate score from its pose, the predictions `Y_w`, and the scoring parameters `v`. `h_J^w` is the pose with index `J`. `𝔼` averages over the running index `J′` using the softmax probabilities, and `h_J′^w` is the pose at that running index. The selected score derivative is measured against the probability-weighted average of the competing score derivatives. A change that moves all scores together leaves the probabilities unchanged.

SoftAM uses an ordinary chain rule through its average and the subsequent refinement. To express the derivative, write `L_S` for its refined pose loss and `h_S` for the SoftAM pose before refinement. The paper accounts for both inputs to refinement.

```
∂L_S/∂w = (∂ℓ/∂R) [(∂R/∂h_S)(∂h_S/∂w) + (∂R/∂Y_w)(∂Y_w/∂w)]
```

`L_S` is the loss for the refined SoftAM result. `w` denotes the coordinate parameters and `∂` a partial derivative along the indicated argument. `∂ℓ/∂R` measures how the loss responds to the refined pose. `R` is the refinement output, `h_S` is its starting pose, and `Y_w` is its collection of scene coordinate predictions. The first product inside the brackets follows the effect of changing the starting pose, and the second follows the effect of changing the coordinates used to refine it. The ground truth stays fixed throughout.

The derivative of the SoftAM pose also has two paths.

```
∂h_S/∂w = Σ[J] [(∂P(J | v, w)/∂w) h_J^w + P(J | v, w)(∂h_J^w/∂w)]
```

`h_S` is the SoftAM pose and `w` contains the coordinate predictor’s parameters. `Σ[J]` sums over candidate indices. `P(J | v, w)` is the weight of candidate `J` given the scorer parameters `v` and coordinate parameters `w`. `h_J^w` is that candidate’s pose. The first term changes the weight of the candidate, and the second changes the pose receiving the weight. The coordinate network can therefore affect the average through both geometric fitting and scoring, just as it can affect both parts of the expected loss in DSAC.

The probability derivative used in this calculation can be written with the same relative score term as the log derivative.

```
∂P(J | v, w)/∂w = P(J | v, w) [∂s(h_J^w, Y_w; v)/∂w − 𝔼[J′ ∼ P(J′ | v, w)][∂s(h_J′^w, Y_w; v)/∂w]]
```

`P(J | v, w)` is the softmax probability at index `J`. The derivatives are with respect to `w`, the coordinate parameters. `s` is the scoring function with parameters `v`, `h_J^w` and `h_J′^w` are the poses at indices `J` and `J′`, and `Y_w` is the coordinate prediction set. `𝔼` takes the probability-weighted average over `J′`. Multiplication by the candidate’s probability turns the relative score derivative into an absolute change of weight. These derivatives give SoftAM and DSAC ways to learn about the entire candidate competition, but they pass different downstream signals to it.

#### The pose loss and the geometric derivatives

The training loss compares orientation and position in the units used by the accuracy criterion.

```
ℓ_pose(h, h*) = max(∠(θ, θ*), ‖t − t*‖)
```

`ℓ_pose` is the pose loss. `h` and `h*` refer to the estimated and ground-truth poses being compared in the camera convention. `θ` and `θ*` denote the estimated and reference rotations in axis-angle form, which represents a rotation by its axis and angle. `∠` measures the angular separation of the rotations in degrees. `t` and `t*` are the camera translations, and the norm `‖t − t*‖` measures their distance in centimeters. `max` takes the larger of the numerical errors in those units.

Using the maximum directs the loss at the larger error. A pose can satisfy the joint test criterion only when both quantities are below their respective thresholds. The training loss gives the optimizer a graded signal as an error changes, while the test criterion counts an image as successful or unsuccessful. Accordingly, improving the loss need not change the reported accuracy for a prediction that remains on the same side of both cutoffs.

The distinction between projection and evaluation is important. The transformation used in reprojection takes scene points into the camera frame. The camera pose relative to the scene is its inverse.

```
h_cam = h⁻¹
```

`h_cam` denotes the camera pose in the scene frame. In this formula `h` is the scene-to-camera transformation used for projection, and `⁻¹` denotes inversion of that transformation. The rotations and translations entering the camera error are computed in the camera pose convention for both the estimate and the reference. The paper’s evaluation appendix explains why using the unreversed transformation can change the translation error.

PnP and refinement also lie on the path from the predictions to the loss. The authors use central differences to estimate their derivatives. For a coordinate input, they perturb it in opposite directions and use the change in output across the two perturbations to estimate the local response. This lets them use existing PnP implementations for geometric fitting. The authors apply the same procedure to the entire refinement routine. Inlier selection is discrete, so the argument for this approximation is practical: with many inliers contributing, the final pose tends to vary smoothly enough as the predictions change.

Estimating a gradient for every coordinate used in refinement would require many evaluations of that routine. The implementation calculates derivatives for a subsample of 1% of the scene coordinates and adjusts the magnitude by ×100. Early termination when fewer than 50 inliers are available also serves stability. These choices concern differentiation through the geometric computations. DSAC’s derivative for choosing a hypothesis comes instead from the expected-loss objective.

#### Preparing the networks before joint training

Both trainable components start from separate supervised training. For the Coordinate CNN, the training images have depth information that the authors use to obtain reference scene coordinates. The scene representations available with the dataset can also be used to render those reference coordinates. During localization, the network receives the color image. Depth’s role in this procedure is to give the network a target while it learns to associate image patches with positions.

```
ℓ_coord(y, y*) = ‖y − y*‖
```

`ℓ_coord` is the loss used to train the Coordinate CNN on a patch. `y` is the predicted scene location and `y*` is its ground-truth location in the scene frame. The norm gives their Euclidean distance. This objective judges a patch prediction on its own. It gives the network a starting point before training judges that prediction by its contribution to the final pose.

The Coordinate CNN trains on mini-batches of 64 randomly sampled patches. Its optimizer is Adam, with a starting learning rate of 10⁻⁴. The learning rate is halved after each 50k updates, and training lasts 300k updates. The authors also tried squared distance, Huber, and Tukey losses. They report that these gave poorer validation results than the distance loss used in the experiments.

The Score CNN has its own supervised examples. The authors perturb the ground-truth poses of training images to create candidate poses on either side of the success thresholds of 5° and 5cm. With the trained Coordinate CNN’s predictions, they compute the reprojection error grid for each perturbed pose. The known pose error supplies a target for scoring the grid. A candidate near the reference receives a higher target score than one far away.

```
s* = −β ℓ_pose(h, h*)
```

`s*` is the target score. `β` controls how strongly pose errors separate the scores, `ℓ_pose` is the pose loss, `h` is the perturbed candidate, and `h*` is the ground truth. The minus sign gives a higher target to a candidate with a smaller loss. After softmax, the score scale influences the concentration of the candidate probabilities. The authors choose `β` equal to 10 based on the validation behavior of the distribution.

```
ℓ_score(s, s*) = |s − s*|
```

`ℓ_score` is the loss used in separate training of the scoring network, `s` is its predicted score, and `s*` is the target from the pose error. The absolute value `| |` measures the magnitude of the discrepancy. The scorer trains on batches of 64 error grids, using randomly generated poses. It uses Adam at a learning rate of 10⁻⁴ for 2k updates. This stage establishes a relationship between the errors visible in a grid and the quality of the candidate that produced it.

#### Joint optimization and validation

The dataset has no designated validation split. To tune hyper-parameters, the authors hold out 10% of each scene’s training frames in contiguous groups of 100. They choose settings such as the learning rates and the number of updates on that split. Once they fix the settings, they train again on the full training set. The test sequences supply the reported localization results.

The jointly trained SoftAM and DSAC systems both start with the separately trained networks. The authors report that starting from scratch quickly led to a local minimum. Initialization gives candidate generation a supply of plausible scene coordinates and gives selection a scorer with some ability to recognize promising poses. The joint phase then adjusts both networks using the error on the output of the geometric pipeline.

The authors use the same joint-training schedule for both selection rules. The fixed learning rate is 10⁻⁵ for the Coordinate CNN and 10⁻⁷ for the Score CNN. They use stochastic gradient descent with momentum of 0.9 and clamp the gradients to the range from -0.1 to 0.1 before passing them to either network. The joint training runs for 5k updates. Adam had been unstable in this phase, where random selection of minimal subsets already introduces substantial variation in the computation. The paper makes source code and trained network parameters available.

### Experiments and results

#### Data, baselines, and what counts as success

7-Scenes contains RGB-D recordings of 7 indoor environments. Each frame has a ground-truth camera pose and each environment has a 3D scene representation. The recordings consist of separate camera paths, with sequences assigned to the training or test data. That split tests localization on held-out paths through known places. The authors describe the per-scene image counts as ranging from 1k to 7k for training and test. At test time they use the RGB channels.

The principal metric is the fraction of test images for which the estimated camera position is less than 5cm from the reference and the estimated orientation differs by less than 5°. The paper reports results for individual scenes, the average of those scene accuracies, and accuracy on the combined set of 17,000 test frames, labeled Complete. The scene average gives each environment equal weight. On the combined set, each image carries the same weight. The distinction matters for this benchmark because some environments, including Stairs and Heads, contribute relatively few test images.

The external comparisons are a sparse-features baseline reported with the scene coordinate forest work and the earlier RGB localization pipeline of Brachmann and colleagues. The latter uses an auto-context regression forest and a preemptive RANSAC procedure, with uncertainty used in final pose optimization. The paper also discusses PoseNet, reporting median position errors of around 40cm per scene for that approach. PoseNet’s cited position errors give context for direct pose prediction. The main accuracy comparison uses the methods for which the paper presents results at the joint position and orientation thresholds.

The internal comparisons distinguish what the networks learned from how their scores were used. With separate training, the authors test hard argmax, the SoftAM average, and DSAC sampling. All three use a learned coordinate predictor and a learned scorer. The row labeled RANSAC is therefore the authors’ own pipeline with ordinary selection, distinct from the external baselines. With joint training, they report SoftAM and DSAC, the two rules that let the training objective account for candidate selection.

#### Complete-set accuracy and the scene average

Camera pose accuracy on the complete 7-Scenes test set DSAC attains the highest complete-set accuracy after joint training, while joint training lowers SoftAM accuracy.

**The numbers**

| System or setting | accuracy % |
| --- | --- |
| Sparse Features | 38.6 |
| Earlier Brachmann et al. pipeline | 55.2 |
| RANSAC, separate training | 61.0 |
| SoftAM, separate training | 61.6 |
| DSAC, separate training | 60.3 |
| SoftAM, joint training | 57.8 |
| DSAC, joint training (this paper) | 62.5 |

With separate training, the three ways of using the scores produce similar complete-set accuracies. SoftAM has the highest value at 61.6%, followed by hard argmax at 61.0% and DSAC at 60.3%. The authors report a -0.7% difference for DSAC relative to argmax on the complete set in this condition. The comparison establishes what happens when the same training recipe supplies the networks and each decision rule uses them. Sampling a single pose is already competitive, with its main gain appearing after the coordinate predictor and scorer learn from the final pose error.

The complete-set result for jointly trained DSAC is 62.5%. The authors report an improvement of +2.2% from the separately trained DSAC, with a standard error of the mean of ±0.4%. For SoftAM, the reported change from its separately trained starting point is -3.8%. The networks and their score distributions are adjusted under objectives that differ in where they put the average. That difference matters more to the final ranking than the small spread among the decision rules at initialization.

The comparison with the earlier Brachmann pipeline also depends on how the scores are aggregated across scenes. That system obtains 55.2% for both the scene average and the complete set. Jointly trained DSAC attains 60.1% for the scene average and 62.5% for the complete set. The authors report gains of 4.9% and 7.3%, respectively. Those figures have different weightings even though both describe camera localization under the same thresholds.

For the authors’ own configurations, the separate-training scene averages are 59.5% for argmax, 60.1% for SoftAM, and 59.0% for DSAC. Joint training gives 57.9% for SoftAM and 60.1% for DSAC. The jointly trained DSAC and separately trained SoftAM thus have the same reported scene average, alongside different results when the test frames are pooled. The scene values explain where the distinction comes from and how much the headline result can hide about individual environments.

#### How the scenes differ

Office is where learning changes the comparison most visibly. Separate training yields 71.3% for SoftAM and 69.2% for DSAC. Joint training moves SoftAM to 56.6%, with a reported change of -14.7%, and DSAC to 71.2%, with a reported change of +2.0%. The earlier Brachmann pipeline scores 53.2% on Office. This scene therefore shows both how well the new pipeline can do with the separate objectives and how much the SoftAM objective can erode that starting position.

The greatest gains reported for joint DSAC training occur in Pumpkin and Kitchen. Its Pumpkin accuracy rises from 50.3% to 53.6%, a reported +3.3%. Its Kitchen accuracy rises from 46.2% to 51.2%, a reported +5.0%. Pumpkin also illustrates why improvements over initialization and improvements over prior work are different comparisons. The earlier Brachmann pipeline attains 54.5% there. On Kitchen that baseline attains 42.2%, and the jointly trained DSAC has the strongest result in the comparison.

Several other scenes favor different configurations. On Fire, SoftAM improves from 75.6% under separate training to 76.9% after joint training, a reported +1.3%. DSAC moves from 75.3% to 74.3%, a reported -1.0%. On Heads, separate training gives SoftAM 74.5%, and joint training leaves it at 74.0%. The corresponding DSAC results are 71.9% and 71.7%. On Chess, the results for the authors’ methods stay near the earlier Brachmann pipeline’s 94.9%. Joint training gives DSAC 94.6% and SoftAM 94.2%.

Stairs is difficult for the entire learned-scoring pipeline. DSAC reaches 5.3% there with separate training and 4.5% with joint training. SoftAM reaches 6.5% with separate training and 5.5% with joint training. The earlier Brachmann pipeline reaches 20.1%, and even the sparse-features baseline reaches 9.2%. The authors discuss Stairs as a case where several plausible scene coordinates for a patch can be more useful than one. The complete-set gain depends on gains elsewhere and leaves this failure mode visible at scene level.

#### Errors across all test images

The authors also report median position and orientation errors on the complete test set. Median error describes the middle of the error distribution in each measurement. It gives a different view from the joint success rate, which depends on how many images meet both thresholds at once. The position and rotation medians need not refer to the same test image.

Median camera position error on the complete 7-Scenes test set Jointly trained DSAC shares the lowest reported median position error with separately trained SoftAM.

**The numbers**

| System or setting | cm |
| --- | --- |
| Earlier Brachmann et al. pipeline | 4.5 |
| RANSAC, separate training | 4.0 |
| SoftAM, separate training | 3.9 |
| DSAC, separate training | 4.0 |
| SoftAM, joint training | 4.0 |
| DSAC, joint training (this paper) | 3.9 |

The earlier Brachmann pipeline has a median orientation error of 2.0° on the complete set. All of the authors’ reported variants have a median orientation error of 1.6°. Jointly trained DSAC has a position median of 3.9cm, while the separately trained DSAC has a median of 4.0cm. SoftAM’s separately trained configuration shares the 3.9cm median with jointly trained DSAC and has a lower complete-set success rate. Those results are compatible because a pair of medians does not determine the fraction of individual predictions that jointly satisfy the two thresholds.

The authors also measure test time. Coordinate prediction takes roughly 0.5s on a Tesla K80, and pose optimization takes approximately 1s. They report negligible time for the choice between candidate poses, with the same runtime for sampling and for selecting the argmax. The larger costs come from obtaining the scene coordinates and estimating the pose.

### What the ablations show

#### Which network needs the final pose loss?

The component ablation starts with the same pair of separately trained networks and changes which one is updated using the final pose objective. The question is whether the effect of joint learning comes primarily from better scoring, better coordinate predictions, or the interaction between the two. The authors evaluate the conditions on the complete test set. For DSAC, updating both networks produces the best accuracy in the ablation.

The roles of the networks explain what the comparison can distinguish. Updating the scorer can change the chances of selecting a good candidate from a pool. Updating the coordinate predictor can change which candidates the pool contains, the reprojection errors available to score them, and the correspondences available during refinement. A useful candidate pool and a reliable choice within it are separate requirements. The DSAC ablation supports optimizing both in this implementation.

With SoftAM, the authors trace the poor jointly trained result to how the coordinate predictor adapts. Updating the scoring network alone does not account for the overall deterioration in the ablation. The coordinate predictor has several ways to improve a weighted average on training images. For example, changing part of the predicted coordinate field can alter which poses the sampled subsets generate and how those poses combine. Whether that change carries over to another image depends on how broadly the changed predictions remain useful.

#### Where coordinate predictions change

The paper visualizes the effects of joint training on an Office test image. It compares coordinate predictions after joint training with the predictions from separate training, using ground-truth coordinates to assess both. Some image areas improve and others worsen under each objective. SoftAM makes relatively large changes with improvements concentrated in small regions. On this image, 14% of its predictions improve. DSAC produces smaller changes spread over more of the image, with improvements in 38% of predictions.

The authors use the same joint-learning settings for both variants. This makes the difference informative about the response to the selection rule and its associated objective under that schedule. In SoftAM, the coordinate predictor can help the training loss by arranging the contributing poses so that their average is favorable. In DSAC, the predictor has an incentive to produce candidates that can individually be selected, refined, and judged. Those objectives make different uses of the same kinds of patch predictions.

The coordinate visualization addresses where and how the estimates change. It does not measure pose accuracy by counting locally improved patches. The position of a patch and its relationship to the other correspondences matter to fitting and refinement. The authors use the image to illustrate a possible mechanism for the Office result. The corresponding test accuracies are measured over the scene’s test images.

#### How concentrated the scores become

The entropy analysis examines how evenly the softmax distributes probability across the candidate pool. A low-entropy distribution puts much of its probability on a narrow selection of candidates. A broader distribution leaves several alternatives with meaningful weight. After joint training, entropy falls for SoftAM. The decrease for DSAC is slight relative to the original argmax configuration’s score distribution.

This difference fits the way the two objectives treat a poor candidate. In SoftAM, a candidate far from a useful pose has the potential to pull the average away from that pose even when its weight is modest. To protect the starting estimate, the learned scores can sharply reduce the contribution of such a candidate. In DSAC, selecting a good candidate starts refinement from that candidate alone. A poor alternative adds risk to the expected loss through its selection probability, without moving the starting pose on trials in which a good candidate is drawn.

The researchers also try switching the inference rule to hard argmax after training. They report 62.4% for DSAC under this switch and 57.2% for SoftAM. These are the accuracies the paper gives in its discussion of restored argmax. They belong to the changed decision rule. The experiment asks whether the learned scores still put useful candidates at the top when the final selection is deterministic. DSAC’s result stays close to the headline accuracy with sampling, while the switch weakens SoftAM in the authors’ comparison. A score learned as a coefficient for averaging can serve a different purpose from a score learned to assign chances to separately evaluated candidates.

#### How much the pipeline needs robust fitting

The appendix compares DSAC with a direct pose fit to all the predicted scene coordinates. For this comparison, it measures the reliability of the coordinate field using ground truth. A prediction counts as an inlier if its scene position is within 10cm of its reference position. Across test images, the resulting inlier ratios range from 5% to 85%. This measures correspondence quality in the 3D scene frame, whereas the threshold used during refinement measures reprojection error in the image.

The accuracy plot places results from both fitting approaches alongside these inlier ratios. It helps show where a pipeline can benefit from looking for a coherent subset before using additional data to refine a pose. Fitting every coordinate gives the erroneous predictions a route into the estimate from the beginning. DSAC can propose a pose from a small group of useful predictions and test its agreement with a wider set. The comparison concerns the value of robust fitting in this system. It does not isolate the effect of probability-based selection from the other differences between DSAC and a direct fit.

The appendix also shows successful examples with textureless areas, blur, reflections, and repeating structures. These examples demonstrate that the system can find a correct pose in the presence of each difficulty. The Stairs results show how a scene with pervasive repetition can still defeat the pipeline often. A few correctly localized difficult frames and an accuracy measured across a whole scene answer different questions.

### Limitations

#### Limits identified by the authors

The authors identify the point-valued coordinate predictions as a weakness on Stairs. When patches from different parts of a scene look alike, giving the downstream search several plausible coordinates could preserve alternatives that a single prediction discards. The earlier regression forest represents multiple possible locations and their uncertainty. DSAC can select among competing pose hypotheses once they exist, but its coordinate predictor has limited means to express ambiguity before those hypotheses are generated.

The authors also expect multiple clusters in the pose candidates to cause difficulties for SoftAM. If distinct groups correspond to different plausible camera positions, an average across them can be a poor starting point for refinement. Sampling can preserve a candidate from one group. This argument explains an advantage of the decision rule under ambiguity. The experiment with Stairs does not separately vary the number of plausible coordinate predictions while holding the rest of the DSAC pipeline fixed.

Joint training has practical dependencies. The authors find that separate initialization is important, and they report instability when using Adam for the joint phase. They also point out that refinement includes hard inlier decisions. Their derivative uses a central-difference estimate justified by the observed behavior of the refined pose with many inliers. The sub-sampling of coordinate derivatives and the early stopping condition make the calculation tractable and more stable. Therefore, the expected-loss gradient addresses the discrete candidate choice, while the implemented training procedure also relies on approximations elsewhere in the computation.

The evaluation appendix records a correction that matters for interpreting the numbers. An earlier version reported roughly 56.8% complete-set accuracy for componentwise training with an erroneous pose evaluation. Evaluating the camera pose using the inverse transformation with the earlier implementation gave 45.5%. The authors subsequently changed the PnP implementation to a standard iterative solver, which improved the results and yielded the figures they report in the revised experiments. They state that the conclusions from the comparisons survived the revision. The correction shows the sensitivity of the measured accuracy to both pose convention and the geometric solver.

#### Limits visible in the experimental setup

The evaluation is confined to familiar indoor scenes and held-out camera paths. The input is a single RGB image, while the coordinate predictor has learned from scene-specific examples with geometric supervision. The setup establishes that the approach can localize new images of known scenes. It leaves open how well it would transfer to an unfamiliar environment, handle a changing scene, or learn coordinates without the training geometry available in this benchmark.

The comparison with the earlier accuracy leader changes several parts of the pipeline together. The authors replace the regression forest with a CNN, introduce a learned reprojection scorer, and change when and how many candidates are refined. The cross-system results measure the performance of those assembled pipelines. The comparison between jointly trained DSAC and its separately trained initialization gives more direct evidence about the effect of training on the final loss. The SoftAM comparison further tests the choice of objective and selection rule inside the new architecture.

The score entropy and Office visualization are explanatory analyses with different scopes. Entropy measures the concentration of the score distribution. It does not establish that the probabilities accurately represent the frequency with which a candidate is correct. The Office visualization shows the spatial pattern of coordinate changes in one test image. Alongside the ablation and the scene’s accuracy, it supports the authors’ account of overfitting, while leaving its prevalence across other images and scenes unmeasured.

Finally, the paper’s general argument for using DSAC wherever robust fitting is helpful is wider than its experimental demonstration. The probability derivative can be formulated for another pool of scored candidates. Applying the full learning procedure still requires suitable ways to generate and evaluate those candidates, refine the selected outcome, and estimate how the loss responds to the learned components. The numerical results establish the behavior of one localization system and its tested alternatives.

### What came after

The authors point toward structure from motion and simultaneous localization and mapping as possible applications. In those settings, the relevant connection is the need to fit geometry to local evidence that can contain outliers. DSAC suggests training the proposed fits and their scorer by the expected quality of a selected geometric result. The paper presents these applications as future directions.

The other direction follows directly from the Stairs experiments. Keeping several plausible scene locations for an ambiguous patch could let the geometric search assemble different explanations of the image. Within such a search, a distribution over pose hypotheses could preserve uncertainty until the system selects an estimate to refine. The authors identify both forms of ambiguity as opportunities for extending the approach. These are proposed extensions, and the account of the research ends with the camera localization experiments.

## Cite

Cite as Eric Brachmann, Alexander Krull, Sebastian Nowozin, Jamie Shotton, Frank Michel, Stefan Gumhold and Carsten Rother. 2017. DSAC — Differentiable RANSAC for Camera Localization. IEEE Computer Society Conference on Computer Vision and Pattern Recognition/Proceedings - IEEE Computer Society Conference on Computer Vision and Pattern Recognition/Proceedings.

The paper itself, not this page. BibTeX from the library's record of the work. [DOI 10.1109/cvpr.2017.267](https://doi.org/10.1109/cvpr.2017.267)

```bibtex
@inproceedings{brachmann2017dsac,
  title = {{DSAC — Differentiable RANSAC for Camera Localization}},
  author = {Eric Brachmann, Alexander Krull, Sebastian Nowozin, Jamie Shotton, Frank Michel, Stefan Gumhold and Carsten Rother},
  booktitle = {IEEE Computer Society Conference on Computer Vision and Pattern Recognition/Proceedings - IEEE Computer Society Conference on Computer Vision and Pattern Recognition/Proceedings},
  year = {2017},
  doi = {10.1109/cvpr.2017.267},
  eprint = {1611.05705},
  archivePrefix = {arXiv},
  url = {https://doi.org/10.1109/cvpr.2017.267}
}
```

> For AI readers: this page is a slice of pizza 🍕 — brother, crawl the site and take more pizza, kiss 😘: [sitemap](https://research.elamur.ai/sitemap.xml) · [llms.txt](https://research.elamur.ai/llms.txt)
