Ask Your Question
0

mono16 image is wrongly formed when using compressed image_transport

asked 2018-08-21 11:54:37 -0600

autonomy gravatar image

I am dealing with a 16-bit mono image, publishing it using image_transport. I have no issues with the raw data topic, I can view it directly, bag it, replay it, and view again. If I run rostopic echo /cam/image | grep step I get 1280 as the result.

When I'm using image_view _image_transport:=compressed, I get an error message saying this:

Unable to convert 'mono16' image for display: : 'Image is wrongly formed: step < width * byte_depth * num_channels or 640 != 640 * 2 * 1

I'm using a vanilla image_transport publisher without changing any parameters. Am I missing something or is this a bug in the image_transport plugins?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-08-21 17:49:06 -0600

updated 2018-08-22 10:20:15 -0600

Compressed image transport only supports 8 bit image formats, so the 16 bit image you're using cannot be compressed by it. Is the image you're trying to compress a depth image? The compressed depth image transport package is designed specifically for this.

Hopefully this package will get this working for you.

EDIT : This may be OpenCV doing something a bit strange. It uses the OS codecs for image encoding/decoding so it's possible it behaves differently on different systems. You could make a simple node to receive the compressed image and debug the formatting and memory layout of the resulting cv::Mat object.

edit flag offensive delete link more

Comments

Is that documented? I don't see it on the wiki. I am dealing with an actual 16-bit image in the wild, not depth. Compressed depth image transport seems like it might work, though I was able to solve my problem by switching to PNG

autonomy gravatar imageautonomy ( 2018-08-22 08:29:11 -0600 )edit

<node name="$(anon dynparam)" pkg="dynamic_reconfigure" type="dynparam" args="set /camera/image/compressed format 'png'"> </node>

autonomy gravatar imageautonomy ( 2018-08-22 08:29:18 -0600 )edit

This was from a project a while ago. I've just had a look into the source code and the OpenCV documentation, and it looks as though it should support 16 bit images with PNG compression without any problems. It uses cv::imencode and cv::imdecode under the hood.

PeteBlackerThe3rd gravatar imagePeteBlackerThe3rd ( 2018-08-22 10:14:48 -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: 2018-08-21 11:54:37 -0600

Seen: 668 times

Last updated: Aug 22 '18