0
$\begingroup$

Rosanswers logo

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.


Originally posted by xaggi on ROS Answers with karma: 1 on 2018-04-09

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by mgruhler with karma: 12390 on 2018-04-09

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.