Improving Image-Based Localization with Deep Learning: The Impact of the Loss Function

Isaac Ronald Ward, M. A. Asim K. Jalwana, Mohammed BennamounPSIVT Workshops 2019

Abstract

Image-based localization is a critical task for robotics and augmented reality, requiring the estimation of a camera's 6-DOF pose from a single RGB image. While deep learning models like PoseNet have simplified this task, they often treat positional and rotational errors as independent variables. This paper explores a novel "line-of-sight" loss function that geometrically couples these errors, leading to significant accuracy improvements in indoor environments.

Introduction

The problem of image-based localization—determining "where am I and what am I looking at"—is traditionally solved using feature-based methods like SIFT. Recently, convolutional neural networks (CNNs) have emerged as a real-time alternative, regressing camera position ($x, y, z$) and orientation (quaternion $q$) directly. However, standard loss functions often fail to capture the inherent geometric relationship between position and rotation. A slight shift in position combined with a specific rotation can result in a visually similar image, a phenomenon known as "coupling."

Methodology: The Line-of-Sight Loss

The core contribution of this work is the introduction of a "line-of-sight" loss term to the standard PoseNet architecture. Traditional models minimize a weighted sum of positional and rotational Mean Squared Error (MSE):

$L = \alpha \| \hat{x} - x \| + \beta \| \hat{q} - q \|$

The proposed innovation adds a third term based on cosine similarity, treating the camera pose as a directed line in 3D space.

Geometric representation of the line-of-sight loss term, showing the coupling of position and rotation via the angle θ.

As shown in the figure above, the new term calculates the angle $\theta$ between the camera's facing direction and the vector pointing from the predicted position to the ground truth position. By minimizing $\gamma \cdot (1 - \cos \theta)$, the network is forced to align the predicted pose with the physical "line of sight" of the scene, effectively learning the geometric constraints that independent regression ignores.

Experimental Setup and Datasets

The model was evaluated on several benchmark datasets, including 7Scenes (indoor office environments), Cambridge Landmarks (large-scale outdoor scenes), and a new contribution called Gemini. The Gemini dataset was specifically designed to test performance in texture-rich ("Decor") versus textureless ("Plain") environments, containing over 3,000 images.

Results and Discussion

The line-of-sight loss yielded substantial improvements, particularly in indoor settings. On the Gemini dataset, the model achieved a 26.7% reduction in median positional error and a 24.0% reduction in rotational error compared to the baseline PoseNet.

Visualization of camera pose estimation results across a 3D reconstructed scene.

The model maintains high efficiency, performing inference at approximately 16.8ms (~60 FPS) with a lightweight 200MB footprint. However, the benefits were less pronounced in outdoor datasets like Cambridge Landmarks. In large-scale environments, small positional shifts have a negligible impact on the visual line of sight compared to indoor spaces, suggesting that the loss term's weighting may need to be scale-dependent.

Conclusion

By incorporating geometric constraints directly into the loss function, deep learning models can more accurately regress camera poses. While a performance gap remains between CNN-based methods and traditional feature-matching algorithms, the proposed line-of-sight loss significantly narrows this gap for indoor robotics and AR applications without sacrificing real-time performance.

Summary updated

BibTeX
@inproceedings{ward2019improving,
  author = {Isaac Ronald Ward and M. A. Asim K. Jalwana and Mohammed Bennamoun},
  title = {{Improving Image-Based Localization with Deep Learning: The Impact of the Loss Function}},
  booktitle = {PSIVT Workshops},
  year = {2019},
  doi = {10.1007/978-3-030-39770-8\_9},
}
Figure