> 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.

# Adding Video Capture in ROS

> **Warning**
>
> **The ZED ROS Wrapper packages are no longer maintained** because ROS 1 reached [end-of-life (EOL) on 2025-05-31](https://www.ros.org/blog/noetic-eol/) with the final Noetic release.
>
> We recommend upgrading to [ROS 2](/docs/integrations/ros-2) to take advantage of the latest ZED SDK features for robotics applications.

## Video with RViz

In this tutorial, you will learn in detail how to configure your own RViz session to see only the video data that you require.

To visualize the video stream published by the ZED node, you can use two different plugins:

* `Camera`: Displays an image from a camera, with the visualized world rendered behind it
* `Image`: Displays an image from a topic of type `sensor_msgs/Image`

### Camera

The `Camera` plugin allows you to visualize an image from a topic of type `sensor_msgs/Image`. It acts as if the source of the image is placed on its virtual frame and renders all virtual objects in front of it.

![RViz](/_fern-img/0a39b52d1ee073d5457687a6ca687e772c36e228d43ef92c1e00d7a8a204be34.webp)

Key parameters:

* `Image topic`: Selects the image topic to visualize from the list of available images in the combo box
* `Transport hint`: Selects the type of compression from the list. Using a compressed image allows reducing the required bandwidth if the image is transmitted to another machine over the ROS network
* `Queue size`: The size of the message queue. Use a lower value to reduce latency
* `Unreliable`: Enables using the UDP network protocol instead of the default TCP protocol in order to reduce latency

By expanding `Visibility`, you can select/deselect what will be visible in the `camera view`. Only active plugins can be selected.

### Image

The `Image` plugin allows you to visualize an image from a topic of type `sensor_msgs/Image`.

![RViz](/_fern-img/feb53c2f616fae6587194b0c80b80df29e4c7aee4bc2e89e8a88e131daaaf1ac.webp)

Key parameters:

* `Image topic`: Selects the image topic to visualize from the list of available images in the combo box
* `Transport hint`: Selects the type of compression from the list. Using a compressed image allows reducing the required bandwidth if the image is transmitted to another machine over the ROS network
* `Queue size`: The size of the message queue. Use a lower value to reduce latency
* `Unreliable`: Enables using the UDP network protocol instead of the default TCP protocol in order to reduce latency

## Video subscribing in C++

In this tutorial, you will learn how to write a simple C++ node that subscribes to messages of type
`sensor_msgs/Image`. This lets you retrieve the Left and Right rectified images published by the ZED node.

### Introduction

Use this command to connect the ZED camera to the ROS network:

* **ZED:**

```bash
roslaunch zed_wrapper zed.launch
```

* **ZED Mini:**

```bash
roslaunch zed_wrapper zedm.launch
```

* **ZED 2:**

```bash
roslaunch zed_wrapper zed2.launch
```

* **ZED 2i:**

```bash
roslaunch zed_wrapper zed2i.launch
```

* **ZED X:**

```bash
roslaunch zed_wrapper zedx.launch
```

* **ZED X Mini:**

```bash
roslaunch zed_wrapper zedxm.launch
```

The ZED node will start to publish image data in the network only if there is another node that subscribes to the corresponding topic.

> **Note**
>
> The code below subscribes to topics in the `/zed/zed_node` namespace used by `zed.launch`. With the other launch files, the namespace is named after the camera model (for example `/zed2i/zed_node`): change the topic names in the code or remap them when running the node.

### Running the tutorial

If you properly followed the [ROS Installation Guide](/docs/integrations/ros/#installation), the executable of this tutorial has been compiled and you can run the subscriber node using this command:

```bash
rosrun zed_video_sub_tutorial zed_video_sub
```

If the ZED node is running and a camera is connected or you have loaded an SVO file, you will receive
the following stream of messages confirming that you have correctly subscribed to the ZED image topics:

```bash
[ INFO] [1536328544.086771765]: Left Rectified image received from ZED - Size: 1280x720
[ INFO] [1536328544.089849129]: Right Rectified image received from ZED - Size: 1280x720
[ INFO] [1536328544.097859387]: Left Rectified image received from ZED - Size: 1280x720
[ INFO] [1536328544.100533804]: Right Rectified image received from ZED - Size: 1280x720
[ INFO] [1536328544.129701672]: Left Rectified image received from ZED - Size: 1280x720
[ INFO] [1536328544.131353933]: Right Rectified image received from ZED - Size: 1280x720

[...]
```

### The code

The source code of the subscriber node `zed_video_sub_tutorial.cpp`:

```C
#include <ros/ros.h>
#include <sensor_msgs/Image.h>

/**
 * Subscriber callbacks. The argument of the callback is a constant pointer to the received message
 */

void imageRightRectifiedCallback(const sensor_msgs::Image::ConstPtr& msg) {
    ROS_INFO("Right Rectified image received from ZED - Size: %dx%d",
             msg->width, msg->height);
}

void imageLeftRectifiedCallback(const sensor_msgs::Image::ConstPtr& msg) {
    ROS_INFO("Left Rectified image received from ZED - Size: %dx%d",
             msg->width, msg->height);
}

/**
 * Node main function
 */
int main(int argc, char** argv) {

    // Node initialization
    ros::init(argc, argv, "zed_video_subscriber");
    ros::NodeHandle n;

    // Subscribers
    ros::Subscriber subRightRectified = n.subscribe("/zed/zed_node/right/image_rect_color", 10,
                                                    imageRightRectifiedCallback);
    ros::Subscriber subLeftRectified  = n.subscribe("/zed/zed_node/left/image_rect_color", 10,
                                                    imageLeftRectifiedCallback);

    // Node execution
    ros::spin();

    return 0;
}

```

### The code explained

The following is a brief explanation of the source code above:

```C
void imageRightRectifiedCallback(const sensor_msgs::Image::ConstPtr& msg) {
    ROS_INFO("Right Rectified image received from ZED - Size: %dx%d", msg->width, msg->height);
}

void imageLeftRectifiedCallback(const sensor_msgs::Image::ConstPtr& msg) {
    ROS_INFO("Left Rectified image received from ZED - Size: %dx%d", msg->width, msg->height);
}
```

These callbacks are executed when the subscriber node receives a message of type `sensor_msgs/Image` that matches the subscribed topic.
The parameter of the callback is a `boost::shared_ptr` to the received message. This means you don't have to worry
about memory management.
The callback code is very simple and demonstrates how to access the fields in a message;
in this case, the `height` and `width` of the image.

The `main` function is very standard and is explained in detail in the ["Talker/Listener" ROS tutorial](http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber%28c%2B%2B%29).

The most important lesson of the above code is how the subscribers are defined:

```C
    // Subscribers
    ros::Subscriber subRightRectified = n.subscribe("/zed/zed_node/right/image_rect_color", 10, imageRightRectifiedCallback);
    ros::Subscriber subLeftRectified  = n.subscribe("/zed/zed_node/left/image_rect_color", 10, imageLeftRectifiedCallback);
```

A `ros::Subscriber` is a ROS object that listens on the network and waits for its own topic message to be available.
When a message is received, it executes the callback assigned to it.

We declared two subscribers: one for the left rectified image and one for the right rectified image.

* The subscriber to the `/zed/zed_node/right/image_rect_color` topic calls the `imageRightRectifiedCallback` function when it receives a message of type
  `sensor_msgs/Image` that matches that topic
* The subscriber to the `/zed/zed_node/left/image_rect_color` topic calls the `imageLeftRectifiedCallback` function when it receives a message of type
  `sensor_msgs/Image` that matches that topic

### Conclusion

The full source code of this tutorial is available on GitHub in the [zed\_video\_sub\_tutorial](https://github.com/stereolabs/zed-ros-examples/tree/master/tutorials/zed_video_sub_tutorial) sub-package.
Along with the node source code are the `package.xml` and `CMakeLists.txt` files that complete the tutorial package.