0
$\begingroup$

Rosanswers logo

Hi,

I am playing a bag of 16 bits-per-pixel depth and 8 bit rgb images. While playing the bag, I can extract both the rgb and the depth images into files (verifying that the data is ok) (I used the thread here to create and extract the depth images)

The way the depth image is stored in the bag is by using a python script that uses the PIL package to read a pgm image from file into a PIL object, serialize the object data into byte array (using io.BytesIO()), and save the byte array in PPM format.

In rviz I can view the rgb image, but I cannot view the depth image.

rviz issues an error message:

[ WARN] [1548110467.614542827]: OGRE EXCEPTION(2:InvalidParametersException): Stream size does not match calculated image size in Image::loadRawData at /build/ogre-1.9-B6QkmW/ogre-1.9-1.9.0+dfsg1/OgreMain/src/OgreImage.cpp (line 283)
[ERROR] [1548110467.614620078]: Error loading image: OGRE EXCEPTION(2:InvalidParametersException): Stream size does not match calculated image size in Image::loadRawData at /build/ogre-1.9-B6QkmW/ogre-1.9-1.9.0+dfsg1/OgreMain/src/OgreImage.cpp (line 283)

The transport Hint in rviz is set to "raw" and I cannot change it.

Thanks,

Avner


Originally posted by Avner on ROS Answers with karma: 96 on 2019-01-21

Post score: 1


Original comments

Comment by gvdhoorn on 2019-01-24:
I would actually recommend to post your edit1 as an answer and then accept your own answer (by clicking the checkmark to the left of it).

That would much more clearly show that your question was answered.

Comment by Avner on 2019-01-29:
Done. Thanks for your comment.

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

RVIZ cannot view 16 bit images natively. You'll have to convert them to an 8 bit format.

There are various ways to do this. A simple method is to normalise the depth image to the range 0-255 and changed to an 8 bit image. Or a more meaningful conversion would be adding a color bar and scale.


Originally posted by PeteBlackerThe3rd with karma: 9529 on 2019-01-21

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by Avner on 2019-01-22:
Thanks for your answer. After using cv_bridge to add the 16 bit depth image into the bag, I can now see it in rviz without any special further adjustments. Does this mean that actually, rviz can handle 16 bit images? (maybe it does scale it down internally to 8 bit per pixel)

$\endgroup$
0
$\begingroup$

Rosanswers logo

I changed the way that the depth image is stored in the bag in the python script, to use cv_bridge instead of using the PIL.

im_depth = cv2.imread(depth_img, -1)
bridge = CvBridge()
# passthrough honors the original image encoding (mono16)
image_message = bridge.cv2_to_imgmsg(im_depth, encoding="passthrough")
image_message.header.stamp = Stamp
image_message.header.frame_id = "camera"
bag.write('camera/depth/image', image_message, Stamp)

After doing this, I can see the depth image in rviz.

p.s. as a sanity test, I extracted the files from the the bag and verified that they are actual 16 bit images (image type is 16 bit and pixel values are greater than 255)

I used the solution to execute rtabmap on a bag with rgb and 16 bit depth images. See here


Originally posted by Avner with karma: 96 on 2019-01-29

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.