Image_transport for Python node

asked 2019-10-25 15:00:17 -0600

Heelbruise gravatar image

In http://wiki.ros.org/image_transport#r..., it is said that "image_transport does not yet support Python, though it is on the Roadmap. If you need to interface a Python node with some compressed image transport, try interposing a republish node."

Can someone help me with the republish node solution? Perhaps some example code? I have no idea how this implementation would look like.

edit retag flag offensive close merge delete

Comments

I think the intention of this comment is that you should write a C++ node that uses an image_transport subscriber to subscribe to the compressed image data, and then publish the data in an uncompressed format for your Python node to subscribe to. This C++ node would be the "republish node". The tutorials for image_transport should give a pretty good idea of how to write that node.

jarvisschultz gravatar image jarvisschultz  ( 2019-10-25 18:22:24 -0600 )edit

@jarvisschultz I am a bit confused. How would the Python node subscribe to this data? The first sentence of the image_transport documentation says "image_transport should always be used to subscribe to and publish images." Python doesn't have image_transport so how would I subscribe to that republished uncompressed image format that you are referring to?

Also, I have another question. In section 4 of this guide, http://wiki.ros.org/cv_bridge/Tutoria... they use Python to subscribe to images topic. What is going on?

Heelbruise gravatar image Heelbruise  ( 2019-10-25 19:05:48 -0600 )edit
1

I think the intention of this comment is that you should write a C++ node that uses an image_transport subscriber to subscribe to the compressed image data, and then publish the data in an uncompressed format for your Python node to subscribe to.

image_transport/republish already supports this.

Should be no need to write something custom.

Still a bit of a kludge though.

gvdhoorn gravatar image gvdhoorn  ( 2019-10-26 04:33:49 -0600 )edit

@Heelbruise: please don't post additional/follow-up questions in comments. It's your question already, so edit your original question text and append it.

But do please note that ROS Answers (ie: Askbot) is not a forum. The ideal ratio of questions-to-answers is 1:1.

gvdhoorn gravatar image gvdhoorn  ( 2019-10-26 04:34:39 -0600 )edit

Good point @gvdhoorn! I completely forgot about the republish capability.

jarvisschultz gravatar image jarvisschultz  ( 2019-10-28 12:25:22 -0600 )edit

@gvdhoorn OK I will ask on a separate post :)

@jarvisschultz any answer to my confusion?

Do I understand this correctly?: Python can sub to image/compressed but not /image so: 1. Republish /image to image/compressed in c++ but without actually compressing 2. subscribe to /compressed image in python node?

Heelbruise gravatar image Heelbruise  ( 2019-10-28 15:11:10 -0600 )edit

Both the comment you originally asked about and the image_transport/republish that @gvdhoorn mentioned are working around the limitation that Python can't natively use image_transport to subscribe to the compressed/streaming transports. The goal of the "republisher" is to take in a compressed stream topic and output a sensor_msgs/Image topic for Python to subscribe to. You shouldn't have to write an C++ code, just a launch file that starts a republisher with the correct stream types and topic remappings.

jarvisschultz gravatar image jarvisschultz  ( 2019-10-28 16:30:41 -0600 )edit