Items with no label
3335 Discussions

Read Raw Depth Image with MATLAB/Record Stream

AAvis
Beginner
3,853 Views

Hi,

I'm new in using Intel RealSense Depth module.

Currently I have 2 modules - D415/D435

I have downloaded the Intel.RealSense.Viewer.exe and started Depth and Video streams.

I have captured 1 raw Depth image and now trying simply to read it in MATLAB.

I'm using a very simple code:

FID = fopen('IntelDepth.raw');

DepthImage = fread(FID, [720, 1280], 'uint8');

fclose(FID)

but I get a Depth image which is probably wrong.

Another issue I would like to handle - Is there any simple way to capture a stream of images instead of 1 with Intel.RealSense.Viewer.exe?

Thanks!

0 Kudos
9 Replies
MartyG
Honored Contributor III
1,601 Views

A MATLAB wrapper for the RealSense SDK 2.0 is currently being worked on by the RealSense development team, which should make using the 400 Series cameras with MATLAB much easier. The most recent estimate of a release schedule for this on June 27 was in 'a couple of sprints' (sprints being terminology for development time-cycles).

So as the SDK tends to get updated roughly every couple of weeks, I would estimate that 'a couple of sprints' after June 27 might be the update after next, maybe around end July / start August. That's by no means an official date though .... "it's here when it's here" is probably better.

Regarding capturing all frames with the RealSense Viewer: the Viewer can record frames into a file type called a 'rosbag'. Bear in mind though that the resultant file can be very large, with some reporting file sizes in the range of 20 GB. On the link below, scroll down to the heading 'Record and playback in RealSense Viewer'.

https://github.com/IntelRealSense/librealsense/blob/master/src/media/readme.md librealsense/readme.md at master · IntelRealSense/librealsense · GitHub

0 Kudos
AAvis
Beginner
1,601 Views

Dear Marty,

Thank you for your prompt reply.

I understand that soon RealSense SDK will soon include MATLAB wrapper.

Though, in case I would like to try some basic and simple function such as reading Depth image into a numeric matrix (preferably with MATLAB but not mandatory) is there any simple method to read the raw image and rosbag file?

Is there an option to record (and later read) Disparity file?

0 Kudos
MartyG
Honored Contributor III
1,601 Views

The best reference currently available as far as I know is a long discussion about generating a disparity map with the 400 Series.

0 Kudos
AAvis
Beginner
1,601 Views

Dear Marty,

I there any update regrading the MATLAB wrapper?

Thanks!

0 Kudos
MartyG
Honored Contributor III
1,601 Views

There's no fresh news yet about the MATLAB wrapper. There have been some interesting discussions about MATLAB on this forum during the past month though.

0 Kudos
NTala
Beginner
1,601 Views

Hello Marty,

I recently downloaded the intel RealSense SDK 2.0 and I got a checkbox during installation for MATLAB stuff that I ticked. I got some MATLAB files which seem like classes to make different kinds of objects. However, since I am really new to this, I was wondering if there is some examples/documentation I could look at to operate the RealSense camera entirely in MATLAB and gather data in matrix form for 3d point cloud (I am interested in depth as well). I basically want it to update data regarding depth,etc. in a matrix in MATLAB in realtime. Any help towards achieving this including sample code is much appreciated!

Best Regards,

Neel

0 Kudos
MartyG
Honored Contributor III
1,601 Views

The documentation for the MATLAB wrapper is a bit slim at the moment, as the wrapper was introduced only recently. It contains the setup instructions and a simple example for displaying a depth frame.

https://github.com/IntelRealSense/librealsense/tree/master/wrappers/matlab librealsense/wrappers/matlab at master · IntelRealSense/librealsense · GitHub

If you would prefer to access data in MATLAB more directly though, on the page linked to below there is a MATLAB function that can be downloaded that converts a depth image to a point cloud in MATLAB. Scroll down the page to the heading titled 'Depth Image to Point Cloud (MATLAB)' and click on the 'depthToCloud.m' link to launch its download in your browser.

https://rgbd-dataset.cs.washington.edu/software.html RGB-D (Kinect) Object Dataset

0 Kudos
idata
Employee
1,601 Views

Hi,

in order to read raw file produce with Intel.RealSense.Viewer.exe

use this code:

FID = fopen('IntelDepth.raw');

DepthImage = fread(FID, [1280, 720], 'uint16')';

fclose(FID);

make sure you configure the depth image as z16 (16 bit)

To capture a stream of images use the recorded button.

0 Kudos
VT000
Beginner
1,601 Views

Hello idata,

I saw this post. I have a problem to with RealSense Viewer.

How can I extract the point cloud and RGB, XYZ arrays from "bag" file with Matlab, when I record a scene using RealSense Viewer in Win10? I am using RealSense D415&D435 and the data are stored in "bag" file.

I tried with matlab functions: rosbag, select, readMessages, but I can't extract the point cloud and the XYZ array of the scene/frame. I only got the RGB or the INFRA image data with mentioned functions (the dimensions should be 640x480x3, 307200x3 arrays for RGB and XYZ).

Or, when I run the pointcloud_example Matlab function from wrapper, how can I get the variables? I got only two empty figures. Do you have any tutorial for Matlab wrapper?

I need an point cloud 1 message with RGB and XYZ arrays for image processing? Can I get this somehow? I am using Matlab. I hope someone will help me.

Thank you in advance.

 

0 Kudos
Reply