# rohana96/sfm architecture

> Architecture diagram of the GitHub repository rohana96/sfm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rohana96/sfm
- Repository: https://github.com/rohana96/sfm

## Overview

This repository is a command-line Structure-from-Motion project with two in-house reconstruction workflows and an optional COLMAP workflow. The primary workflow reconstructs a sparse 3D scene from matched views: estimate two-view geometry and triangulate, or incrementally estimate camera poses and add points. README capabilities guide the map; source excerpts support the main orchestration and numerical calls, but some documented features are not independently wired in the sampled CLI.

Main entry points: [`main.py`](https://github.com/rohana96/sfm/blob/main/main.py) (Command runner), [`src/sfM.py`](https://github.com/rohana96/sfm/blob/main/src/sfM.py) (Incremental reconstruction), [`src/colmap.py`](https://github.com/rohana96/sfm/blob/main/src/colmap.py) (COLMAP runner), [`src/ransac.py`](https://github.com/rohana96/sfm/blob/main/src/ransac.py) (Robust F estimation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI entry"]
  node_cli["Command runner<br/>[main.py]"]
end

subgraph group_two_view["Two-view SfM"]
  node_monument_data["Monument inputs"]
  node_ransac["Robust F estimation<br/>[ransac.py]"]
  node_fundamental["Seven/eight-point F"]
  node_geometry_utils["Geometry utilities<br/>[utils.py]"]
  node_pose_init["Essential pose selection<br/>[sfM_two_view.py]"]
end

subgraph group_incremental["Incremental SfM"]
  node_triangulation["Point triangulation<br/>[triangulate.py]"]
  node_cow_data["Multi-view inputs"]
  node_incremental_sfm["Incremental reconstruction<br/>[sfM.py]"]
  node_visualization["3D visualization<br/>[utils.py]"]
end

subgraph group_colmap["COLMAP reconstruction"]
  node_colmap_runner["COLMAP runner<br/>[colmap.py]"]
  node_colmap_engine["COLMAP engine"]
end

node_user(("User"))
node_scene_output["Reconstruction outputs"]

node_user -->|"selects run"| node_cli
node_cli -->|"loads inputs"| node_monument_data
node_cli -->|"estimates F"| node_ransac
node_ransac -->|"fits candidates"| node_fundamental
node_ransac -->|"scores epipolar error"| node_geometry_utils
node_cli -->|"selects pose"| node_pose_init
node_pose_init -->|"decomposes E"| node_geometry_utils
node_pose_init -->|"tests candidates"| node_triangulation
node_cli -->|"runs incremental SfM"| node_incremental_sfm
node_incremental_sfm -->|"loads cameras and matches"| node_cow_data
node_incremental_sfm -->|"triangulates point sets"| node_triangulation
node_incremental_sfm -->|"plots point clouds"| node_visualization
node_cli -->|"runs COLMAP"| node_colmap_runner
node_colmap_runner -->|"extracts, matches, maps"| node_colmap_engine
node_colmap_runner -->|"plots reconstructed points"| node_visualization
node_visualization -->|"saves animations"| node_scene_output
node_colmap_runner -->|"writes model"| node_scene_output

click node_cli "https://github.com/rohana96/sfm/blob/main/main.py"
click node_monument_data "https://github.com/rohana96/sfm/tree/main/data/monument"
click node_ransac "https://github.com/rohana96/sfm/blob/main/src/ransac.py"
click node_fundamental "https://github.com/rohana96/sfm/blob/main/src/compute_fundamental.py"
click node_geometry_utils "https://github.com/rohana96/sfm/blob/main/utils.py"
click node_pose_init "https://github.com/rohana96/sfm/blob/main/src/sfM_two_view.py"
click node_triangulation "https://github.com/rohana96/sfm/blob/main/src/triangulate.py"
click node_cow_data "https://github.com/rohana96/sfm/tree/main/data/data_cow"
click node_incremental_sfm "https://github.com/rohana96/sfm/blob/main/src/sfM.py"
click node_visualization "https://github.com/rohana96/sfm/blob/main/utils.py"
click node_colmap_runner "https://github.com/rohana96/sfm/blob/main/src/colmap.py"
click node_scene_output "https://github.com/rohana96/sfm/tree/main/out"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_user toneBlue
class node_monument_data,node_ransac,node_fundamental,node_geometry_utils,node_pose_init toneAmber
class node_triangulation,node_cow_data,node_incremental_sfm,node_visualization toneMint
class node_colmap_runner,node_colmap_engine toneRose
class node_scene_output toneTeal
```

## Components

### CLI entry

- [Command runner](https://github.com/rohana96/sfm/blob/main/main.py): `main.py`

### Two-view SfM

- [Monument inputs](https://github.com/rohana96/sfm/tree/main/data/monument): `data/monument`
- [Robust F estimation](https://github.com/rohana96/sfm/blob/main/src/ransac.py): `src/ransac.py`
- [Seven/eight-point F](https://github.com/rohana96/sfm/blob/main/src/compute_fundamental.py): `src/compute_fundamental.py`
- [Geometry utilities](https://github.com/rohana96/sfm/blob/main/utils.py): `utils.py`
- [Essential pose selection](https://github.com/rohana96/sfm/blob/main/src/sfM_two_view.py): `src/sfM_two_view.py`

### Incremental SfM

- [Point triangulation](https://github.com/rohana96/sfm/blob/main/src/triangulate.py): `src/triangulate.py`
- [Multi-view inputs](https://github.com/rohana96/sfm/tree/main/data/data_cow): `data/data_cow`
- [Incremental reconstruction](https://github.com/rohana96/sfm/blob/main/src/sfM.py): `src/sfM.py`
- [3D visualization](https://github.com/rohana96/sfm/blob/main/utils.py): `utils.py`

### COLMAP reconstruction

- [COLMAP runner](https://github.com/rohana96/sfm/blob/main/src/colmap.py): `src/colmap.py`
- **COLMAP engine**

### Other components

- **User**
- [Reconstruction outputs](https://github.com/rohana96/sfm/tree/main/out): `out`

## Connections

- User → Command runner: selects run
- Command runner → Monument inputs: loads inputs
- Command runner → Robust F estimation: estimates F
- Robust F estimation → Seven/eight-point F: fits candidates
- Robust F estimation → Geometry utilities: scores epipolar error
- Command runner → Essential pose selection: selects pose
- Essential pose selection → Geometry utilities: decomposes E
- Essential pose selection → Point triangulation: tests candidates
- Command runner → Incremental reconstruction: runs incremental SfM
- Incremental reconstruction → Multi-view inputs: loads cameras and matches
- Incremental reconstruction → Point triangulation: triangulates point sets
- Incremental reconstruction → 3D visualization: plots point clouds
- Command runner → COLMAP runner: runs COLMAP
- COLMAP runner → COLMAP engine: extracts, matches, maps
- COLMAP runner → 3D visualization: plots reconstructed points
- 3D visualization → Reconstruction outputs: saves animations
- COLMAP runner → Reconstruction outputs: writes model
