yzfzzz/depth-detect
mono / stereo depth estimation + yolo object detection with deployment on Jeston nano / TX2 / GeForce by TensorRT
depth‑detect – Bike‑mounted smart rear‑view mirror
What it is
- A C++14 framework that fuses object detection (YOLO) with monocular or stereo depth estimation (Depth‑Anything, Lite‑Mono, YOLO‑Depth) to recognise dangerous approaching objects on a bicycle.
- It runs on x86 Linux as well as Jetson embedded devices (aarch64) and can be built inside a Docker container.
Key capabilities
| Feature | Detail |
|---|---|
| Multi‑model pipeline | Detection and depth models run in parallel, with three scheduling modes: synchronous (serial), overlap (GPU streams overlap), and staggered (different frame intervals). |
| Approach detection | Flags a target as dangerous when its depth consistently decreases and its bounding‑box height grows. |
| Tracking | BYTETracker with Kalman filtering provides multi‑object IDs. |
| Alerting | Generates JSON alerts sent over TCP; can also save video/images and per‑track CSV logs. |
| Cross‑platform | Builds with CMake for x86, Jetson TX2/Nano; inference back‑ends: TensorRT (GPU), ONNX Runtime (CPU fallback). |
| Performance | On Jetson TX2, TensorRT FP16 gives ~19× speed‑up over ONNX‑CPU (100 ms vs 1910 ms per frame). Staggered scheduling reaches ~13.5 fps (≈74 ms/frame) on 640×480 video. |
| Resource‑aware | Asynchronous disk‑write buffer prevents I/O stalls; memory usage stays <4.2 GB, GPU temperature stays below 40 °C on TX2. |
Technology stack
- Language: C++14
- Build: CMake ≥3.10
- Inference: TensorRT (8.x/10.x) or ONNX Runtime 1.10
- GPU acceleration: CUDA (including custom CUDA kernels for pre/post‑processing)
- Vision: OpenCV 4.x
- Config / logging: yaml‑cpp, spdlog
- Math: Eigen3, OpenCV KalmanFilter
- Networking: nlohmann/json over TCP (via submodule
JsonSenderTest) - Benchmarking: Google Benchmark
- Tracking algorithm: BYTETracker (with LAPJV assignment)
How to get started
# Clone and enter the repo
git clone https://github.com/yzfzzz/depth-detect.git
cd depth-detect
# Quick run (uses the default config and Docker if you prefer)
./start.sh
# Build a Docker image (recommended for reproducibility)
./build.sh # creates an image with all dependencies
# Inside the container
./start.sh
The output directory (bin/out_dir/) will contain processed video or image frames, logs, and a track_log.csv with per‑track depth, box area and frame count.
Configuration
- All parameters are YAML‑driven (
config.yaml). - You can switch inference back‑end (
prefer.backend), schedule mode (prefer.overlap,prefer.stagger_infer), model paths, detection intervals, depth intervals, logging options, etc. - A helper script
scripts/config_tool.pylets you generate or refresh the config.
Benchmark & testing
- Run the provided Google‑Benchmark suite with
./bin/run_benchmark.sh. - Individual tests (
test_trt_pipeline,test_schedule_strategy, etc.) let you compare sync/overlap/stagger modes, FP16 vs FP32, and quantized INT8 (available on x86 GPUs). - A Jetson‑specific monitor script (
scripts/jetson_monitor.py) records CPU, memory, and GPU temperature during execution.
Development & contribution
- Code formatting is enforced by
format.shand CI checks. - Pull requests should pass the CI workflow which builds the Docker image, runs the container, and executes a smoke test.
License
- See the
LICENSEfile in the repository (standard open‑source license).
Generated from the repository’s README.
Related
- Project
- Project
- Project
- Project
- Project