Deep Learning

Lidar Code-Along

Learn how to load point cloud data, preprocess datasets, define and train networks, and generate detections.

To follow along:

  1. Download the code
  2. Open in MATLAB

Don’t have access? Get a free trial now.

Time to Complete:
15–30 minutes
Basic MATLAB skills

Need a refresher? Try a free, interactive tutorial.

Step 1

Load Point Cloud Data and Corresponding Labels

Load point cloud data, load bounding box labels, and split training and testing sets.


What you learned: To load point cloud data and corresponding labels

  • Load point cloud data as fileDatastore with pcread function
  • Load bounding box labels using boxLabelDatastore function
  • Split training and testing sets

Step 2

Preprocess Data Sets

Split a data set into training and test sets and discover various augmentation techniques.


What you learned: Splitting datasets and data augmentation

  • Split the data set into training and test sets
  • Use data augmentation for training data including:
    • Randomly adding a fixed number of car and truck class objects to every point cloud
    • Flipping, scaling, rotation, and translation of point cloud

Step 3

Define Networks

Understand the definition of anchor boxes, pillars for the PointPillars network, and PointPillars network.


What you learned: To define a PointPillars network for object detection

  • Define anchor boxes
  • Define pillars for the PointPillars network
  • Define PointPillar network

Step 4

Train Network​​​s

Train the model on the PointPillar network or use a pretrained model.


What you learned: To train PointPillars object detector

  • Specify training options
  • Use trainPointPillarsObjectDetector function to train PointPillars
  • Alternatively, load a pretrained model

Step 5

Generate Detections

Use the trained network to detect objects in the test data and display the point cloud with bounding boxes.


What you learned: To test PointPillars network on test dataset

  • Read the point cloud from the test data
  • Run the detector on the test point cloud to get the predicted bounding boxes and confidence scores
  • Display detected output point cloud with bounding boxes