Ask Your Question

Size of a CompressedImage

asked 2017-09-29 10:44:54 -0500

Younès gravatar image

I have a compressed image in a bagfile. I am subscribed to the topic with :


I want to get the width and the hight of this CompressedImage to using it in a callback. What should I do

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2017-09-29 15:16:19 -0500

In general, subscribing directly to a CompressedImage topic isn't what you want to do; in C++, you would want to use the image_transport mechanism, which will handle decompressing it for you.

Unfortunately, that doesn't work in Python. Your options are either:

  • Run an image_transport/republish node that will subscribe to the CompressedImage topic, publish it as an Image topic, and subscribe to that.

  • Look at the format field of the CompressedImage message to determine the compression type, then use an appropriate Python library to manually decompress the image data and extract the height and width.

edit flag offensive delete link more


I can't use republish since it is not recognized by my Ubuntu 16.04. How could I resolve this problem?

Younès gravatar image Younès  ( 2017-09-30 17:03:23 -0500 )edit

It does exist in 16.04, although you might not have it installed. Try sudo apt install ros-kinetic-image-transport.

preed gravatar image preed  ( 2017-10-02 09:36:59 -0500 )edit

It was already installed in my Ubuntu. I used the command rosrun image_transport republish compressed in:=/irat_red/camera/image image_transport:=compressed raw out:=/irat_red/camera/image It works

Younès gravatar image Younès  ( 2017-10-02 10:38:41 -0500 )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



Asked: 2017-09-29 10:44:54 -0500

Seen: 853 times

Last updated: Sep 29 '17