Decompress "/depth/depth_registered/compressed" after rosbag recording fails

Using rosbag to record compressedDepth images is failing to decompress on python, the resulting image ends up binary, losing all depth information.

depth_np_arr = np.frombuffer(, np.uint16)
cv_image_depth = cv.imdecode(depth_np_arr, cv.IMREAD_UNCHANGED)

Hi @Shaza-Kaoud
You cannot directly read a compressed image.
You must subscribe to it by using the appropriate camera subscriber:

I had a subscriber, basically while creating the bagfile, now the compressedDepth image is unit16 and compressed with JPEG instead of PNG, I can decompress the color image normally, the problem is with the depth and how it was formed by the wrapper, no normal flow would work:

It seams like the openni option makes the data go through an unsupported flow

You must remember that the standard depth mode uses 32bit float data, OpenNI instead uses 16 bit unsigned int data.
So you must correctly transform the data

Yes, I can not find a standard transformation for the 16-bit unsigned int data that had undergone JPEG compression, opencv ends up converting to a binary image!

Thank you so much @Myzhar for the attempts. Apparently, the file I was trying to read was recorded before the 3.7 release of the wrapper. Release v3.7.x · stereolabs/zed-ros-wrapper · GitHub , before the openni fix

1 Like