> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.stereolabs.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.stereolabs.com/_mcp/server.

# Using Object Detection and Tracking with ROS 2

The Object Detection module can be [configured](/docs/integrations/ros-2/zed-stereo-node/#configuration-parameters) to use one of the available detection models:

| MODEL                           | Description                                                                                                                                                                                  |
| ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `MULTI_CLASS_BOX_FAST`          | Any objects, bounding box based                                                                                                                                                              |
| `MULTI_CLASS_BOX_MEDIUM`        | Any objects, bounding box based, compromise between accuracy and speed                                                                                                                       |
| `MULTI_CLASS_BOX_ACCURATE`      | Any objects, bounding box based, more accurate but slower than the base model                                                                                                                |
| `PERSON_HEAD_BOX_FAST`          | Bounding Box detector specialized in person heads, particularly well suited for crowded environments, the person localization is also improved                                               |
| `PERSON_HEAD_BOX_ACCURATE`      | Bounding Box detector specialized in person heads, particularly well suited for crowded environments, the person localization is also improved, more accurate but slower than the base model |
| `CUSTOM_YOLOLIKE_BOX_OBJECTS`   | For internal inference using your own custom YOLO-like model. This mode requires an ONNX file to be passed in the ObjectDetectionParameters. This model will be used for inference.          |
| `CUSTOM_RFDETRLIKE_BOX_OBJECTS` | Same as above, for an RF-DETR-like model. Requires ZED SDK >= 5.5                                                                                                                            |
| `CUSTOM_BOX_OBJECTS_AUTODETECT` | Same as above, with the ZED SDK picking between YOLO-like and RF-DETR-like from the model outputs. Requires ZED SDK >= 5.5                                                                   |

The `MULTI_CLASS_BOX` and `PERSON_HEAD_BOX` modes use internal models that are provided and downloaded automatically by the SDK.

The three `CUSTOM_*` modes allow you to load your own ONNX model. The [Custom Object Detection and Tracking with ROS 2](/docs/integrations/ros-2/custom-object-detection-and-tracking) guide shows an example of how to export this model from a trained PyTorch model. This process must be done only once.

The result of the detection is published using a custom message of type [zed\_msgs/ObjectsStamped](/docs/integrations/ros-2/custom-msgs/#object-detection-and-body-tracking-results) defined in the package [zed\_msgs](https://github.com/stereolabs/zed-ros2-interfaces).

## Enable Object Detection

Object detection can be started automatically when the ZED Wrapper node starts by setting the parameter `object_detection.od_enabled` to `true` in the file `common_stereo.yaml`.

It is also possible to start the Object Detection processing manually by calling the service `~/enable_obj_det` with the parameter `True`.

In both cases, the Object Detection processing can be stopped by calling the service `~/enable_obj_det` with the parameter `False`.

See the [services](/docs/integrations/ros-2/zed-stereo-node/#services) documentation for more info.

> **Note**
>
> The first time you run the ZED node with the object detection configuration, the SDK will optimize the model for the GPU used on the host device.
>
> This process may take a long time, depending on the model size and the power of the GPU used. The optimized model will be saved in the `/usr/local/zed/resources` folder and reused in subsequent runs, which will no longer require the optimization process.
>
> ```bash
> [ZED][INFO] Please wait while the AI model is being optimized for your graphics card
> This operation will be run only once and may take a few minutes
> ```

## Object Detection results in RViz 2

To visualize the results of the Object Detection processing in RViz 2, the `ZedOdDisplay` plugin is required. The plugin is available in the [zed-ros2-examples](https://github.com/stereolabs/zed-ros2-examples) GitHub repository and can be installed following the [online instructions](https://github.com/stereolabs/zed-ros2-examples#build-the-package).

> **Note**
>
> [The source code of the plugin](https://github.com/stereolabs/zed-ros2-examples/tree/master/rviz-plugin-zed-od) is a valid example of how to process the data of the topics of type [zed\_msgs/ObjectsStamped](/docs/integrations/ros-2/custom-msgs/#object-detection-and-body-tracking-results).

![image](/_fern-img/098402572e865ae1d090e06d4877c53fdcb7e8dc4a8de4018b4cd04db2dad80a.webp)

Parameters:

* `Topic`: Selects the object detection topic to visualize from the list of available topics in the combo box.
* `Depth`: The depth of the incoming message queue.
* `History policy`: Set the QoS history policy. `Keep Last` is suggested for performance and compatibility.
* `Reliability Policy`: Set the QoS reliability policy. `Best Effort` is suggested for performance and compatibility.
* `Durability Policy`: Set the QoS durability policy. `Volatile` is suggested for compatibility.
* `Transparency`: the transparency level of the structures composing the detected objects.
* `Show skeleton`: Not used.
* `Show Labels`: enable/disable the visualization of the object label.
* `Show Bounding Boxes`: enable/disable the visualization of the bounding boxes of the detected objects.
* `Link Size`: the size of the bounding boxes' corner lines.
* `Joint Radius`: the radius of the spheres placed on the corners of the bounding boxes.
* `Label Scale`: the scale of the label of the object.

![image](/_fern-img/0f99febb7edd52e892e5f03b109f0eceaff4354a22638809cb514cb6bc70dfde.webp)