Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to convert uint8 data captured by Depth to the correct 'mono16'? #13542

Open
wenmingxiaohuo opened this issue Nov 25, 2024 · 9 comments
Open
Labels

Comments

@wenmingxiaohuo
Copy link

  • Before opening a new issue, we wanted to provide you with some useful suggestions (Click "Preview" above for a better view):

  • All users are welcomed to report bugs, ask questions, suggest or request enhancements and generally feel free to open new issue, even if they haven't followed any of the suggestions above :)


Required Info
Camera Model { R200 / F200 / SR300 / ZR300 / D400 }
Firmware Version (Open RealSense Viewer --> Click info)
Operating System & Version {Win (8.1/10) / Linux (Ubuntu 14/16/17) / MacOS
Kernel Version (Linux Only) (e.g. 4.14.13)
Platform PC/Raspberry Pi/ NVIDIA Jetson / etc..
SDK Version { legacy / 2.. }
Language {C/C#/labview/nodejs/opencv/pcl/python/unity }
Segment {Robot/Smartphone/VR/AR/others }

Issue Description

<Describe your issue / question / feature request / etc..>

@MartyG-RealSense
Copy link
Collaborator

Hi @wenmingxiaohuo RealSense depth data is not 8-bit. It is 16-bit uint16_t.

@wenmingxiaohuo
Copy link
Author

filename='D:\RecordData_D435\20241125_111919.bag'; % validateattributes(filename, {'char','string'}, {'scalartext', 'nonempty'}, '', 'filename', 1); bag=rosbag(filename); mes=select(bag,'Topic','/device_0/sensor_0/Depth_0/image/data'); poseStructs = readMessages(mes, 'DataFormat', 'struct'); %
Getting information from the depth sensor,
image
The Data is unit8 but the decoding method is mono16.

@wenmingxiaohuo
Copy link
Author

wenmingxiaohuo commented Nov 25, 2024

Thanks for the quick answer, also if you use pipe to get the data you will get the uint16 data
`for i = 1:5
fs = pipe.wait_for_frames();
end
depth = fs.get_depth_frame();
dwidth = depth.get_width();
dheight = depth.get_height();
units = depth.get_units();
Temp=depth.get_data();
depthdata = (reshape(depth.get_data(),dwidth,dheight))';
depthdata = double(depthdata)*units;
image

@MartyG-RealSense
Copy link
Collaborator

You are very welcome. Thanks for sharing your code!

@wenmingxiaohuo
Copy link
Author

Thanks, but I'm still a little confused.
I want to convert 814080 of uint8 to 407040 of uint16, what should I do?

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Nov 25, 2024

Was the bag file recorded in ROS and you are attempting to read it using the librealsense SDK, please? If it is a ROS bag then it will be difficult to use with librealsense because there are differences between the rosbag format of ROS and librealsense's SDK-bag format, as advised at #3020 (comment)

8-bit to 16-bit conversion is not usually something that is done with RealSense depth data, but the non-RealSense link below might provide some ideas about how to do it.

https://stackoverflow.com/questions/52183191/convert-uint8-t-array-to-uint16-t

@wenmingxiaohuo
Copy link
Author

Ok thanks for the answer, I see what you mean. Also in response to your reply there is a small question, 'D:\RecordData_D435\20241125_111919.bag' is the data captured using the D435, how can I tell if this bag file is a ROG bag file?

@wenmingxiaohuo
Copy link
Author

Sorry, I have other things to take care of, so please just leave a message at your leisure. Thank you for every answer, bye!

@MartyG-RealSense
Copy link
Collaborator

A quick way to test whether a bag file might be a ROS bag is to drag and drop the file into the center panel of the RealSense Viewer tool if you have access to that tool. If there is an error message instead of the bag starting to play automatically then there is a good chance that it is a rosbag instead of an SDK-bag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants