# colmap/glomap architecture

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

- Interactive diagram: https://gitdiagram.com/colmap/glomap
- Repository: https://github.com/colmap/glomap

## Overview

##### Main Components Identification
The system can be broken down into these major components based on the directory structure:

a. Core Components:
- Controllers (Pipeline Management)
- Estimators (Mathematical Computations)
- Scene Management
- Processors (Data Processing)
- I/O Operations
- Math Utilities

##### Component Relationships

- Blue: Input/Output components
- Green: Processing components
- Yellow: Mathematical computation components
- Gray: Utility components

##### Specific Implementation Details

Key architectural elements:
- COLMAP Integration points
- PoseLib Integration points
- Pipeline stages:
1. Feature extraction (external COLMAP)
2. Matching (external COLMAP)
3. Global mapping (GLOMAP core)
4. Reconstruction optimization

##### Technical Details to Highlight

- The global approach to SfM (vs. incremental)
- Integration with COLMAP database format
- Optimization pipeline stages
- Scene graph management

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        DB[("COLMAP Database")]:::input
        IMG["Image Directory"]:::input
    end

    subgraph "Core Processing"
        GMC["Global Mapper Controller"]:::controller
        TE["Track Establishment"]:::processor
        TR["Track Retriangulation"]:::processor
        BA["Bundle Adjustment"]:::estimator
        GP["Global Positioning"]:::estimator
        GRA["Global Rotation Averaging"]:::estimator
        VGC["View Graph Calibration"]:::estimator
    end

    subgraph "Scene Management"
        CM["Camera Models"]:::scene
        VG["View Graph"]:::scene
        TM["Track Management"]:::scene
    end

    subgraph "Math Utilities"
        R3D["Rigid3D Transformations"]:::math
        GC["Gravity Calculations"]:::math
        TVG["Two-View Geometry"]:::math
    end

    subgraph "I/O Operations"
        CI["COLMAP Integration"]:::io
        CC["COLMAP Converter"]:::io
    end

    subgraph "Additional Processing"
        IU["Image Undistorter"]:::processor
        RN["Reconstruction Normalizer"]:::processor
        VGM["View Graph Manipulation"]:::processor
    end

    subgraph Output
        SR[("COLMAP Sparse Reconstruction")]:::output
    end

    %% Relationships
    DB --> CI
    IMG --> CI
    CI --> GMC
    
    GMC --> TE
    GMC --> TR
    GMC --> BA
    GMC --> GP
    GMC --> GRA
    GMC --> VGC

    TE -.-> VG
    TR -.-> TM
    BA -.-> CM
    GP -.-> R3D
    GRA -.-> GC
    VGC -.-> TVG

    VG --> VGM
    TM --> RN
    CM --> IU

    GMC --> CC
    CC --> SR

    %% Click events
    click GMC "https://github.com/colmap/glomap/blob/main/glomap/controllers/global_mapper.h"
    click TE "https://github.com/colmap/glomap/blob/main/glomap/controllers/track_establishment.h"
    click TR "https://github.com/colmap/glomap/blob/main/glomap/controllers/track_retriangulation.h"
    click BA "https://github.com/colmap/glomap/blob/main/glomap/estimators/bundle_adjustment.h"
    click GP "https://github.com/colmap/glomap/blob/main/glomap/estimators/global_positioning.h"
    click GRA "https://github.com/colmap/glomap/blob/main/glomap/estimators/global_rotation_averaging.h"
    click VGC "https://github.com/colmap/glomap/blob/main/glomap/estimators/view_graph_calibration.h"
    click CM "https://github.com/colmap/glomap/blob/main/glomap/scene/camera.h"
    click VG "https://github.com/colmap/glomap/blob/main/glomap/scene/view_graph.h"
    click TM "https://github.com/colmap/glomap/blob/main/glomap/scene/track.h"
    click R3D "https://github.com/colmap/glomap/blob/main/glomap/math/rigid3d.h"
    click GC "https://github.com/colmap/glomap/blob/main/glomap/math/gravity.h"
    click TVG "https://github.com/colmap/glomap/blob/main/glomap/math/two_view_geometry.h"
    click CI "https://github.com/colmap/glomap/blob/main/glomap/io/colmap_io.h"
    click CC "https://github.com/colmap/glomap/blob/main/glomap/io/colmap_converter.h"
    click IU "https://github.com/colmap/glomap/blob/main/glomap/processors/image_undistorter.h"
    click RN "https://github.com/colmap/glomap/blob/main/glomap/processors/reconstruction_normalizer.h"
    click VGM "https://github.com/colmap/glomap/blob/main/glomap/processors/view_graph_manipulation.h"

    %% Styling
    classDef input fill:#AEC6CF
    classDef output fill:#AEC6CF
    classDef controller fill:#98FB98
    classDef processor fill:#98FB98
    classDef estimator fill:#FFEC8B
    classDef scene fill:#DDA0DD
    classDef math fill:#F0E68C
    classDef io fill:#B8860B

    %% Legend
    subgraph Legend
        L1[Input/Output]:::input
        L2[Processing]:::controller
        L3[Estimation]:::estimator
        L4[Scene Management]:::scene
        L5[Math Utilities]:::math
        L6[I/O Operations]:::io
    end
```
