Main Content

Read Point Clouds

You can preview and read point clouds from the supported lidar sensors using the preview and read functions. You can read all available point clouds or read a subset that you select. You can specify number of point clouds to read and specify them as the latest or the oldest point clouds in the buffer using arguments of the read command.

Preview Point Clouds

You can preview your Velodyne LiDAR® point clouds before acquiring the data.

  1. Create a velodynelidar object, v, for use with a model HDL-32E sensor.

    v = velodynelidar('HDL32E');
  2. Preview the point cloud data.

    preview(v);

    The preview window opens.

  3. When you are done previewing, close the window.

    closePreview(v);

    You must close the preview window before you can use the read function to acquire data.

Read Point Clouds Without Buffering

You can use the read function to acquire point clouds, with or without using the start function, to start streaming point clouds first.

When you use the read function without having used the start function, the streaming is started, the point clouds are read, then streaming is stopped. You can read the latest point cloud this way, or a specified number of point clouds.

To get the latest point cloud without buffering:

  1. Create a velodynelidar object, v, for use with a model HDL-32E sensor.

    v = velodynelidar('HDL32E');
  2. Preview the point cloud data.

    preview(v);

    The preview window opens.

  3. When you are done previewing, close the preview window.

    closePreview(v);

    You must close the preview window before you can use the read function to acquire data.

  4. Get the latest point cloud.

    [pcloud, timestamp] = read(v, 'latest');
  5. Display the point cloud.

    pcshow(pcloud);

    The point cloud is displayed in a Figure window.

    Note that pcshow is part of the Computer Vision Toolbox.

To get multiple point clouds without buffering:

  1. Create a velodynelidar object, v, for use with a model HDL-32E sensor.

    v = velodynelidar('HDL32E');
  2. Read 10 point clouds.

    [pcloud, timestamp] = read(v, 10);

    Ten point clouds are acquired and a 10x1 point cloud object is created. You can then use the pcplayer function to visualize the point cloud data. For more information about using pcplayer, see pcplayer.

Read Point Clouds from the Buffer

When you use the read function without having used the start function, the streaming is started, the point clouds are read, then streaming is stopped. You can read the latest point cloud this way, or a specified number of point clouds.

Alternatively, you can use the start function to start streaming point clouds, and then use the read function to read one or multiple point clouds, choosing the latest or the oldest in the buffer, or read all point clouds in the buffer.

Get Latest Point Cloud

To get the latest point cloud from the buffer:

  1. Create a velodynelidar object, v, for use with a model HDL-32E sensor.

    v = velodynelidar('HDL32E');
  2. Preview the point cloud data.

    preview(v);

    The preview window opens.

  3. When you are done previewing, close the preview window.

    closePreview(v);

    You must close the preview window before you can use the read function to acquire data.

  4. Start streaming point clouds.

    start(v)
  5. Get the latest point cloud from the buffer.

    [pcloud, timestamp] = read(v, 'latest');

    When you read the latest point clouds in the buffer, older point clouds will be discarded.

  6. Display the point cloud.

    pcshow(pcloud);

    The point cloud is displayed in a Figure window.

    Note that pcshow is part of the Computer Vision Toolbox.

  7. You can stop streaming point clouds at any time.

    stop(v)

Get Oldest Point Cloud

To get the oldest point cloud from the buffer, use this syntax in step 5:

[pcloud, timestamp] = read(v, 'oldest');

Get All Point Clouds

To get all available point clouds from the buffer, use this syntax in step 5:

[pcloud, timestamp] = read(v, 'all');

Get a Specified Number of Point Clouds

You can read a specified number of point clouds from the buffer by using the NumPointClouds property.

  1. Create a velodynelidar object, v, for use with a model HDL-32E sensor.

    v = velodynelidar('HDL32E');
  2. Start streaming point clouds.

    start(v)
  3. Get the 20 latest point cloud from the buffer. The NumPointClouds property comes after the object name, for the number of point clouds you want to read. That argument is followed by the mode, which designates whether to read the latest or oldest point clouds in the buffer. In this case you get the 20 latest point clouds in the buffer.

    [pcloud, timestamp] = read(v, 20, 'latest');

    When you read the latest point clouds in the buffer, older point clouds are discarded.

  4. You can stop streaming point clouds at any time.

    stop(v)

To get the 20 oldest point clouds from the buffer, use this syntax in step 3:

[pcloud, timestamp] = read(v, 20, 'oldest');

When you read the oldest point clouds in the buffer, newer point clouds continue to exist and be available.

When you acquire multiple point clouds, you can then use the pcplayer function to visualize the point cloud data. For more information about using pcplayer, see pcplayer.

Flush the Buffer

You can flush point clouds from the buffer by using the flush function.

  1. Create a velodynelidar object, v, for use with a model HDL-32E sensor.

    v = velodynelidar('HDL32E');
  2. Start streaming point clouds.

    start(v)
  3. You can flush the buffer of point clouds at any time. This deletes all point clouds currently in the buffer.

    flush(v);

    The state of streaming is maintained when you flush the buffer. In this case, because start was called to begin streaming before flush was called, flush deletes the existing point clouds in the buffer, and then continues streaming.

See Also

| | | | | |

Related Topics