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

How can I publish many ROIs in a detection node?

asked 2017-09-11 02:50:43 -0500

danaitri gravatar image

Hello I have simple object detection node that reads frames from the usb camera and performs face detection. I would like to publish all the detected bounding boxes. How can I publish many bounding boxes? The number of detections is not static, as I have no priori knowledge of how many detections the detector will produce. I have a tracker node which will then subscribe to the detector topic and perform tracking.

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2017-09-11 03:13:32 -0500

gvdhoorn gravatar image

updated 2017-09-11 03:21:31 -0500

Barring the use of any (proposed) standard messages for vision, this could be done using lists/unbounded arrays of some simpler messages (such as geometry_msgs, perhaps four Point32 per bbox, or Polygons).

Edit: note that there are actually people_msgs that may be more appropriate for this, as they carry a bit more information than just bounding boxes. There are also quite some packages that implement either face or people tracking, such as cob_people_detection, face_detector and face_recognition. If nothing else, it might be good to take a look at how those packages publish their results and perhaps use a similar / the same method. cob_people_detection uses the cob_people_detection_msgs fi.

edit flag offensive delete link more

answered 2017-10-21 14:17:26 -0500

Jasmin gravatar image

updated 2017-10-21 14:24:12 -0500

@gvdhoorn gave you very useful information and examples of similar message types which is interesting but having the same use case as yours I'm going with the following solution:

To acheive what you want, I think that you need to create and build your own message type, every detected face is sort of a ROI and the number of detections is rondom.

There is a predefined message type describing a ROI which is sensor_msgs/RegionOfInterest, so a message for a simple list of detected faces DetectedFaces.msg can be defined as follows:

sensor_msgs/RegionOfInterest[]  detected_faces

But it will be also useful to set an id or label for each detection and maybe a weigh or a score in order to pass all the intresting things to know about every single detection to your tracker or whatever subscriber to this message.

So I suggest creating two messages, one for a single detected face description DetectedFace.msg and a second one which is a list of all the detections DetectedFaceArray.msg so their msg definitions can be done as follows:

std_msgs/Int32 label
sensor_msgs/RegionOfInterest detected_face
std_msgs/Float32 weigh


your_pkg_name/DetectedFace[] detected_faces

You can also add headers to these messages and any other information that you find useful.

See this tutorial for more details about the steps and configuration needed to create and build msg files. and make sure to add the sensor_msgs and std_msgs as DEPENDENCIES in your package definition.

Once your msgs are compiled try to create a simple publisher and subscriber to check them out.

Good luck!

edit flag offensive delete link more


Thanks for taking the time to write such an extensive answer.

I must note though: your suggestion (label, roi and weigh[t]) is essentially what the cob_people_detection_msgs/html/PeopleDetection msg ..

gvdhoorn gravatar image gvdhoorn  ( 2017-10-23 02:22:01 -0500 )edit

.. contains:

std_msgs/Header header
string label
string detector
float32 score
cob_people_detection_msgs/Mask mask
geometry_msgs/PoseStamped pose

(mask contains a roi).

My recommendation to @danaitri would still be to use some existing msg, instead of a custom one.

gvdhoorn gravatar image gvdhoorn  ( 2017-10-23 02:23:17 -0500 )edit

You are absolutely right, the cob_people_detection_msgs/PeopleDetection msg is very suitable for his need, I didn't see its content till now, so thanks for the info :) .

Jasmin gravatar image Jasmin  ( 2017-10-23 02:47:18 -0500 )edit

answered 2017-10-23 02:52:21 -0500

danaitri gravatar image

updated 2017-10-23 02:53:35 -0500

Hello and thank you for taking the time to answer my question. I deployed Jasmin's solution and developed my own custom message. The ROI message has the following description (Called mva_roi, and belongs in the package mva_msgs)

int32 x int32 y int32 w int32 h int32 id int32 average_area

Then, as Jasmin suggested I defined an other message that contains a list of mva_roi messages:

mva_msgs/mva_roi[] message

I have tested it and it works, so I am now able to transfer detection and tracking messages between different nodes. Your help has been much appreciated. Thank you.


edit flag offensive delete link more


You're welcome! happy it helped :).

Jasmin gravatar image Jasmin  ( 2017-10-24 04:15:42 -0500 )edit

Question Tools



Asked: 2017-09-11 02:50:43 -0500

Seen: 1,287 times

Last updated: Oct 23 '17