# openslam/orb_slam3 architecture

> Architecture diagram of the GitHub repository openslam/orb_slam3, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/openslam/orb_slam3
- Repository: https://github.com/openslam/orb_slam3

## Overview

##### Project type and purpose
- ORB-SLAM3 is an open-source C++ SLAM library (not a web or mobile app) providing Visual, Visual-Inertial and Multi-Map SLAM for Monocular, Stereo and RGB-D cameras.
- It delivers a core shared library (`libORB_SLAM3.so`), multiple example executables (in `Examples/`), ROS wrappers, and evaluation scripts.

##### File structure
- Top-level:
- `CMakeLists.txt`, build scripts (`build.sh`, `build_ros.sh`)
- `Dependencies.md`, `README.md`
- `include/` (public headers), `src/` (core implementation)
- `Thirdparty/DBoW2`, `Thirdparty/g2o` (embedded place-recognition & optimizer libs)
- `Vocabulary/ORBvoc.txt.tar.gz` (ORB vocabulary)
- `Examples/` (monocular, stereo, RGB-D, inertial, ROS)
- `evaluation/` (scripts & ground-truth for ATE evaluation)
- The library follows a multi-threaded, modular architecture:
- Frontend (Tracking, Initializer)
- Backend (LocalMapping, LoopClosing, Optimizer)
- Data structures (Map, KeyFrames, MapPoints, Databases)
- Visualization (Viewer via Pangolin)

##### README for additional insights
- Dependencies: Pangolin (UI), OpenCV (image processing), Eigen (linear algebra), DBoW2 & g2o (embedded).
- Usage: build shared library + examples; run scripts for EuRoC/TUM-VI; evaluate with Python.

## Diagram (Mermaid)

```mermaid
flowchart TD
  subgraph "Sensors & Input"
    direction TB
    Camera["Camera(s)"]:::external
    IMU["IMU"]:::external
  end

  subgraph "Core SLAM Library (libORB_SLAM3.so)"
    direction TB
    System["System"]:::entry
    Tracking["Tracking\n(Front-end thread)"]:::thread
    Initializer["Initializer\n(Mono Bootstrapping)"]:::thread
    LocalMapping["LocalMapping\n(Local BA thread)"]:::thread
    LoopClosing["LoopClosing\n(Global BA thread)"]:::thread
    ORBExt["ORBextractor"]:::thread
    ORBMatch["ORBmatcher"]:::thread
    MapDS["Map"]:::datastore
    MP["MapPoint"]:::datastore
    KF["KeyFrame"]:::datastore
    MapDB["KeyFrameDatabase"]:::datastore
    Optimizer["Optimizer\n(g2o)"]:::external
    Vocabulary["Vocabulary\n(DBoW2)"]:::external
    Viewer["Viewer\n(Pangolin)"]:::thread
  end

  subgraph "Thirdparty Libraries"
    direction TB
    DBoW2["DBoW2"]:::external
    g2o["g2o"]:::external
  end

  subgraph "Examples & Wrappers"
    direction TB
    Examples["Example Binaries"]:::cloud
    ROS["ROS Nodes"]:::cloud
  end

  subgraph "Evaluation & Tools"
    direction TB
    Eval["Python & Shell Scripts"]:::cloud
  end

  Camera -->|"frames"| System
  IMU -->|"IMU data"| System
  System -->|"pass frames"| Tracking
  Tracking -->|"extract features"| ORBExt
  Tracking -->|"match features"| ORBMatch
  ORBExt --> Tracking
  ORBMatch --> Tracking
  Tracking -->|"KeyFrame"| KF
  Tracking -->|"MapPoint"| MP
  KF --> MapDS
  KF --> MapDB
  MapDS --> LocalMapping
  MapDS --> LoopClosing
  MapDS --> Viewer
  Tracking --> Viewer
  LocalMapping -->|"local BA request"| Optimizer
  LoopClosing -->|"loop candidates"| Vocabulary
  Vocabulary --> MapDB
  LoopClosing -->|"global BA request"| Optimizer
  Optimizer --> MapDS
  DBoW2 --> Vocabulary
  g2o --> Optimizer
  System --> Examples
  System --> ROS
  MapDS --> Eval

  click System "https://github.com/openslam/orb_slam3/blob/master/include/System.h"
  click System "https://github.com/openslam/orb_slam3/blob/master/src/System.cc"
  click Tracking "https://github.com/openslam/orb_slam3/blob/master/include/Tracking.h"
  click Tracking "https://github.com/openslam/orb_slam3/blob/master/src/Tracking.cc"
  click Initializer "https://github.com/openslam/orb_slam3/blob/master/include/Initializer.h"
  click Initializer "https://github.com/openslam/orb_slam3/blob/master/src/Initializer.cc"
  click LocalMapping "https://github.com/openslam/orb_slam3/blob/master/include/LocalMapping.h"
  click LocalMapping "https://github.com/openslam/orb_slam3/blob/master/src/LocalMapping.cc"
  click LoopClosing "https://github.com/openslam/orb_slam3/blob/master/include/LoopClosing.h"
  click LoopClosing "https://github.com/openslam/orb_slam3/blob/master/src/LoopClosing.cc"
  click MapDS "https://github.com/openslam/orb_slam3/blob/master/include/Map.h"
  click MapDS "https://github.com/openslam/orb_slam3/blob/master/src/Map.cc"
  click MP "https://github.com/openslam/orb_slam3/blob/master/include/MapPoint.h"
  click MP "https://github.com/openslam/orb_slam3/blob/master/src/MapPoint.cc"
  click KF "https://github.com/openslam/orb_slam3/blob/master/include/KeyFrame.h"
  click KF "https://github.com/openslam/orb_slam3/blob/master/src/KeyFrame.cc"
  click MapDB "https://github.com/openslam/orb_slam3/blob/master/include/KeyFrameDatabase.h"
  click MapDB "https://github.com/openslam/orb_slam3/blob/master/src/KeyFrameDatabase.cc"
  click ORBExt "https://github.com/openslam/orb_slam3/blob/master/include/ORBextractor.h"
  click ORBExt "https://github.com/openslam/orb_slam3/blob/master/src/ORBextractor.cc"
  click ORBMatch "https://github.com/openslam/orb_slam3/blob/master/include/ORBmatcher.h"
  click ORBMatch "https://github.com/openslam/orb_slam3/blob/master/src/ORBmatcher.cc"
  click Optimizer "https://github.com/openslam/orb_slam3/blob/master/include/Optimizer.h"
  click Optimizer "https://github.com/openslam/orb_slam3/blob/master/src/Optimizer.cc"
  click Vocabulary "https://github.com/openslam/orb_slam3/blob/master/include/ORBVocabulary.h"
  click Vocabulary "https://github.com/openslam/orb_slam3/tree/master/Thirdparty/DBoW2"
  click Viewer "https://github.com/openslam/orb_slam3/blob/master/include/Viewer.h"
  click Viewer "https://github.com/openslam/orb_slam3/blob/master/src/Viewer.cc"

  classDef entry fill:#f9f,stroke:#333,stroke-width:1px
  classDef thread fill:#bbf,stroke:#333,stroke-width:1px,shape:roundrect
  classDef datastore fill:#fbb,stroke:#333,stroke-width:1px,shape:cylinder
  classDef external fill:#eee,stroke-dasharray:5 5,stroke:#333
  classDef cloud fill:#afa,stroke:#333,stroke-width:1px
```
