# ches00/360-sl-metasurface architecture

> Architecture diagram of the GitHub repository ches00/360-sl-metasurface, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ches00/360-sl-metasurface
- Repository: https://github.com/ches00/360-sl-metasurface

## Overview

This repository implements a learned 360° structured-light system: synthetic scene data and camera calibration feed an end-to-end model that simulates metasurface illumination, renders fisheye images, and estimates depth. The README also describes synthetic and real-capture inference. The graph emphasizes these product stages and the camera, data, and neural-network layers supporting them. Training links are supported by the shown training excerpt; inference and some subsystem connections are documented at a high level, so unverified links are dashed.

Main entry points: [`train.py`](https://github.com/ches00/360-sl-metasurface/blob/main/train.py) (Training), [`Image_formation/renderer.py`](https://github.com/ches00/360-sl-metasurface/blob/main/Image_formation/renderer.py) (Active Stereo Renderer), [`model/StereoMatching.py`](https://github.com/ches00/360-sl-metasurface/blob/main/model/StereoMatching.py) (Stereo Depth Estimator), [`test.py`](https://github.com/ches00/360-sl-metasurface/blob/main/test.py) (Inference)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Scene Data"]
  node_generator["Scene Generator<br/>[Generator.py]"]
  node_dataset_entry["Dataset Launcher"]
  node_synthetic_data["Synthetic Dataset<br/>[dataset.py]"]
  node_exr["EXR Reader<br/>[openExr.py]"]
  node_real_data["Real Capture Dataset<br/>[dataset.py]"]
end

subgraph group_optics["Optical Simulation"]
  node_camera["Camera Geometry<br/>[Camera.py]"]
  node_metasurface["Metasurface Propagation<br/>[Metasurface.py]"]
  node_renderer["Active Stereo Renderer<br/>[renderer.py]"]
  node_noise["Image Noise<br/>[noise.py]"]
end

subgraph group_reconstruction["Depth Reconstruction"]
  node_estimator["Stereo Depth Estimator<br/>[StereoMatching.py]"]
  node_layers["Neural Layers<br/>[basic_layer.py]"]
end

subgraph group_workflow["Model Workflow"]
  node_train["Training<br/>[train.py]"]
  node_test["Inference<br/>[test.py]"]
  node_arguments["Run Configuration<br/>[ArgParser.py]"]
  node_e2e["End-to-End Model<br/>[e2e.py]"]
end

node_user(("Researcher"))

node_user -->|"starts training"| node_train
node_user -->|"starts inference"| node_test
node_train -->|"parses options"| node_arguments
node_train -->|"loads batches"| node_synthetic_data
node_train -->|"trains model"| node_e2e
node_train -->|"initializes phase"| node_metasurface
node_train -->|"sets up rendering"| node_renderer
node_train -->|"sets up estimator"| node_estimator
node_dataset_entry -->|"launches generation"| node_generator
node_generator -->|"uses camera"| node_camera
node_synthetic_data -->|"reads depth maps"| node_exr
node_renderer -->|"propagates pattern"| node_metasurface
node_renderer -->|"projects scene points"| node_camera
node_renderer -->|"samples noise"| node_noise
node_estimator -->|"projects views"| node_camera
node_estimator -->|"builds features"| node_layers
node_e2e -->|"renders images"| node_renderer
node_e2e -->|"estimates depth"| node_estimator
node_test -.->|"supports synthetic input"| node_synthetic_data
node_test -.->|"supports real captures"| node_real_data

click node_train "https://github.com/ches00/360-sl-metasurface/blob/main/train.py"
click node_test "https://github.com/ches00/360-sl-metasurface/blob/main/test.py"
click node_arguments "https://github.com/ches00/360-sl-metasurface/blob/main/utils/ArgParser.py"
click node_generator "https://github.com/ches00/360-sl-metasurface/blob/main/dataset/Generator.py"
click node_dataset_entry "https://github.com/ches00/360-sl-metasurface/blob/main/dataset/dataset_generator.py"
click node_synthetic_data "https://github.com/ches00/360-sl-metasurface/blob/main/dataset/dataset.py"
click node_camera "https://github.com/ches00/360-sl-metasurface/blob/main/utils/Camera.py"
click node_metasurface "https://github.com/ches00/360-sl-metasurface/blob/main/model/Metasurface.py"
click node_renderer "https://github.com/ches00/360-sl-metasurface/blob/main/Image_formation/renderer.py"
click node_noise "https://github.com/ches00/360-sl-metasurface/blob/main/utils/render/noise.py"
click node_exr "https://github.com/ches00/360-sl-metasurface/blob/main/utils/render/openExr.py"
click node_real_data "https://github.com/ches00/360-sl-metasurface/blob/main/dataset/dataset.py"
click node_estimator "https://github.com/ches00/360-sl-metasurface/blob/main/model/StereoMatching.py"
click node_layers "https://github.com/ches00/360-sl-metasurface/blob/main/utils/net/basic_layer.py"
click node_e2e "https://github.com/ches00/360-sl-metasurface/blob/main/model/e2e.py"

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_generator,node_dataset_entry,node_synthetic_data,node_exr,node_real_data toneBlue
class node_camera,node_metasurface,node_renderer,node_noise toneAmber
class node_estimator,node_layers toneMint
class node_train,node_test,node_arguments,node_e2e toneRose
class node_user toneIndigo
```

## Components

### Scene Data

- [Scene Generator](https://github.com/ches00/360-sl-metasurface/blob/main/dataset/Generator.py): `dataset/Generator.py`
- [Dataset Launcher](https://github.com/ches00/360-sl-metasurface/blob/main/dataset/dataset_generator.py): `dataset/dataset_generator.py`
- [Synthetic Dataset](https://github.com/ches00/360-sl-metasurface/blob/main/dataset/dataset.py): `dataset/dataset.py`
- [EXR Reader](https://github.com/ches00/360-sl-metasurface/blob/main/utils/render/openExr.py): `utils/render/openExr.py`
- [Real Capture Dataset](https://github.com/ches00/360-sl-metasurface/blob/main/dataset/dataset.py): `dataset/dataset.py`

### Optical Simulation

- [Camera Geometry](https://github.com/ches00/360-sl-metasurface/blob/main/utils/Camera.py): `utils/Camera.py`
- [Metasurface Propagation](https://github.com/ches00/360-sl-metasurface/blob/main/model/Metasurface.py): `model/Metasurface.py`
- [Active Stereo Renderer](https://github.com/ches00/360-sl-metasurface/blob/main/Image_formation/renderer.py): `Image_formation/renderer.py`
- [Image Noise](https://github.com/ches00/360-sl-metasurface/blob/main/utils/render/noise.py): `utils/render/noise.py`

### Depth Reconstruction

- [Stereo Depth Estimator](https://github.com/ches00/360-sl-metasurface/blob/main/model/StereoMatching.py): `model/StereoMatching.py`
- [Neural Layers](https://github.com/ches00/360-sl-metasurface/blob/main/utils/net/basic_layer.py): `utils/net/basic_layer.py`

### Model Workflow

- [Training](https://github.com/ches00/360-sl-metasurface/blob/main/train.py): `train.py`
- [Inference](https://github.com/ches00/360-sl-metasurface/blob/main/test.py): `test.py`
- [Run Configuration](https://github.com/ches00/360-sl-metasurface/blob/main/utils/ArgParser.py): `utils/ArgParser.py`
- [End-to-End Model](https://github.com/ches00/360-sl-metasurface/blob/main/model/e2e.py): `model/e2e.py`

### Other components

- **Researcher**

## Connections

- Researcher → Training: starts training (evidence: `README.md`)
- Researcher → Inference: starts inference (evidence: `README.md`)
- Training → Run Configuration: parses options (evidence: `train.py`)
- Training → Synthetic Dataset: loads batches (evidence: `train.py`)
- Training → End-to-End Model: trains model (evidence: `train.py`)
- Training → Metasurface Propagation: initializes phase (evidence: `train.py`)
- Training → Active Stereo Renderer: sets up rendering (evidence: `train.py`)
- Training → Stereo Depth Estimator: sets up estimator (evidence: `train.py`)
- Dataset Launcher → Scene Generator: launches generation (evidence: `dataset/dataset_generator.py`)
- Scene Generator → Camera Geometry: uses camera (evidence: `dataset/Generator.py`)
- Synthetic Dataset → EXR Reader: reads depth maps (evidence: `dataset/dataset.py`)
- Active Stereo Renderer → Metasurface Propagation: propagates pattern (evidence: `Image_formation/renderer.py`)
- Active Stereo Renderer → Camera Geometry: projects scene points (evidence: `Image_formation/renderer.py`)
- Active Stereo Renderer → Image Noise: samples noise (evidence: `Image_formation/renderer.py`)
- Stereo Depth Estimator → Camera Geometry: projects views (evidence: `model/StereoMatching.py`)
- Stereo Depth Estimator → Neural Layers: builds features (evidence: `model/StereoMatching.py`)
- End-to-End Model → Active Stereo Renderer: renders images (evidence: `model/e2e.py`)
- End-to-End Model → Stereo Depth Estimator: estimates depth (evidence: `model/e2e.py`)
- Inference → Synthetic Dataset: supports synthetic input (evidence: `README.md`)
- Inference → Real Capture Dataset: supports real captures (evidence: `README.md`)
