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

Making sense of 16-bit jpeg compressed data from Intel RealSense D435i camera

asked 2022-06-15 06:10:50 -0500

pointsnadpixels gravatar image

updated 2022-06-15 08:18:25 -0500

Hello,
I recorded some data from an Intel RealSense D435i with the /camera/aligned_depth_to_color/image_raw/compressed topic; I use image transport to subscribe to it (in C++), and do the following:

cv_bridge::CvImageConstPtr cv_ptrD; try { cv_ptrD = cv_bridge::toCvShare(msgD) ; } catch (cv_bridge::Exception& e) { ROS_ERROR("cv_bridge exception: %s", e.what()); return; }
EDIT: I forgot to mention that this gives me the error: [ERROR] : cv_bridge exception: Image is wrongly formed: step < width * byte_depth * num_channels or 848 != 848 * 2 * 1

On running rostopic echo /camera/aligned_depth_to_color/image_raw/compressed/format I get the output: "16UC1; jpeg compressed " . My understanding is that jpeg compression works only for 8 bit data, and the png compression should be used for 16-bit.
Does this then mean that the data from this topic is useless since the raw data was compressed with the wrong compression format or is there some other way to make sense of the data? Relevant issue in the realsense-ros github: https://github.com/IntelRealSense/rea...

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-06-15 08:05:07 -0500

Alex-SSoM gravatar image

I've been using this formula and it works alright

cv_bridge::CvImageConstPtr cv_ptr

float pixel_depth = static_cast<float>(cv_ptr->image.at<unsigned short>(x, y));

edit flag offensive delete link more

Comments

Hi, thank you! Let me try this out. Were you using this for the compressed topic?

pointsnadpixels gravatar image pointsnadpixels  ( 2022-06-15 08:08:11 -0500 )edit

Yes with 16UC1; compressedDepth rvl

Alex-SSoM gravatar image Alex-SSoM  ( 2022-06-15 08:55:53 -0500 )edit

ah, okay. My problem is with jpeg. I think it works fine for other compression formats which support 16 bit.

pointsnadpixels gravatar image pointsnadpixels  ( 2022-06-15 09:27:11 -0500 )edit

Well jpeg is a lossy compression algorithm. It doesn't work with depth data. The image_transport_plugins/compressed_depth_image_transport uses either PNG or RVL which are lossless compression formats. See config definition file. In my experience, the RVL compression uses less resources and is faster than PNG.

Alex-SSoM gravatar image Alex-SSoM  ( 2022-06-15 15:05:07 -0500 )edit

Yeah, I'm aware of that. Unfortunately, only the /camera/aligned_depth_to_color/image_raw/compressed topic was recorded, and hence my question.

pointsnadpixels gravatar image pointsnadpixels  ( 2022-06-16 06:32:25 -0500 )edit

You'll need a new recording, as nothing can be done to fix a erroneous recording.

Alex-SSoM gravatar image Alex-SSoM  ( 2022-06-21 07:29:53 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2022-06-15 06:10:50 -0500

Seen: 577 times

Last updated: Jun 15 '22