DepthStream Accelerator: A TensorRT-optimized monocular depth estimation tool with ROS2 integration for C++. It offers high-speed, accurate depth perception, perfect for real-time applications in robotics, autonomous vehicles, and interactive 3D environments.
- NVIDIA Driver (Official Link)
- CUDA Toolkit (Official Link)
- cuDNN (Official Link)
- TensorRT (Official Link)
- OpenCV CUDA (Github Guide)
- Miniconda (Official Link)
- ROS 2 Humble (Official Link)
- ZoeDepth (Official Link)
Create the onnx file cd monocular_depth/scripts/ZoeDepth/ && python trt_convert.py
. The ONNX file gets saved in the working directory as zoe_nk.onnx
, configure the input dimensions as per your input image dimensions (h, w).
You can download a prebuilt .onnx
file from LINK.
Once you have the .onnx
file created go into the tensorRT trtexec directory. Mostly this is cd /usr/src/tensorrt/bin/
. Now it is time to create the engine file, this could take a few minutes to create. Run the command below,
./trtexec --onnx=zoe_nk.onnx --builderOptimizationLevel=3 --useSpinWait --useRuntime=full --useCudaGraph --precisionConstraints=obey --allowGPUFallback --tacticSources=+CUBLAS,+CUDNN,+JIT_CONVOLUTIONS,+CUBLAS_LT --inputIOFormats=fp32:chw --outputIOFormats=fp32:chw --sparsity=enable --layerOutputTypes=fp32 --layerPrecisions=fp32 --saveEngine=zoe_nk.trt
colcon build --symlink-install --cmake-args=-DCMAKE_BUILD_TYPE=Release --parallel-workers $(nproc)
ros2 launch monocular_depth mono_depth.launch.py trt_path:=zoe_nk.trt image_topic:=/rgb/image_rect_color gui:=true
With GUI.
ros2 launch monocular_depth mono_depth.launch.py trt_path:=zoe_nk.trt image_topic:=/rgb/image_rect_color gui:=false
Without GUI.
The depth map gets published as sensor_msg/Image
in the /mono_depth/depthMap
topic
- There is a know problem with MiDAS which doesnt allow tracing the network.
- If the input image dimensions are changed, change the source code to match your image dimension inputs.