Giter Club home page Giter Club logo

neuralrouting's Introduction

[CVPR 2021 Oral] Robust Neural Routing Through Space Partitions for Camera Relocalization in Dynamic Indoor Environments

*Siyan Dong, *Qingnan Fan, He Wang, Ji Shi, Li Yi, Thomas Funkhouser, Baoquan Chen, Leonidas J. Guibas

* Equal Contribution | Video | Poster

teaser

We provide the implementation of NeuralRouting, a novel outlier-aware neural tree model to estimate camera pose in dynamic environments. The model builds on three important blocks: (a) a hierarchical space partition over the indoor scene to construct a decision tree; (b) a neural routing function, implemented as a deep classification network, employed for better 3D scene understanding; and (c) an outlier rejection module used to filter out dynamic points during the hierarchical routing process. After establishing camera-to-world 3D-3D correspondences, a Kabsch based RANSAC is applied to solve the camera pose.

Overall, our algorithm consists of two steps: a scene coordinate regressor for 3D-3D correspondence establishment and a Kabsch-based RANSAC algorithm for camera pose optimization. The coordinate regressor is scene-specific and learned in each scene. At inference time, the camera pose is estimated by running the coordinate regressor and the RANSAC algorithm.

Citation

If you find our work helpful in your research, please consider citing:

@InProceedings{Dong_2021_CVPR,
    author    = {Dong, Siyan and Fan, Qingnan and Wang, He and Shi, Ji and Yi, Li and Funkhouser, Thomas and Chen, Baoquan and Guibas, Leonidas J.},
    title     = {Robust Neural Routing Through Space Partitions for Camera Relocalization in Dynamic Indoor Environments},
    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
    month     = {June},
    year      = {2021},
    pages     = {8544-8554}
}

Requirements

The codes in this repository are tested with Python 3.7.3, PyTorch 1.1.0, CUDA 10.0, OpenCV 4.5.1 and scikit-learn 0.21.2. We recommend running our code in the Docker container siyandong/neuralrouting:ransac_v0.2.

docker run -v <dataset folder>:/opt/dataset -it --gpus all --rm --entrypoint /bin/bash --name <container name> siyandong/neuralrouting:ransac_v0.2

In the container, run source activate NeuralRouting to activate the environment.

Dataset

The data follows the format of the RIO10 benchmark. To use the code, please download the dataset first.

In our experiments, we apply a random transformation to the original ground-truth camera poses each scene. The pre-computed parameters and pre-trained model weights rely on the transformed coordiante system. Therefore, run the following script to convert coordinate system before running our algorithm

python random_transformation.py --dataset_folder <dataset folder>

For example, python random_transformation.py --dataset_folder /opt/dataset. After camera pose estimation, run the same script with different argument to convert the estimation to the original coordinate system.

Training

In the training stage, we build the space partition tree and train the neural routing functions to memorize the static points while rejecting dynamic ones.

Set dataset_folder and scene_id in config.py.

Run the script

python train.py --exp_name <checkpoint folder>

For example, python train.py --exp_name rio10_scene01.

It will build the tree, train it level by level, and save the model parameters in the folder ./experiment/<checkpoint folder>.

You can find the pre-trained checkpoints here.

Test

Step1: Correspondence Establishment

Set dataset_folder and scene_id in config.py.

Run the script

python test.py --exp_name <checkpoint folder> --test_seq <sequence name>

For example, python test.py --exp_name rio10_scene01 --test_seq seq01_02.

It will infer pixel-wise scene coordinates (as GMM) and save them in the folder ./gmm_prediction.

Step2: Pose Optimization

The following two parts are both required to achieve the performance reported in the paper.

(a) RANSAC

You should run this part of codes in the Docker container siyandong/neuralrouting:ransac_v0.2. In the container, run the following commands

cd /opt/relocalizer_codes/spaint
python run_ransac.py --data_folder_mask <dataset folder mask> --scene_id <scene id> --sequence_id <sequence id> --prediction_folder <gmm prediction folder>

For example, python run_ransac.py --data_folder_mask /opt/dataset/scene{:02d}/seq{:02d}/seq{:02d}_{:02d} --scene_id 1 --sequence_id 2 --prediction_folder /opt/relocalizer_codes/NeuralRouting/gmm_prediction/rio10_scene01_seq01_02.

It will output the estimated camera poses in the folder /opt/relocalizer_codes/spaint/build/bin/apps/relocgui/reloc_poses.

(b) ICP Refinement

You should run this part of codes in the Docker container siyandong/neuralrouting:ransac_icp_v0.0. In the container, run the following commands

cd /opt/relocalizer_codes/spaint
python run_ransac_icp.py --data_folder_mask <dataset folder mask> --scene_id <scene id> --sequence_id <sequence id> --prediction_folder <gmm prediction folder>

For example, python run_ransac_icp.py --data_folder_mask /opt/dataset/scene{:02d}/seq{:02d} --scene_id 1 --sequence_id 2 --prediction_folder /opt/relocalizer_codes/NeuralRouting/gmm_prediction/rio10_scene01_seq01_02.

It will output the estimated camera poses in the folder /opt/relocalizer_codes/spaint/build/bin/apps/spaintgui/reloc_poses.

Coordinate System Conversion

To convert the pose estimation to the original scene coordinate system of the RIO10 benchmark, run

python random_transformation.py --pose_folder <camera pose estimation folder> --scene_id <scene id>

For example, python random_transformation.py --pose_folder /opt/relocalizer_codes/spaint/build/bin/apps/spaintgui/reloc_poses/20210620T112628 --scene_id 1.

Acknowledgments

In this repository, we use parts of the implementation from spaint and InfiniTAM. We thank the respective authors for open sourcing their code.

neuralrouting's People

Contributors

fqnchina avatar siyandong avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.