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

sensor_msgs/Image data to sensor_msgs/CompressedImage data

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

anonymous user


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

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 -0500

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.

anonymous userAnonymous ( 2019-04-02 07:37:54 -0500 )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 image gvdhoorn  ( 2019-04-02 07:39:51 -0500 )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.

anonymous userAnonymous ( 2019-04-02 07:50:07 -0500 )edit

How to republish sensor_msgs/CompressedImage data to sensor_msgs/Image data ? I use "rosrun image_transport republish compressed in:=/usb_cam/image_raw/compressed raw out:=/usb_cam/image_raw". But thereis no data.When I run "rostopic echo /usb_cam/image_raw", There is nothing. Where is the problem ?

sunt40 gravatar image sunt40  ( 2020-10-19 00:55:50 -0500 )edit

Question Tools

1 follower


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

Seen: 6,187 times

Last updated: Apr 02 '19