How can I get an RGB point cloud in MATLAB* for Intel® RealSense™?


Product Information & Documentation



Issue Encountered
I would like to acquire and plot RGB colored point clouds from a D435 in MATLAB*. Can I access and use the vertices and textures to reformat the RealSense point cloud object into a MATLAB point cloud object?

Intel® RealSense™ Software Developer's Kit 2.0
Intel® RealSense™ D400 Series Depth Cameras


The RealSense team is working on an example for how to color a point cloud in MATLAB. Currently, we don't have an ETA (estimate time of arrival).  

Meanwhile, you can check this thread, which contains a code for acquiring an RGB (red, green, blue) colored point cloud in MATLAB (read comments for a quick fix to an issue related to align.m superclass).

If you want to acquire only the point cloud, without RGB, you can use the following code:

% Make Pipeline object to manage streaming
pipe = realsense.pipeline();

% define point cloud object
pcl_obj = realsense.pointcloud();

% Start streaming on an arbitrary camera with default settings

% Get frames. We discard the first couple to allow
% the camera time to settle
for i = 1:5
frames = pipe.wait_for_frames();

% Select depth frame
depth = frames.get_depth_frame();

% get point cloud points without color
pnts = pcl_obj.calculate(depth);
vertices = pnts.get_vertices();

% optional: populate MATLAB point cloud object
pCloud = pointCloud(vertices);

%display point cloud