Leveraging Image Matching Toward End-to-End Relative Camera Pose Regression

Fadi Khatib, Yuval Margalit, Meirav Galun, Ronen Basri

TL;DR

Researchers from the Weizmann Institute of Science have developed a new end-to-end deep learning method for relative camera pose regression that significantly improves accuracy and generalization. By leveraging pre-trained image matching features (LoFTR) and a novel loss function that separates translation direction from metric scale, their approach closes the performance gap between fast regression-based models and slower, classical geometric pipelines.

What Problem Does This Paper Address?

Determining the relative pose—the rotation and translation between two camera viewpoints—is a cornerstone of computer vision, essential for everything from autonomous drones to augmented reality.

Classical methods rely on matching individual points (like SIFT features) and solving geometric equations using RANSAC. While accurate, these methods are slow, struggle with repetitive textures, and crucially, cannot recover the absolute distance (scale) between cameras without extra information.

Recent "End-to-End Relative Pose Regression" (RPR) networks try to predict the pose directly from image pairs. While fast and capable of inferring scale from object sizes, they often fail to generalize to new environments and lack the precision of geometric methods. This paper aims to combine the best of both worlds: the speed and scale-awareness of deep learning with the geometric grounding of feature matching.

Methods

The authors propose a three-stage pipeline, as illustrated in their network architecture:

Figure 1. Network architecture. Our network is composed of three modules (top), LoFTR which given an image pair produces a coarse grid of features, a warping module, and a pose regression module. The bottom figure shows a detailed description of the warping and pose regression modules.
  1. Feature Extraction: Instead of training a feature extractor from scratch, they use a frozen LoFTR (Local Feature Transformer) backbone. LoFTR is pre-trained for image matching and uses self- and cross-attention to produce "semi-dense" feature maps that are aware of the context in both images.
  2. Matching and Warping: The model identifies corresponding points between the two images. It uses "hard matching" to warp the features from the second image to align with the grid of the first image. This creates a combined feature map of correspondences.
  3. Pose Regression: A residual network (ResNet) processes this warped map to predict three distinct components: a rotation quaternion ($\hat{q}$), a unit translation direction vector ($\hat{t}_{dir}$), and a scalar scale factor ($\hat{s}$).

A key innovation is the disentangled loss function. The authors argue that translation direction is a geometric property determined by point matches, while scale is a semantic property inferred from the size of known objects. By using a cosine similarity loss for direction and an $\ell_1$ loss for scale, they allow the network to learn these distinct tasks more effectively.

Datasets

The method was rigorously tested across several diverse benchmarks:

  • 7Scenes: A standard indoor dataset for visual relocalization.
  • ScanNet: A massive indoor dataset with wide baselines and texture-less regions.
  • Cambridge Landmarks: An outdoor urban dataset used to test generalization from indoor training.
  • Map-Free: A challenging outdoor benchmark with limited overlap and significant lighting changes between image pairs.

Key Insights and Ideas

  • Matching as a Pre-training Task: The most significant "aha moment" is that relative pose regression is essentially a downstream task of image matching. By using a frozen, high-quality matching backbone like LoFTR, the regression head can focus on interpreting geometric correspondences rather than learning basic visual features.
  • Geometric vs. Semantic Cues: Separating translation into direction and scale acknowledges that these two values come from different types of information in the image. This separation proved crucial for accuracy in their ablation studies.
  • Hard vs. Soft Warping: While some previous works used "soft" attention-based warping, this paper finds that "hard" warping (picking the single best match) provides a clearer signal for the regression module to estimate precise motion.

Key Results

The proposed method, referred to as "Ours," consistently outperformed existing end-to-end RPR baselines like RelPoseNet and 8Point.

Table 1. Results on the 7Scenes dataset showing significant improvements in position and orientation error.
  • Accuracy: On the 7Scenes dataset, the method improved position prediction by nearly 8cm and direction prediction by 15° compared to the best existing RPR methods.
  • Generalization: In "cross-scene" tests (training on six scenes and testing on a seventh), the model maintained its lead, showing it learns general geometric principles rather than just memorizing specific rooms.
  • Speed: The model is highly efficient, with an inference time of only 26ms on an Nvidia V100 GPU—significantly faster than feature-matching pipelines that require RANSAC and depth estimation (which can take over 100ms).

Limitations and Future Work

The primary limitation is the reliance on the warping module. If the initial feature matching fails—which often happens in cases of extremely wide baselines or zero overlap (as seen in some Map-Free samples)—the pose regression will also fail.

Additionally, because the LoFTR backbone is frozen, the model's performance is somewhat capped by the quality of the pre-trained features. The authors suggest that future work could explore more advanced network architectures or ways to fine-tune the backbone specifically for the regression task without losing its general matching capabilities.

Summary updated

Abstract

This paper proposes a generalizable, end-to-end deep learning-based method for relative pose regression between two images. Given two images of the same scene captured from different viewpoints, our method predicts the relative rotation and translation (including direction and scale) between the two respective cameras. Inspired by the classical pipeline, our method leverages Image Matching (IM) as a pre-trained task for relative pose regression. Specifically, we use LoFTR, an architecture that utilizes an attention-based network pre-trained on Scannet, to extract semi-dense feature maps, which are then warped and fed into a pose regression network. Notably, we use a loss function that utilizes separate terms to account for the translation direction and scale. We believe such a separation is important because translation direction is determined by point correspondences while the scale is inferred from prior on shape sizes. Our ablations further support this choice. We evaluate our method on several datasets and show that it outperforms previous end-to-end methods. The method also generalizes well to unseen datasets.
BibTeX
@inproceedings{khatib2024leveraging,
  author = {Fadi Khatib and Yuval Margalit and Meirav Galun and Ronen Basri},
  title = {{Leveraging Image Matching Toward End-to-End Relative Camera Pose Regression}},
  booktitle = {GCPR},
  year = {2024},
  doi = {10.1007/978-3-031-85187-2\_12},
}
Figure