CTRL-C: Camera calibration TRansformer with Line-Classification

Jinwoo Lee, Hyunsung Go, Hyunjoon Lee, Sunghyun Cho, Min-Hyuk Sung, Junho Kim

TL;DR

CTRL-C (Camera calibration TRansformer with Line-Classification) is a novel end-to-end neural network that estimates camera parameters—like focal length and horizon line—from a single image. By combining a transformer architecture with an auxiliary line-classification task, it effectively fuses semantic image data with geometric line cues to achieve new state-of-the-art results.

What Problem Does This Paper Address?

Single-image camera calibration is the process of determining a camera's intrinsic (e.g., focal length) and extrinsic (e.g., tilt and roll) parameters from just one picture. This is a foundational task for applications like augmented reality, photo upright adjustment, and metrology.

Traditionally, this was done using classical geometry: detecting line segments and using algorithms like RANSAC to find vanishing points (VPs). However, these methods fail if line detection is noisy. Recent deep learning approaches using Convolutional Neural Networks (CNNs) have improved performance by learning "semantic" cues (like the shape of a building), but CNNs struggle to capture the global geometric relationships across an entire image. CTRL-C aims to bridge this gap by using a transformer to integrate both visual context and explicit geometric lines in a unified, end-to-end framework.

Methods

The authors introduce CTRL-C, which leverages the transformer's ability to handle multi-modal inputs as sequences of tokens.

  1. Multi-Modal Inputs: The model takes two inputs:
  2. Semantic Tokens: Extracted from the image using a ResNet-50 backbone and processed by a transformer encoder.
  3. Geometric Tokens: Line segments are detected using the LSD (Line Segment Detector) algorithm, converted into line equations, and embedded into tokens.
  4. Transformer Decoder: A transformer decoder aggregates these tokens. It uses "learned queries" for specific parameters (zenith VP, horizon line, and Field of View) to attend to both the image features and the detected lines.
  5. Auxiliary Line-Classification: To force the network to understand geometry, the authors add a task where the model must classify whether each detected line segment converges toward the zenith (vertical) VP or the horizontal VPs.
Figure 2. Our network estimates parameters for camera calibration from an input image and a set of line segments. Image features are extracted with the ResNet backbone, flattened and positionally encoded, and then passed into a transformer encoder network. Learned query embedding vectors are fed into a transformer decoder network, alongside with the line embedding vectors, so that queries can attend to image and line features. Two auxiliary outputs, vertical and horizontal convergence line scores, are used to further guide the network to learn the scene geometry for calibration.

Datasets

The model was trained and evaluated on two primary benchmarks:

  • Google Street View (GSV): A dataset of urban scenes curated for calibration tasks.
  • SUN360: A dataset of panoramic indoor and outdoor scenes.

To test generalization, the authors also evaluated the model on HoliCity, Horizon Lines in the Wild (HLW), and Eurasian Cities (ECD) without retraining on them. Because GSV and SUN360 lack ground-truth for horizontal vanishing points, the authors developed a method to estimate "pseudo-ground-truth" horizontal VPs to train their line classifier.

The process for estimating pseudo-horizontal vanishing points to provide supervision for the auxiliary classification task.

Key Insights and Ideas

  • Transformers for Geometry: While transformers are famous for NLP, their attention mechanism is perfectly suited for camera calibration because vanishing points are global properties determined by distant, related line segments across the whole image.
  • Lines as Tokens: Treating geometric line segments as tokens alongside image patches allows the model to "reason" about how a specific edge in the corner of an image relates to the overall perspective.
  • Classification as a Guide: The auxiliary task of classifying lines (vertical vs. horizontal) acts as a powerful regularizer. It ensures the transformer doesn't just memorize textures but actually learns the underlying perspective structure of the scene.

Key Results

CTRL-C outperformed all previous state-of-the-art (SotA) methods across multiple metrics.

  • Horizon Line Accuracy: On the GSV dataset, the Area Under the Curve (AUC) for horizon line estimation improved from the previous best of 83.12% to 87.29%.
  • Error Reduction: The model reduced mean errors for the "up direction," pitch, roll, and FoV by significant margins (e.g., a 40.3% reduction in FoV error compared to the previous SotA on GSV).
  • Robustness: Even in natural scenes with very few detected lines, the semantic features from the ResNet backbone allowed the model to maintain high accuracy where classical methods would fail.
Cumulative distribution of horizon line errors, showing CTRL-C (red) consistently outperforming other methods.

Limitations and Future Work

While CTRL-C is highly effective, it still relies on an external line detector (LSD) as a pre-processing step. If the line detector fails completely (e.g., in extremely blurry or low-texture images), the geometric branch of the network provides less utility.

The authors suggest that future work could involve self-supervised pre-training to further improve the model's ability to generalize to diverse, unseen environments without needing massive labeled datasets.

Summary updated

BibTeX
@misc{lee2021ctrl,
  author = {Jinwoo Lee and Hyunsung Go and Hyunjoon Lee and Sunghyun Cho and Min-Hyuk Sung and Junho Kim},
  title = {{CTRL-C: Camera calibration TRansformer with Line-Classification}},
  year = {2021},
  eprint = {2109.02259},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2109.02259},
}
Figure