how to read 16UC1 encoded uint8 depth data
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ramanpreet
am 10 Jun. 2016
Beantwortet: Sebastian Castro
am 21 Mär. 2018
I have a ros bag file saved from ubuntu using rosbag capture command on the terminal using a kinect and some other sensors. Now i am trying to read the file in matlab on my windows machine. I can read the data, and color image just fine. For color image, i had to demosaic but it works correctly.
My problem is arising on depth image. As you can see in the image it is saved using 16uc1 flag, but is a uint8 datatype with double the arraysize (640*480 should be 307200, this one is twice that). How do i read in the depth information properly in matlab from a standard rosbag file. The topic i am listening to is /camera/depth_registered/image_raw is that helps.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/166220/image.png)
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 10 Jun. 2016
reshape(typecast(Data, 'uint16'), Height, Width)
Possibly you might need
reshape(typecast(Data, 'uint16'), Width, Height) .'
Weitere Antworten (1)
Sebastian Castro
am 21 Mär. 2018
While Walter's approach is correct, there is a Robotics System Toolbox function called "readImage" which already operates on these image ROS messages and uses whatever encoding is provided.
img = readImage(msg)
... where msg corresponds to the above object.
- Sebastian
0 Kommentare
Siehe auch
Kategorien
Mehr zu ROS Log Files and Transformations finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!