ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

ROS msg including image and related variables related to that image

asked 2018-04-09 06:55:57 -0500

xaggi gravatar image

I need to create a publisher which can publish an image along with a few strings, integers and arrays containing different information about the image (like number of objects, bounding boxes, name of the objects inside image etc).

Up until now, I am successful to publish image using the following command:

  pub_msg = bridge.cv2_to_imgmsg(img, "bgr8")

But I dont understand how to incorporate rest of the data with this image. If I create custom ROS msg, how to add all these information variables along with and image data. Please guide me or suggest me some tutorial where I can get some related help.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-04-09 10:02:42 -0500

mgruhler gravatar image

You have to create a custom message which includes the sensor_msgs/Image as well as the additional data that you want. Those could be primitives (e.g. int8) or other compound messages (e.g. geometry_msgs/Polygon, not quite sure if this specific one helps, though).

There is a tutorial about how to create custom m essages. Then you need to fill the respective fields and adapt your publisher accordingly.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2018-04-09 06:55:57 -0500

Seen: 394 times

Last updated: Apr 09 '18