https://github.com/semanurbilada/realtime-depth-camera
AI Lecture Term Project | Real-time Depth Estimation with OpenCV & Neural Networks in C++
https://github.com/semanurbilada/realtime-depth-camera
depth-camera depth-estimation monocular-camera monocular-depth-estimation neural-networks opencv-cpp opencv-cuda
Last synced: 20 days ago
JSON representation
AI Lecture Term Project | Real-time Depth Estimation with OpenCV & Neural Networks in C++
- Host: GitHub
- URL: https://github.com/semanurbilada/realtime-depth-camera
- Owner: semanurbilada
- Created: 2025-03-20T09:31:29.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2025-05-05T20:43:08.000Z (28 days ago)
- Last Synced: 2025-05-05T21:42:24.666Z (28 days ago)
- Topics: depth-camera, depth-estimation, monocular-camera, monocular-depth-estimation, neural-networks, opencv-cpp, opencv-cuda
- Language: C++
- Homepage:
- Size: 35.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Real-Time Depth Estimation with OpenCV & Neural Networks in C++
> **AI Lecture Term Project β 4th Grade, 2nd Term**
This project demonstrates real-time monocular depth estimation using a pre-trained MiDaS (v2.1 Large) model in ONNX format. Built with C++ and OpenCVβs DNN module, it captures live webcam feed and visualizes depth maps in real time.
---
## π Project Structure
The project follows this directory structure:
```
RealTime-Depth-Camera/
βββ .vscode/ # Editor configs for VSCode (optional)
βββ build/ # Compiled output binary (auto-generated)
β βββ depth_estimate # Executable built from depth_estimate.cpp
βββ docs/ # For storing additional docs or reports (optional)
βββ src/ # Source code and model files
β βββ depth_estimate.cpp # Main source file for real-time depth estimation
β βββ models/ # Contains pre-trained ONNX models for depth estimation
β βββ midas_v21_384.onnx # MiDaS v2.1 large model (384x384 resolution)
β βββ midas_v21_small_256.onnx # MiDaS v2.1 small model (256x256 resolution)
β
βββ .gitignore # Git ignore rules
βββ CMakeFileList.txt # CMake-related configuration (if used)
βββ launch.sh # Build and run script for compiling and executing the project
βββ README.md # Project documentation (this file)
```---
## βοΈ Requirements
- C++11 or later
- OpenCV 4.x (built with DNN module)
- Webcam (for live video input)
- MiDaS ONNX model (included in `src/models`)---
## π Build and Run
You can build and run the project using the provided shell script:
```bash
chmod +x launch.sh
./launch.sh
```This script will:
- Create the build/ directory if it doesn't exist
- Compile depth_estimate.cpp
- Run the resulting executable
- βοΈNote: Ensure the model file midas_v21_384.onnx is located at src/models/.---
## π§ About MiDaS
MiDaS (Monocular Depth Estimation) is a deep learning model developed by Intel Labs that estimates depth from a single RGB image. This project uses the v2.1 Large model in ONNX format.
---
## π· Output
- Displays the original webcam frame
- Displays the corresponding real-time depth map
- Shows the current FPS in the depth window
- Press q to exit the application.---
## π Notes
- For macOS or systems without GPU support, the model runs on CPU by default.
- You can modify the backend to use CUDA if supported:
```
net.setPreferableBackend(DNN_BACKEND_CUDA);
net.setPreferableTarget(DNN_TARGET_CUDA);
```---
## π License
This project is for academic use only. Model usage is subject to its original [MiDaS license.](https://github.com/isl-org/MiDaS)
---
## βοΈ Resources
- [Original Document | MiDaS - Getting Started - Models](https://docs.doji-tech.com/com.doji.midas/manual/models.html)
- [YouTube | How to Estimate Depth with a Monocular Camera using OpenCV C++ and Neural Networks](https://www.youtube.com/watch?v=7fCheEYUpgU&t=409s)