# ethanhe42/3d-reconstruction architecture

> Architecture diagram of the GitHub repository ethanhe42/3d-reconstruction, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ethanhe42/3d-reconstruction
- Repository: https://github.com/ethanhe42/3d-reconstruction

## Overview

This MATLAB application reconstructs a 3D point cloud from two views. Users can run the bundled datasets through main.m or provide a pair of images and camera intrinsics to SfM2.m. The documented workflow covers feature detection and matching, robust fundamental-matrix estimation, camera-pose recovery, dense matching, triangulation, and PLY output, with optional model display. The README documents these stages but no source excerpts were available, so edges are based on its workflow description rather than verified call sites.

Main entry points: [`SfM2.m`](https://github.com/ethanhe42/3d-reconstruction/blob/master/SfM2.m) (Two-view reconstruction), [`main.m`](https://github.com/ethanhe42/3d-reconstruction/blob/master/main.m) (Dataset runner), [`imgs`](https://github.com/ethanhe42/3d-reconstruction/tree/master/imgs) (Camera intrinsics), [`result`](https://github.com/ethanhe42/3d-reconstruction/tree/master/result) (PLY point clouds)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry points"]
  node_dataset_runner["Dataset runner<br/>[main.m]"]
  node_reconstruct["Two-view reconstruction<br/>[SfM2.m]"]
end

subgraph group_geometry["Image geometry"]
  node_feature_detection["Feature detection<br/>[getSIFTFeatures.m]"]
  node_feature_matching["Feature matching"]
  node_fundamental_estimation["Robust F estimation<br/>[MSAC.m]"]
  node_eight_point["Eight-point estimation<br/>[eightPoint.m]"]
  node_pose_recovery["Pose recovery<br/>[motionFromF.m]"]
end

subgraph group_reconstruction["3D reconstruction"]
  node_dense_matching["Dense matching<br/>[getMatches.m]"]
  node_triangulation["Triangulation<br/>[mytriangualation.m]"]
  node_model_display["Model display<br/>[SfM2.m]"]
end

subgraph group_artifacts["Inputs and outputs"]
  node_camera_intrinsics["Camera intrinsics"]
  node_point_clouds["PLY point clouds"]
end

node_user(("User"))

node_user -->|"runs datasets"| node_dataset_runner
node_user -->|"provides image pair"| node_reconstruct
node_user -->|"provides calibration"| node_camera_intrinsics
node_reconstruct -->|"loads intrinsics"| node_camera_intrinsics
node_reconstruct -->|"detects features"| node_feature_detection
node_reconstruct -->|"matches features"| node_feature_matching
node_reconstruct -->|"estimates F"| node_fundamental_estimation
node_reconstruct -.->|"estimates F"| node_eight_point
node_reconstruct -->|"recovers pose"| node_pose_recovery
node_reconstruct -->|"matches densely"| node_dense_matching
node_reconstruct -->|"triangulates points"| node_triangulation
node_reconstruct -->|"saves PLY"| node_point_clouds
node_reconstruct -->|"optionally displays"| node_model_display
node_dataset_runner -->|"produces clouds"| node_point_clouds

click node_dataset_runner "https://github.com/ethanhe42/3d-reconstruction/blob/master/main.m"
click node_reconstruct "https://github.com/ethanhe42/3d-reconstruction/blob/master/SfM2.m"
click node_camera_intrinsics "https://github.com/ethanhe42/3d-reconstruction/tree/master/imgs"
click node_feature_detection "https://github.com/ethanhe42/3d-reconstruction/blob/master/getSIFTFeatures.m"
click node_feature_matching "https://github.com/ethanhe42/3d-reconstruction/blob/master/matchFeaturePoints.m"
click node_fundamental_estimation "https://github.com/ethanhe42/3d-reconstruction/blob/master/MSAC.m"
click node_eight_point "https://github.com/ethanhe42/3d-reconstruction/blob/master/eightPoint.m"
click node_pose_recovery "https://github.com/ethanhe42/3d-reconstruction/blob/master/motionFromF.m"
click node_dense_matching "https://github.com/ethanhe42/3d-reconstruction/blob/master/getMatches.m"
click node_triangulation "https://github.com/ethanhe42/3d-reconstruction/blob/master/mytriangualation.m"
click node_point_clouds "https://github.com/ethanhe42/3d-reconstruction/tree/master/result"
click node_model_display "https://github.com/ethanhe42/3d-reconstruction/blob/master/SfM2.m"

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_dataset_runner,node_reconstruct,node_user toneBlue
class node_feature_detection,node_feature_matching,node_fundamental_estimation,node_eight_point,node_pose_recovery toneAmber
class node_dense_matching,node_triangulation,node_model_display toneMint
class node_camera_intrinsics,node_point_clouds toneRose
```

## Components

### Entry points

- [Dataset runner](https://github.com/ethanhe42/3d-reconstruction/blob/master/main.m): `main.m`
- [Two-view reconstruction](https://github.com/ethanhe42/3d-reconstruction/blob/master/SfM2.m): `SfM2.m`

### Image geometry

- [Feature detection](https://github.com/ethanhe42/3d-reconstruction/blob/master/getSIFTFeatures.m): `getSIFTFeatures.m`
- [Feature matching](https://github.com/ethanhe42/3d-reconstruction/blob/master/matchFeaturePoints.m): `matchFeaturePoints.m`
- [Robust F estimation](https://github.com/ethanhe42/3d-reconstruction/blob/master/MSAC.m): `MSAC.m`
- [Eight-point estimation](https://github.com/ethanhe42/3d-reconstruction/blob/master/eightPoint.m): `eightPoint.m`
- [Pose recovery](https://github.com/ethanhe42/3d-reconstruction/blob/master/motionFromF.m): `motionFromF.m`

### 3D reconstruction

- [Dense matching](https://github.com/ethanhe42/3d-reconstruction/blob/master/getMatches.m): `getMatches.m`
- [Triangulation](https://github.com/ethanhe42/3d-reconstruction/blob/master/mytriangualation.m): `mytriangualation.m`
- [Model display](https://github.com/ethanhe42/3d-reconstruction/blob/master/SfM2.m): `SfM2.m`

### Inputs and outputs

- [Camera intrinsics](https://github.com/ethanhe42/3d-reconstruction/tree/master/imgs): `imgs`
- [PLY point clouds](https://github.com/ethanhe42/3d-reconstruction/tree/master/result): `result`

### Other components

- **User**

## Connections

- User → Dataset runner: runs datasets (evidence: `README.md`)
- User → Two-view reconstruction: provides image pair (evidence: `README.md`)
- User → Camera intrinsics: provides calibration (evidence: `README.md`)
- Two-view reconstruction → Camera intrinsics: loads intrinsics (evidence: `README.md`)
- Two-view reconstruction → Feature detection: detects features (evidence: `README.md`)
- Two-view reconstruction → Feature matching: matches features (evidence: `README.md`)
- Two-view reconstruction → Robust F estimation: estimates F (evidence: `README.md`)
- Two-view reconstruction → Eight-point estimation: estimates F
- Two-view reconstruction → Pose recovery: recovers pose (evidence: `README.md`)
- Two-view reconstruction → Dense matching: matches densely (evidence: `README.md`)
- Two-view reconstruction → Triangulation: triangulates points (evidence: `README.md`)
- Two-view reconstruction → PLY point clouds: saves PLY (evidence: `README.md`)
- Two-view reconstruction → Model display: optionally displays (evidence: `README.md`)
- Dataset runner → PLY point clouds: produces clouds (evidence: `README.md`)
