All Projects → cvg → Hierarchical Localization

cvg / Hierarchical Localization

Licence: apache-2.0
Visual localization made easy with hloc

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Hierarchical Localization

PCLoc
Pose Correction for Highly Accurate Visual Localization in Large-scale Indoor Spaces (ICCV 2021)
Stars: ✭ 37 (-96.29%)
Mutual labels:  image-retrieval, pose-estimation
Map Based Visual Localization
A general framework for map-based visual localization. It contains 1) Map Generation which support traditional features or deeplearning features. 2) Hierarchical-Localizationvisual in visual(points or line) map. 3)Fusion framework with IMU, wheel odom and GPS sensors.
Stars: ✭ 229 (-77.03%)
Mutual labels:  pose-estimation, image-retrieval
Kapture
kapture is a file format as well as a set of tools for manipulating datasets, and in particular Visual Localization and Structure from Motion data.
Stars: ✭ 128 (-87.16%)
Mutual labels:  image-retrieval, structure-from-motion
kapture-localization
Provide mapping and localization pipelines based on kapture format
Stars: ✭ 111 (-88.87%)
Mutual labels:  structure-from-motion, image-retrieval
Pyretri
Open source deep learning based unsupervised image retrieval toolbox built on PyTorch🔥
Stars: ✭ 795 (-20.26%)
Mutual labels:  image-retrieval
Hand3d
Network estimating 3D Handpose from single color images
Stars: ✭ 690 (-30.79%)
Mutual labels:  pose-estimation
Deep metric
Deep Metric Learning
Stars: ✭ 671 (-32.7%)
Mutual labels:  image-retrieval
Theiasfm
An open source library for multiview geometry and structure from motion
Stars: ✭ 647 (-35.11%)
Mutual labels:  structure-from-motion
Mxnet Ir
Image Retrieval Experiment Using Triplet Loss
Stars: ✭ 27 (-97.29%)
Mutual labels:  image-retrieval
Awesome Learning Mvs
A list of awesome learning-based multi-view stereo papers
Stars: ✭ 27 (-97.29%)
Mutual labels:  structure-from-motion
Convolutional Pose Machines Tensorflow
Stars: ✭ 758 (-23.97%)
Mutual labels:  pose-estimation
Boofcv
Fast computer vision library for SFM, calibration, fiducials, tracking, image processing, and more.
Stars: ✭ 706 (-29.19%)
Mutual labels:  structure-from-motion
Ddsh Tip2018
source code for paper "Deep Discrete Supervised Hashing"
Stars: ✭ 16 (-98.4%)
Mutual labels:  image-retrieval
Mmpose
OpenMMLab Pose Estimation Toolbox and Benchmark.
Stars: ✭ 674 (-32.4%)
Mutual labels:  pose-estimation
Cbir System
Content-Based Image Retrieval system (KTH DD2476 Project)
Stars: ✭ 9 (-99.1%)
Mutual labels:  image-retrieval
Openpifpaf
Official implementation of "OpenPifPaf: Composite Fields for Semantic Keypoint Detection and Spatio-Temporal Association" in PyTorch.
Stars: ✭ 662 (-33.6%)
Mutual labels:  pose-estimation
Meshroom
3D Reconstruction Software
Stars: ✭ 7,254 (+627.58%)
Mutual labels:  structure-from-motion
Pytorch Pose
A PyTorch toolkit for 2D Human Pose Estimation.
Stars: ✭ 932 (-6.52%)
Mutual labels:  pose-estimation
Lire
Open source library for content based image retrieval / visual information retrieval.
Stars: ✭ 740 (-25.78%)
Mutual labels:  image-retrieval
Keras realtime multi Person pose estimation
Keras version of Realtime Multi-Person Pose Estimation project
Stars: ✭ 728 (-26.98%)
Mutual labels:  pose-estimation

hloc - the hierarchical localization toolbox

This is hloc, a modular toolbox for state-of-the-art 6-DoF visual localization. It implements Hierarchical Localization, leveraging image retrieval and feature matching, and is fast, accurate, and scalable. This codebase won the indoor/outdoor localization challenge at CVPR 2020, in combination with SuperGlue, our graph neural network for feature matching.

With hloc, you can:

  • Reproduce our CVPR 2020 winning results on outdoor (Aachen) and indoor (InLoc) datasets
  • Run Structure-from-Motion with SuperPoint+SuperGlue to localize with your own datasets
  • Evaluate your own local features or image retrieval for visual localization
  • Implement new localization pipelines and debug them easily 🔥


Hierachical Localization uses both image retrieval and feature matching

Installation

hloc requires Python >=3.6, PyTorch >=1.1, and COLMAP. Other minor dependencies are listed in requirements.txt. For pose estimation, we use pycolmap, which can be installed as:

pip install git+https://github.com/mihaidusmanu/pycolmap

This codebase includes external local features as git submodules – don't forget to pull submodules with git submodule update --init --recursive. Your local features are based on TensorFlow? No problem! See below for the steps.

We also provide a Docker image that includes COLMAP and other dependencies:

docker build -t hloc:latest .
docker run -it --rm -p 8888:8888 hloc:latest  # for GPU support, add `--runtime=nvidia`
jupyter notebook --ip 0.0.0.0 --port 8888 --no-browser --allow-root

General pipeline

The toolbox is composed of scripts, which roughly perform the following steps:

  1. Extract SuperPoint local features for all database and query images
  2. Build a reference 3D SfM model
    1. Find covisible database images, with retrieval or a prior SfM model
    2. Match these database pairs with SuperGlue
    3. Triangulate a new SfM model with COLMAP
  3. Find database images relevant to each query, using retrieval
  4. Match the query images with SuperGlue
  5. Run the localization
  6. Visualize and debug

The localization can then be evaluated on visuallocalization.net for the supported datasets. When 3D Lidar scans are available, such as for the indoor dataset InLoc, step 2. can be skipped.

Strcture of the toolbox:

  • hloc/*.py : top-level scripts
  • hloc/extractors/ : interfaces for feature extractors
  • hloc/matchers/ : interfaces for feature matchers

Tasks

We provide step-by-step guides to localize with Aachen, InLoc, and to generate reference poses for your own data using SfM. Just download the datasets and you're reading to go!

Aachen – outdoor localization

Have a look at pipeline_Aachen.ipynb for a step-by-step guide on localizing with Aachen. Play with the visualization, try new local features or matcher, and have fun! Don't like notebooks? You can also run all scripts from the command line.

InLoc – indoor localization

The notebook pipeline_InLoc.ipynb shows the steps for localizing with InLoc. It's much simpler since a 3D SfM model is not needed.

SfM reconstruction from scratch

We show in pipeline_SfM.ipynb how to run 3D reconstruction for an unordered set of images. This generates reference poses, and a nice sparse 3D model suitable for localization with the same pipeline as Aachen.

Results

hloc currently supports SuperPoint and D2-Net local feature extractors; and SuperGlue and Nearest Neighbor matchers. Using NetVLAD for retrieval, we obtain the following best results:

Methods Aachen day Aachen night Retrieval
SuperPoint + SuperGlue 89.6 / 95.4 / 98.8 86.7 / 93.9 / 100 NetVLAD top 50
SuperPoint + NN 85.4 / 93.3 / 97.2 75.5 / 86.7 / 92.9 NetVLAD top 30
D2Net (SS) + NN 84.6 / 91.4 / 97.1 83.7 / 90.8 / 100 NetVLAD top 30
Methods InLoc DUC1 InLoc DUC2 Retrieval
SuperPoint + SuperGlue 46.5 / 65.7 / 78.3 52.7 / 72.5 / 79.4 NetVLAD top 40
SuperPoint + SuperGlue (temporal) 49.0 / 68.7 / 80.8 53.4 / 77.1 / 82.4 NetVLAD top 40
SuperPoint + NN 39.9 / 55.6 / 67.2 37.4 / 57.3 / 70.2 NetVLAD top 20
D2Net (SS) + NN 39.9 / 57.6 / 67.2 36.6 / 53.4 / 61.8 NetVLAD top 20

Check out visuallocalization.net/benchmark for more details and additional baselines.

BibTex Citation

If you report any of the above results in a publication, or use any of the tools provided here, please consider citing both Hierarchical Localization and SuperGlue papers:

@inproceedings{sarlin2019coarse,
  title     = {From Coarse to Fine: Robust Hierarchical Localization at Large Scale},
  author    = {Paul-Edouard Sarlin and
               Cesar Cadena and
               Roland Siegwart and
               Marcin Dymczyk},
  booktitle = {CVPR},
  year      = {2019}
}

@inproceedings{sarlin2020superglue,
  title     = {{SuperGlue}: Learning Feature Matching with Graph Neural Networks},
  author    = {Paul-Edouard Sarlin and
               Daniel DeTone and
               Tomasz Malisiewicz and
               Andrew Rabinovich},
  booktitle = {CVPR},
  year      = {2020},
}

Going further

Debugging and Visualization

[Click to expand]

Each localization run generates a pickle log file. For each query, it contains the selected database images, their matches, and information from the pose solver, such as RANSAC inliers. It can thus be parsed to gather statistics and analyze failure modes or difficult scenarios.

We also provide some visualization tools in hloc/visualization.py to visualize some attributes of the 3D SfM model, such as visibility of the keypoints, their track length, or estimated sparse depth (like below).

Using your own local features or matcher

[Click to expand]

If your code is based on PyTorch: simply add a new interface in hloc/extractors/ or hloc/matchers/. It needs to inherit from hloc.utils.base_model.BaseModel, take as input a data dictionary, and output a prediction dictionary. Have a look at hloc/extractors/superpoint.py for an example. You can additionally define a standard configuration in hloc/extract_features.py or hloc/match_features.py - it can then be called directly from the command line.

If your code is based on TensorFlow: you will need to either modify hloc/extract_features.py and hloc/match_features.py, or export yourself the features and matches to HDF5 files, described below.

In a feature file, each key corresponds to the relative path of an image w.r.t. the dataset root (e.g. db/1.jpg for Aachen), and has one dataset per prediction (e.g. keypoints and descriptors, with shape Nx2 and DxN).

In a match file, each key corresponds to the string path0.replace('/', '-')+'_'+path1.replace('/', '-') and has a dataset matches0 with shape N. It indicates, for each keypoint in the first image, the index of the matching keypoint in the second image, or -1 if the keypoint is unmatched.

Using your own image retrieval

[Click to expand]

For now hloc does not have an interface for image retrieval. You will need to export the global descriptors into an HDF5 file, in which each key corresponds to the relative path of an image w.r.t. the dataset root, and contains a dataset global_descriptor with size D. You can then export the images pairs with hloc/pairs_from_retrieval.py.

Contributions welcome!

External contributions are very much welcome. This is a non-exaustive list of features that might be valuable additions:

  • [ ] more localization datasets (RobotCar Seasons, CMU Seasons, Aachen v1.1, Cambridge Landmarks, 7Scenes)
  • [ ] covisibility clustering for InLoc
  • [ ] visualization of the raw predictions (features and matches)
  • [ ] interfaces for image retrieval (e.g. DIR, NetVLAD)
  • [ ] other local features

Created and maintained by Paul-Edouard Sarlin.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].