# Estimate image depth values with `sample_depth_estimation`
This sample application allows you to input an RGB image named `input_image.jpg` or subscribe to the ROS topic `/cam0_stream1` from `qrb_ro_camera`. It then uses QNN to perform model inference and publishes the result as the `/depth_map` ROS topic containing per-pixel depth values.
The model has its source from [Depth Anything V2](https://aihub.qualcomm.com/iot/models/depth_anything_v2?searchTerm=depth&domain=Computer+Vision), a deep convolutional neural network model for depth estimation.

## `sample_depth_estimation` pipeline flow
The figure shows the pipeline flow for `sample_depth_estimation`.
**`sample_depth_estimation` pipeline**
## ROS nodes used in `sample_depth_estimation`
| Node name | Description |
| --- | --- |
| [qrb ros camera](https://github.com/qualcomm-qrb-ros/qrb_ros_camera) | Qualcomm ROS 2 package that captures images with parameters and publishes them to ROS topics. |
| Image publisher | Publishes image data to a ROS topic—can be camera frames, local files, or processed outputs. |
| Sample depth estimation | Subscribes to input images for preprocessing, then performs postprocessing on the output tensor published by the qrb ros nn interface node. |
| [qrb ros nn interface](https://github.com/qualcomm-qrb-ros/qrb_ros_nn_inference) | Loads a trained AI model, receives preprocessed images, performs inference, and publishes results. |
## ROS topics used in `sample_depth_estimation`
| ROS topic | Type | Description |
| --- | --- | --- |
| `/image_raw` | `` | Published image information. |
| `/qrb_inference_input_tensor` | `` | Preprocessed message. |
| `/qrb_inference_output_tensor` | `` | Neural network interface result with model. |
| `/depth_map` | `` | Depth map result. |
## Prerequisites
You have set up the device, installed ROS2 Jazzy and QIR SDK on the device according to [Install the QIR SDK](https://docs.qualcomm.com/doc/80-90441-2/topic/2-install-the-qir-sdk.html#install-qir-sdk).
## Build from the source of `sample_depth_estimation`
**Device steps**
1. Download the Depth-Anything-V2 model.
sudo mkdir -p /opt/model && cd /opt/model
sudo wget https://huggingface.co/qualcomm/Depth-Anything-V2/resolve/19ce3645e11de17eed7e869eebcc07dd352834f3/Depth-Anything-V2.bin?download=true -O Depth-Anything-V2.bin
Copy to clipboard
2. Install dependencies.
sudo apt install -y ros-dev-tools
sudo apt install -y ros-jazzy-qrb-ros-camera
Copy to clipboard
3. Download the source code from the qrb\_ros\_samples repository.
mkdir -p ~/qrb_ros_ws/src && cd ~/qrb_ros_ws/src
git clone -b jazzy-rel https://github.com/qualcomm-qrb-ros/qrb_ros_samples.git
Copy to clipboard
4. Build the sample application from source code.
cd ~/qrb_ros_ws/src/qrb_ros_samples/ai_vision/sample_depth_estimation
rosdep install -i --from-path ./ --rosdistro jazzy -y
colcon build
Copy to clipboard
5. Set up the environment with the source command and launch the sample application.
source install/setup.bash
ros2 launch sample_depth_estimation launch_with_image_publisher.py
Copy to clipboard
6. You can replace this with a custom image file or model path.
source install/setup.bash
ros2 launch sample_depth_estimation launch_with_image_publisher.py image_path:= model_path:=
Copy to clipboard
7. You can also launch with `qrb_ros_camera` if you connect to the GMSL camera.
source install/setup.bash
ros2 launch sample_depth_estimation launch_with_qrb_ros_camera.py
Copy to clipboard
8. When using this launch script, it uses the default parameters, which send the `local input_image.jpg` file with a publishing rate of 10 Hz.
image_path_arg = DeclareLaunchArgument(
'image_path',
default_value=os.path.join(package_path, "resource", "input_image.jpg"),
description='Path to the input image file'
)
# Node for image_publisher
image_publisher_node = Node(
package='image_publisher',
executable='image_publisher_node',
namespace=namespace,
name='image_publisher_node',
output='screen',
parameters=[
{'filename': image_path},
{'rate': 10.0}, # Set the publishing rate to 10 Hz
]
)
Copy to clipboard
9. You can then check ROS topics with the topic name `/depth_map` in `rqt`. To install `rqt`, see the [ROS 2 Jazzy documentation](https://docs.ros.org/en/jazzy/Tutorials/Beginner-CLI-Tools/Introducing-Turtlesim/Introducing-Turtlesim.html).
1. Run `rqt` and select the following buttons in sequence: Plugins-->Visualization-->ImageView.
2. Select `/sample_container/depth_map` to see the results.
Last Published: Sep 07, 2026
[Previous Topic
Detect hands with sample\_hand\_detection](https://docs.qualcomm.com/bundle/publicresource/80-90441-2/topics/detect-hands-with-sample_hand_detection.md) [Next Topic
Detect faces with sample\_face\_detection](https://docs.qualcomm.com/bundle/publicresource/80-90441-2/topics/detect-faces-with-sample_face_detection.md)