Ask Your Question

sensor_msgs/Image data to sensor_msgs/CompressedImage data

asked 2019-04-02 01:31:15 -0600

Bryant gravatar image

updated 2019-04-02 01:32:26 -0600

I have an industrial camera (DVP interface), and I added some code in the driver to convert the cv image into ros image data. I want to use this camera to test the fiducials package. But it needs to subscribe to a sensor_msgs/CompressedImage topic, and now the driver can only provide the sensor_msgs/Image topic. Is there any way to convert the sensor_msgs/Image data into sensor_msgs/CompressedImage data?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2019-04-02 02:39:52 -0600

gvdhoorn gravatar image

Is there any way to convert the sensor_msgs/Image data into sensor_msgs/CompressedImage data?

yes: the republish node of the image_transport package can convert between uncompressed and compressed images (between any registered transports actually).

Note: this will incur overhead, as it subscribes, compressed and then publishes messages.

edit flag offensive delete link more


Thank you! It solved my problem. This is my method:rosrun image_transport republish raw in:=/usb_cam/image_raw compressed out:=/usb_cam/image_raw. Before use this node, ros-$ROS_DISTRO-image-transport and ros-$ROS_DISTRO-image-transport-plugins should be installed.

Bryant gravatar imageBryant ( 2019-04-02 07:37:54 -0600 )edit

is that correct, or a typo?

I would not publish on the exact same topic. Or does republish add a subtopic (ie: /usb_cam/image_raw/compressed)?

gvdhoorn gravatar imagegvdhoorn ( 2019-04-02 07:39:51 -0600 )edit

Because my camera driver will only generate a usb_cam/image_raw topic, and image_transport node will generate a new topic usb_cam/image_raw/compressed based on the parameter compressed of out.

Bryant gravatar imageBryant ( 2019-04-02 07:50:07 -0600 )edit

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


Asked: 2019-04-02 01:31:15 -0600

Seen: 478 times

Last updated: Apr 02