Ask Your Question

Revision history [back]

Firstly you should avoid subscribing directly to the compressed topic, and use the image_transport package to deal with any decompression transparently.

The example shown in the image_transport tutorials shows how to set this up. You can request that it uses the compressed topic if possible using a TransportHints object as shown below:

image_transport::Subscriber itSub;
image_transport::ImageTransport it(n);
itSub = it.subscribe("base_img_topic",1,&imgCallback,image_transport::TransportHints("compressed"));

This way you never have to deal with the compression or decompression directly. If you're still getting 8 bit images using this method then there may be a problem with the publishing node, that means it's publishing 8 bit images. But hopefully this will get this working.