Home

Awesome

CTRL-C: Camera calibration TRansformer with Line-Classification

This repository contains the official code and pretrained models for CTRL-C (Camera calibration TRansformer with Line-Classification). Jinwoo Lee, Hyunsung Go, Hyunjoon Lee, Sunghyun Cho, Minhyuk Sung and Junho Kim. ICCV 2021.

Single image camera calibration is the task of estimating the camera parameters from a single input image, such as the vanishing points, focal length, and horizon line. In this work, we propose Camera calibration TRansformer with Line-Classification (CTRL-C), an end-to-end neural network-based approach to single image camera calibration, which directly estimates the camera parameters from an image and a set of line segments. Our network adopts the transformer architecture to capture the global structure of an image with multi-modal inputs in an end-to-end manner. We also propose an auxiliary task of line classification to train the network to extract the global geometric information from lines effectively. Our experiments demonstrate that CTRL-C outperforms the previous state-of-the-art methods on the Google Street View and SUN360 benchmark datasets.

<img src="figs/architecture.png" alt="Model Architecture"/>

Results & Checkpoints

DatasetUp Dir (◦)Pitch (◦)Roll (◦)FoV (◦)AUC (%)URL
Google Street View1.801.580.663.5987.29gdrive
SUN3601.911.500.963.8085.45gdrive

Preparation

  1. Clone this repository.

  2. Setup environments.

    conda create -n ctrlc python
    conda activate ctrlc
    conda install -c pytorch torchvision
    
    pip install -r requirements.txt
    

Training Datasets

Training

python main.py --config-file 'config-files/ctrl-c.yaml' --opts OUTPUT_DIR 'logs'
python -m torch.distributed.launch --nproc_per_node=4 --use_env main.py --config-file 'config-files/ctrl-c.yaml' --opts OUTPUT_DIR 'logs'

Evaluation

Make logs folder and copy the downloaded checkpoint into logs folder. Pass the unzipped path to the google street view dataset as dataset_path.

python test.py --dataset 'GoogleStreetView' --dataset_path '../google_street_view_191210/manhattan/' --opts OUTPUT_DIR 'outputs'

single image inference

python test_image.py --sample 'sample.jpg' --opts OUTPUT_DIR 'outputs'

Citation

If you use this code for your research, please cite our paper:

@InProceedings{Lee:2021:ICCV,
    Title     = {{CTRL-C: Camera calibration TRansformer with Line-Classification}},
    Author    = {Jinwoo Lee and Hyunsung Go and Hyunjoon Lee and Sunghyun Cho and Minhyuk Sung and Junho Kim},    
    Booktitle = {Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV)},
    Year      = {2021},
}

License

CTRL-C is released under the Apache 2.0 license. Please see the LICENSE file for more information.

Acknowledgments

This code is based on the implementations of DETR: End-to-End Object Detection with Transformers.