Ask Your Question
0

ROS msg including image and related variables related to that image

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

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")
  pub.publish(pub_msg)

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
0

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

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

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

Seen: 64 times

Last updated: Apr 09 '18