Ask Your Question
1

Publishing compressed images

asked 2013-07-01 03:58:58 -0600

Jep gravatar image

Hi all,

I have a camera that is giving me JPEG images.

The compressed_image_transport overview says: "When writing a driver for such a camera, a quick and dirty approach is to simply copy the JPEG data into a sensor_msgs/CompressedImage message and publish it on a topic of the form image_raw/compressed."

So:

1- I guess there isn't any way to use image transport and saying the data we are publishing is compressed. Right?

2- If the alternative way is "quick and dirty" what would be the proper way to do this?

Thanks in advance,

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2018-06-28 09:39:44 -0600

Mark Rose gravatar image
  1. By publishing the message as message type CompressedImage, you are implicitly saying that the image is compressed. You should further indicate that by using standard naming conventions for the topic. The compressed image topic ends with "/compressed". So you might use a topic like "<camera-name>/image/compressed" or just "image/compressed", if you have only one camera. (You'll notice that in some tools, and in the image_transport package, you will specify the topic name without that suffix, and instead specify that the transport is "compressed". Rviz is one such tool.)
  2. In this case the "quick and dirty" approach is a very valid ROS mechanism. MJPEG compressed video format is just a sequence of JPEG images. Those are easy to deal with in OpenCV and do a reasonable job of compression, albeit not as small as more sophisticated schemes. And they have the advantage that individual frames can be processed separately, because there is no "key frame"/"intermediate frame" distinction. Unless you have performance or bandwith problems, using JPEG image frames is "proper" enough. On the other hand, if you want to publish uncompressed frames, because downstream nodes can't handle compressed images, then you can decompress as soon as you receive the frames using OpenCV and publish uncompressed. (In my case I'm getting JPEG frames in an MJPEG stream from a Raspberry Pi camera and publishing them compressed, because further processing is happening on another host, so the frames are sent across the network. If I were processing them on a single host it might be more efficient to publish them uncompressed, but you might have to measure to make sure.)
edit flag offensive delete link more
1

answered 2017-02-27 12:42:53 -0600

tb12 gravatar image

updated 2017-02-27 12:43:30 -0600

you can republish the compressed image as an uncompressed image:

rosrun image_transport republish compressed in:=/image_raw out:=/image_raw

edit flag offensive delete link more

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

Stats

Asked: 2013-07-01 03:58:58 -0600

Seen: 1,391 times

Last updated: Jun 28 '18