Ask Your Question
0

Size of a CompressedImage

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

Younès gravatar image

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

    sub=rospy.Subscriber("irat_red/camera/image/compressed",CompressedImage,image_callback,pub_vt)

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
2

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

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

Comments

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

Younès gravatar imageYounès ( 2017-09-30 17:03:23 -0600 )edit

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

preed gravatar imagepreed ( 2017-10-02 09:36:59 -0600 )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 imageYounès ( 2017-10-02 10:38:41 -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

2 followers

Stats

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

Seen: 409 times

Last updated: Sep 29 '17