ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Conversion of RGB8 depth encoding to 32FC1

asked 2021-12-22 09:09:33 -0500

KNTRL gravatar image

updated 2021-12-23 09:56:39 -0500

To break it down as simple as possible:

When working with a Realsense D435 with the respective package, you can enable the 'colorizer' filter which delivers an RGB depth image topic, meaning that blue colors are close, red colors are far, and the regular color spectrum inbetween. I have to work with rosbags filled with colorized depth data.

I want to convert this rgb8 encoded depth image into 32FC1 while still having all of the depth information. Making use of OpenCV's cv2.COLOR_RGB2GRAY to convert it leads to nothing, as a blue color won't end up black, while a red color won't turn white.

I hope I stated my problem appropriate. I did my research, but as I am new to OpenCV and image processing in general, I had no success so far to find an appropriate conversion. As I am struggling to read cpp code, I am not able to reverse engineer the process where the grayscale depth image gets converted into that rgb8 encoded format.

edit retag flag offensive close merge delete


Your method seems very inefficient. Why are you not using the depth values directly, then manipulating the info into whatever you want?

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-12-23 08:21:33 -0500 )edit

I kept the info above too brief. The depth data I have is stored in rosbags, which were recorded with that realsense colorizer filter. I am trying to feed the bags into an rtabmap node, which only accepts 32FC1 and mono16 encoding. And I have no clue how to extract depth data out of that RGB8 image, as the mapping is nowhere explained.

Of course it would be the easiest way to record without the colorizer to get the data I need, but all I have for now are these (colorized) rosbags.

KNTRL gravatar image KNTRL  ( 2021-12-23 09:55:06 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2021-12-23 11:20:17 -0500

Mike Scheutzow gravatar image

Intel has been pretty good about publishing technical docs and source code. Have you looked for the algorithm being used by that filter? That seems like the best way for you to construct the inverse function.

I would start here:

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2021-12-22 09:09:33 -0500

Seen: 380 times

Last updated: Dec 23 '21