A standalone, modular Python system developed for Search-and-Rescue (SAR) disaster site situational awareness. It ingests single RGB aerial or ground perspective imagery and produces metric-scaled depth estimates and full-color 3D point clouds (.ply) for interactive geometric inspection.
Crucial Engineering Clarification:
This application does NOT claim that RGB imagery is converted into real hardware LiDAR data.
- Hardware LiDAR utilizes physical lasers firing pulsed beams at nanosecond intervals to calculate time-of-flight (ToF) direct range measurements.
- This System uses deep-learning Monocular Depth Estimation (MDE) via lightweight convolutional networks (
MiDaS v2.1 Small) to infer optical disparity from 2D scene geometry, lighting, and semantic perspective cues.- The estimated depth is subsequently back-projected into 3D Euclidean space
$(X, Y, Z)$ using a pinhole camera intrinsic projection model, generating a metric point cloud while preserving true RGB vertex texturing.
- CPU-First & Edge-Ready: Runs out of the box on standard x86 CPUs and edge devices such as the Raspberry Pi 4 (4 GB RAM) using ONNX Runtime without requiring dedicated GPUs.
- Modular, Decoupled Architecture:
- Depth estimation model is abstracted behind
BaseDepthModel, allowing zero-friction swapping for future models (e.g., Depth-Anything-V2, FastDepth). - 3D Point-cloud reconstruction is isolated from inference logic and handles camera intrinsics (FOV or calibration matrix).
- Visualization is separated from processing with automatic headless detection for servers and Docker environments.
- Depth estimation model is abstracted behind
- Lossless Outputs:
original.png: Reference input image.depth.png: Color-mapped false-color depth visualization (Inferno/Turbo colormap).depth_raw.png: Lossless 16-bit millimeter-scale depth map.pointcloud.ply: Dense 3D point cloud with RGB vertex colors.
- Point Cloud Post-Processing: Built-in voxel downsampling and statistical outlier removal to eliminate depth edge noise and flying pixels.
- Extensible Input: Pinhole parameters are decoupled from physical sensors, allowing direct migration to Raspberry Pi Camera Module v2/v3 or video frame streams.
sih26177/
├── app/
│ ├── depth/
│ │ ├── __init__.py
│ │ ├── model.py # BaseDepthModel, MiDaSSmallONNX, DummyDepthModel
│ │ └── inference.py # DepthEstimator pipeline & disparity-to-depth conversion
│ ├── pointcloud/
│ │ ├── __init__.py
│ │ └── reconstruction.py # CameraIntrinsics, Pinhole back-projection, PLY writer
│ ├── visualization/
│ │ ├── __init__.py
│ │ └── viewer.py # Interactive Open3D visualizer & headless handler
│ └── main.py # CLI orchestration entrypoint
├── config/
│ └── config.yaml # Camera, model, voxel, and output configuration
├── data/
│ ├── input/
│ │ └── image.jpg # Disaster/rescue scene sample image
│ └── output/
│ ├── original.png
│ ├── depth.png
│ ├── depth_raw.png
│ └── pointcloud.ply
├── models/
│ └── model-small.onnx # Auto-downloaded MiDaS v2.1 Small weights (~45 MB)
├── tests/
│ ├── test_reconstruction.py # Pinhole geometry math, depth filtering, PLY export tests
│ ├── test_depth.py # Depth model interface and metric scaling tests
│ └── test_pipeline.py # End-to-end integration test
├── Dockerfile # Containerized deployment specification
├── requirements.txt # Python dependencies
└── README.md
- Python 3.10, 3.11, 3.12, or 3.13.
- Git.
Windows (PowerShell):
python -m venv .venv .\.venv\Scripts\Activate.ps1 pip install -r requirements.txt
Linux / macOS / Raspberry Pi OS:
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt(Note: On Debian/Ubuntu/Raspberry Pi OS, ensure system OpenGL libraries are present: sudo apt-get install -y libgl1 libglib2.0-0 libgomp1)
python -m app.main --input data/input/image.jpg
- On the first run, the lightweight pretrained MiDaS v2.1 Small model (~45 MB) will automatically download into
models/model-small.onnx. - The pipeline will estimate the depth, reconstruct the 3D colored point cloud, save all artifacts to
data/output/, and open an interactive Open3D 3D viewer.
python -m app.main --input data/input/image.jpg --headless
python -m app.main --input path/to/drone_capture.jpg --output my_output_dir/ --config config/config.yaml
For a Raspberry Pi Camera Module 2 (horizontal FOV
python -m app.main --input data/input/image.jpg --fov 62.2 --voxel-size 0.03
When the Open3D viewer launches:
- Rotate: Left Click + Mouse Drag
- Pan: Right Click + Mouse Drag (or Shift + Left Click)
- Zoom: Mouse Scroll Wheel
- Exit: Press
QorESC
The output data/output/pointcloud.ply preserves RGB vertex colors and can also be opened in external 3D software:
- CloudCompare (Free, open-source 3D point cloud editor)
- MeshLab (Free, open-source 3D mesh & point processor)
- Blender (
File -> Import -> Stanford (.ply))
To build and run inside a self-contained Docker container:
# Build the Docker image docker build -t sih-3d-reconstruct . # Run container on a sample image (mounting output folder) docker run --rm -v ${PWD}/data/output:/workspace/data/output sih-3d-reconstruct
Run unit and integration tests using pytest:
pytest -v
All tests run deterministically and do not depend on active internet connectivity (using DummyDepthModel mocks for depth pipeline verification).
- Raspberry Pi Camera Stream:
- The
DepthEstimator.estimate_frame(frame)interface accepts direct numpy buffers fromcv2.VideoCapture(0)orpicamera2.
- The
- Video & Trajectory Processing:
- Downstream modules can accumulate successive point clouds into a global coordinate frame via ICP (Iterative Closest Point) registration.
- Drone & MAVLink Integration:
- Telemetry (roll, pitch, yaw, altitude) can be passed directly as extrinsic transformation matrices to orient the point cloud in real-world geospatial coordinates.