The image transport package sounds like what you need! Image transport package allows user to define their own transport methods. Here is some common transport methods provided by image transport. The transport methods are transparent to the user. i.e. it will be discovered during runtime. A typical implementation of image transport will look like this.
image_transport::ImageTransport it_(node);
image_transport::Publisher image_pub_;
image_pub_ = it_.advertise("rgb", 10);
auto image = sensor_msgs::msg::Image::SharedPtr(new sensor_msgs::msg::Image);
image_pub_.publish(image);
By doing this, you will see some additional topics for different transport method, such as compressed
, if you have install the plugins correctly. I have implemented my own type of image transport plugin that uses nvenc to encode video stream to h.264 encoding.
However, the downside of using image transport is that it will produce a lot of unused topics (an extra topic per image plugin.). There seems to be a way to disable unused topic, but it is always possible to just use sensor_msgs::msg::image
to transport compressed data. Just need to make sure the encoding
field in the sensor_msgs::msg::image
is filled up with the correct encoding format, such as h.264.