Point Cloud Acquisition and Viewing

This documentation shows how to acquire and view point clouds.

Contents

Introduction

The main documentation for point cloud functionality in MATLAB is located here: 'vision/point-cloud-processing.html')) Point Cloud Processing

Import from LIDAR

Data from standard LIDAR devices can be imported into MATLAB or Simulink using the serial, udp or tcpip methods. There is no one demo that can show how to transmit commands and import data with all LIDAR's since the protocols are different.

You can use serial, udp or tcpip from the Instrument Control and DSP System Toolboxes to communicate with your LIDAR device. To determine which communication method to use, see the following module:

Communicate using UDP, TCP/IP and Serial

There are several demos on the MathWorks File Exchange that show how to import data from specific LIDAR units:

Import from Stereo Vision Camera

The Image Acquisition Toolbox supports the acquisition of images from Point Grey Stereovision cameras (i.e. Bumblebee2) as well as multiple cameras at the same time.

To install the necessary adaptor for your camera, use supportPackageInstaller. To determine which adaptor to use, see the following chart

Image Acquisition Support Packages for Hardware Adaptors.

A standard USB camera in Windows would fall under the "Windows Video" category, and therefore the adaptor name would be 'winvideo'.

The syntax for acquiring two images from a single stereovision camera or two camera is as follows:

vobj1 = imaq.VideoDevice(adaptorname,deviceid1);
vobj2 = imaq.VideoDevice(adaptorname,deviceid2);
frame = step(vobj1);
frame2 = step(vobj2);

If you were using two generic Windows usb cameras, the code would look like:

vobj1 = imaq.VideoDevice('winvideo',1);
vobj2 = imaq.VideoDevice('winvideo',2);
frame1 = step(vobj1);
frame2 = step(vobj2);

If you were using a Point Grey Bumblebee2 stereovision camera, the code would look like: vobj1 = imaq.VideoDevice('pointgrey',1); vobj2 = imaq.VideoDevice('pointgrey',2); frame1 = step(vobj1); frame2 = step(vobj2);

Visualizing Point Clouds

To visualize a point cloud in MATLAB, use the showPointCloud and scatter3 command.

One-Time Visualization

If you want to visualize a point cloud frame once and are not running a video, use the showPointCloud command directly:

showPointCloud(pointCloudFrame,colorMapFrame);

Streaming Visualization

If you want to visualize a point cloud video quickly and repetively, use the scatter3 command with the "set" command. The scatter3 command creates the initial plot. The set command runs much quicker than showPointCloud and therefore updates it quickly.

% initialize a 3D Scatter plot
h3ds = scatter3(0,0,0,'Marker','.');
% set the 3d Scatter plot's data at each step
while(videoNotFinished)
   % plot the 3D Point Cloud
    set(h3ds,'XData',pointCloudFrame(:,1),'YData',pointCloudFrame(:,2),'ZData',pointCloudFrame(:,3),...
               'CData',colorMapFrame);
end

Examples

To see an example of One-Time and Streaming Visualization, see the following:

Open Example