luigifreda/pyslam

pySLAM is a hybrid Python/C++ Visual SLAM pipeline supporting monocular, stereo, and RGB-D cameras. It provides a broad set of modern local and global feature extractors, multiple loop-closure strategies, a volumetric reconstruction module, integrated depth-prediction models, and semantic segmentation capabilities for enhanced scene understanding.

pySLAM is an open-source framework for Visual SLAM — a technology that lets a camera figure out where it is in space while simultaneously building a 3D map of its surroundings. It's written in a mix of Python and C++ and is designed to be a flexible research tool for experimenting with different algorithms.

What it does

  • Works with monocular (single camera), stereo (two cameras), and RGBD (color + depth) camera inputs.
  • Provides a complete pipeline for visual odometry (estimating camera motion) and full SLAM (motion + mapping).
  • Supports a wide range of local features (ways to detect and describe distinctive points in images), loop closing (recognizing previously visited places to correct drift), and global descriptors (whole-image signatures for place recognition).
  • Can build dense 3D reconstructions using volumetric integration, including TSDF and Gaussian Splatting.
  • Integrates depth prediction models (estimating depth from single images) and semantic segmentation (understanding what objects are in the scene).
  • Includes a C++ core for high performance, with Python bindings, so you can switch between speed and flexibility.
  • Supports over 10 dataset formats (KITTI, TUM, EuRoC, etc.) for easy testing.

Main scripts (run from the command line)

  • main_vo.py – basic visual odometry (requires ground truth for scale).
  • main_slam.py – full SLAM with mapping, loop closing, and dense reconstruction.
  • main_feature_matching.py – test different feature detectors and matchers.
  • main_depth_prediction.py – run depth estimation models.
  • main_map_viewer.py – visualize a saved map.
  • main_map_dense_reconstruction.py – create a dense reconstruction from a saved map.
  • main_slam_evaluation.py – automated evaluation across datasets.
  • main_semantic_image_segmentation.py – semantic segmentation on video.
  • main_scene_from_views.py – infer 3D scenes from multiple images using models like DUSt3R.

Installation

  • Clone the repository with submodules.
  • Run ./install_all.sh (on Ubuntu/macOS) to set up a Python environment (uses conda or venv).
  • Requires Python 3.11.9, OpenCV ≥4.10, PyTorch ≥2.3.1, TensorFlow ≥2.13.1, and CUDA for some features.

Usage

  • Activate the environment (. pyenv-activate.sh or pixi shell).
  • Run a script, e.g., ./main_vo.py.
  • Configuration is done via config.yaml and pyslam/config_parameters.py.

Supported components (all listed in the README)

  • Local features: SIFT, SURF, ORB, etc.
  • Matchers: various matching algorithms.
  • Global descriptors: NetVLAD, CosPlace, etc.
  • Depth prediction: DepthPro, DepthAnythingV2, etc.
  • Volumetric mapping: TSDF, voxel hashing, Gaussian Splatting.
  • Semantic segmentation: DeepLabv3, Segformer, CLIP, etc.
  • Feed-forward 3D inference: DUSt3R, Mast3r, VGGT, etc.

Key point: pySLAM is a research framework, not a polished product. It's meant for experimentation and prototyping, and it's under active development.

Related

  • Project
  • Project
  • Project
  • Project
  • Project