Need help with pyslam?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

914 Stars 159 Forks GNU General Public License v3.0 103 Commits 9 Opened issues


pySLAM contains a monocular Visual Odometry (VO) pipeline in Python. It supports many modern local features based on Deep Learning.

Services available


Need anything else?

Contributors list

# 119,605
99 commits
# 500,165
1 commit

pySLAM v2

Author: Luigi Freda

pySLAM contains a python implementation of a monocular Visual Odometry (VO) pipeline. It supports many classical and modern local features, and it offers a convenient interface for them. Moreover, it collects other common and useful VO and SLAM tools.

I released pySLAM v1 for educational purposes, for a computer vision class I taught. I started developing it for fun as a python programming exercise, during my free time, taking inspiration from some repos available on the web.

Main Scripts: *
combines the simplest VO ingredients without performing any image point triangulation or windowed bundle adjustment. At each step $k$,
estimates the current camera pose $Ck$ with respect to the previous one $C{k-1}$. The inter-frame pose estimation returns $[R{k-1,k},t{k-1,k}]$ with $||t{k-1,k}||=1$. With this very basic approach, you need to use a ground truth in order to recover a correct inter-frame scale $s$ and estimate a valid trajectory by composing $Ck = C{k-1} * [R{k-1,k}, s t_{k-1,k}]$. This script is a first start to understand the basics of inter-frame feature tracking and camera pose estimation.
    adds feature tracking along multiple frames, point triangulation, keyframe management and bundle adjustment in order to estimate the camera trajectory up-to-scale and build a map. It's still a VO pipeline but it shows some basic blocks which are necessary to develop a real visual SLAM pipeline.

You can use this framework as a baseline to play with local features, VO techniques and create your own (proof of concept) VO/SLAM pipeline in python. When you test it, consider that's a work in progress, a development framework written in Python, without any pretence of having state-of-the-art localization accuracy or real-time performances.

Enjoy it!

VO SLAM Feature Matching


  • [2021.02]
    • added support for BEBLID and DISK local features
    • added support for OpenCV 4.5.1
    • improved keyframe culling
    • added support for macOS Big Sur
    • updated install scripts


Clone this repo and its modules by running

$ git clone --recursive

The framework has been developed and tested under Ubuntu 18.04.
A specific install procedure is available for: - Ubuntu 20.04 - MacOs

I am currently working to unify the install procedures.


  • Python 3.6.9
  • Numpy (1.18.2)
  • OpenCV (4.5.1 supported, see below for a suggested python installation)
  • PyTorch (>= 1.4.0)
  • Tensorflow-gpu 1.14.0

If you run into troubles or performance issues, check this file.

Install pySLAM in Your Working Python Environment

If you want to launch
, run the script:

$ ./

in order to automatically install the basic required system and python3 packages. Here, pip3 is used.

If you want to run
, you must additionally install the libs pangolin, g2opy, etc. by running:

$ ./

Install pySLAM in a Custom Python Virtual Environment

If you do not want to mess up your working python environment, you can create a new virtual environment

by easily launching the scripts described here.

If you prefer conda, run the scripts described in this other file.

N.B.: you just need a single python environment to be able to work with all the supported local features!

Install pySLAM under Ubuntu 20.04

Download this repo and move into the experimental branch

$ git checkout ubuntu20  
and then follow the instructions for creating a new virtual environment
described here.

Install pySLAM on macOS

Check the instructions in this file.

How to install non-free OpenCV modules

The script
takes care of installing the new available opencv version (4.5.1 on Ubuntu 18). In order to use non-free OpenCV features (i.e. SURF, etc.), you need to install the module
built with the enabled option
. You can find SURF availalble in
: this can be installed by running
$ pip3 uninstall opencv-contrib-python
$ pip3 install opencv-contrib-python==

How to check your installed OpenCV version:

$ python3 -c "import cv2; print(cv2.__version__)"
For a more advanced OpenCV installation procedure, you can take a look here.

Issues and Errors

If you run into issues or errors during the installation process or at run-time, please, check the file


Once you have run the script
, you can immediately run:
$ python3 -O
This will process a KITTI video (available in the folder
) by using its corresponding camera calibration file (available in the folder
), and its groundtruth (available in the same
folder). You can stop
by focusing on the Trajectory window and pressing the key 'Q'.

N.B.: as explained above, the basic script
strictly requires a ground truth.

In order to process a different dataset, you need to set the file

: * select your dataset
in the section
(see the section Datasets below for further details) * the camera settings file accordingly (see the section Camera Settings below) * the groudtruth file accordingly (ee the section Datasets below and check the files

Once you have run the script
(as required above), you can test
by running:
$ python3 -O

This will process a KITTI video (available in the folder

) by using its corresponding camera calibration file (available in the folder
). You can stop it by focusing on the opened Figure 1 window and pressing the key 'Q'.

You can choose any detector/descriptor among ORB, SIFT, SURF, BRISK, AKAZE, SuperPoint, etc. (see the section Supported Local Features below for further information).

Some basic test/example files are available in the subfolder

. In particular, as for feature detection/description/matching, you can start by taking a look at test/cv/ and test/cv/

N.B.:: due to information loss in video compression,
tracking may peform worse with the available KITTI videos than with the original KITTI image sequences. The available videos are intended to be used for a first quick test. Please, download and use the original KITTI image sequences as explained below.

Supported Local Features

At present time, the following feature detectors are supported: * FAST
* Good features to track * ORB
* ORB2 (improvements of ORB-SLAM2 to ORB detector) * SIFT
* AGAST * MSER * StarDector/CenSurE * Harris-Laplace * SuperPoint * D2-Net * DELF * Contextdesc * LFNet * R2D2 * Key.Net * DISK

The following feature descriptors are supported: * ORB
* FREAK * SuperPoint * Tfeat * BOOST_DESC * DAISY * LATCH * LUCID * VGG * Hardnet * GeoDesc * SOSNet * L2Net * Log-polar descriptor * D2-Net * DELF * Contextdesc * LFNet * R2D2 * BEBLID * DISK

You can find further information in the file Some of the local features consist of a joint detector-descriptor. You can start playing with the supported local features by taking a look at


In both the scripts
, you can create your favourite detector-descritor configuration and feed it to the function
. Some ready-to-use configurations are already available in the file

The function

can be found in the file
. Take a look at the file
for further details.

N.B.: you just need a single python environment to be able to work with all the supported local features!


You can use 4 different types of datasets:


type in

KITTI odometry data set (grayscale, 22 GB)
TUM dataset
video file
folder of images

KITTI Datasets

pySLAM code expects the following structure in the specified KITTI path folder (specified in the section

of the file
). : ``` ├── sequences ├── 00 ... ├── 21 ├── poses ├── 00.txt ... ├── 10.txt
1. Download the dataset (grayscale images) from and prepare the KITTI folder as specified above

  1. Select the corresponding calibration settings file (parameter [KITTI_DATASET][cam_settings] in the file config.ini)

TUM Datasets

pySLAM code expects a file associations.txt in each TUM dataset folder (specified in the section [TUM_DATASET] of the file config.ini).

  1. Download a sequence from and uncompress it.

  2. Associate RGB images and depth images using the python script You can generate your associations.txt file by executing:

$ python PATHTOSEQUENCE/rgb.txt PATHTOSEQUENCE/depth.txt > associations.txt ``

3. Select the corresponding calibration settings file (parameter
in the file

Camera Settings

The folder

contains the camera settings files which can be used for testing the code. These are the same used in the framework ORBSLAM2. You can easily modify one of those files for creating your own new calibration file (for your new datasets).

In order to calibrate your camera, you can use the scripts in the folder

. In particular: 1. use the script
to collect a sequence of images where the chessboard can be detected (set the chessboard size therein, you can use the calibration pattern
in the same folder) 2. use the script
to process the collected images and compute the calibration parameters (set the chessboard size therein)

For further information about the calibration process, you may want to have a look here.

If you want to use your camera, you have to: * calibrate it and configure WEBCAM.yaml accordingly * record a video (for instance, by using
in the folder
) * configure the
section of
in order to point to your video.

Contributing to pySLAM

I would be very grateful if you would contribute to the code base by reporting bugs, leaving comments and proposing new features through issues and pull requests. Please feel free to get in touch at luigifreda(at)gmail[dot]com. Thank you!


Suggested books: * Multiple View Geometry in Computer Vision by Richard Hartley and Andrew Zisserman * An Invitation to 3-D Vision by Yi-Ma, Stefano Soatto, Jana Kosecka, S. Shankar Sastry * Computer Vision: Algorithms and Applications, by Richard Szeliski * Deep Learning, by Ian Goodfellow, Yoshua Bengio and Aaron Courville * Neural Networks and Deep Learning, By Michael Nielsen

Suggested material: * Vision Algorithms for Mobile Robotics by Davide Scaramuzza * CS 682 Computer Vision by Jana Kosecka
* ORB-SLAM: a Versatile and Accurate Monocular SLAM System by R. Mur-Artal, J. M. M. Montiel, and J. D. Tardos * Double Window Optimisation for Constant Time Visual SLAM by H. Strasdat, A. J. Davison J.M.M. Montielb, K. Konolige * The Role of Wide Baseline Stereo in the Deep Learning World by Dmytro Mishkin * To Learn or Not to Learn: Visual Localization from Essential Matrices by Qunjie Zhou, Torsten Sattler, Marc Pollefeys, Laura Leal-Taixe * Awesome local-global descriptors repository

Moreover, you may want to have a look at the OpenCV guide or tutorials.



Many improvements and additional features are currently under development:

  • loop closure
  • relocalization
  • map saving/loading
  • modern DL matching algorithms
  • object detection and semantic segmentation
  • 3D dense reconstruction

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.