Unsupervised Machine Learning: LiDAR Point Cloud Segmentation and Clustering

Next, we will use unsupervised machine learning techniques to detect LiDAR objects in 3D.

First, we will use an outlier detection algorithm to segment the driveable area in 3d, and second, we will use a clustering algorithm to detect individual obstacles.

Driveable Area Segmentation in 3D

First, we perform driveable area segmentation in 3D. In other words, we process the point cloud to separate the ground from the obstacles, such as vehicles, bicycles, and pedestrians.

Driveable area segmentation can be done with an algorithm called RANSAC, which stands for RANdom SAmple Consensus. This algorithm is used to detect outliers and can be done in 2D or 3D, depending on the use case.

In our case, we define the ground points as inliers and the points related to obstacles as outliers.

We calculate the distance D between the points and an infinite plane X, Y, Z called a threshold. If D < threshold, the points are called inliers, else the points are outliers.

The figure above illustrates that points within a certain distance from the plane X, Y, Z (in green) will be labeled as inliers while the points beyond the distance threshold are labeled as outliers (in red).

RANSAC is a three steps process as follow:

1. Take 3 points at random
2. Fit a plane in the image
3. Calculate the distance between the plane and the points.

However, because we might initially choose the wrong points, we need to loop through the process until we find the optimum value.

The right plan will fit the most significant number of points.

Looking at the point cloud visualization, we can see that the ground has the most significant number of points. This is why we consider the ground points as inliers.

For this algorithm, we need to tune the number of iterations and the distance threshold.

# RANSAC Hyperparameters
# distance_threshold = 0.3
# ransac_n = 3
# number_iterations = 150
Output:
time to segment points using RANSAC 0.02643299102783203

Next, we detect individual obstacles through clustering.

LiDAR Point Cloud Clustering With DBSCAN

Once the driveable segmentation area is done, we need to detect individual obstacles with a clustering algorithm.

Here, we use a DBSCAN ( Density-Based Spatial Clustering of Applications with Noise) clustering algorithm to build clusters of objects.

Because K-MEANS outputs spheres as clusters, this is not a suitable algorithm for self-driving cars.

In our case, obstacles have arbitrary shapes, making DBSCAN a better choice.

Hyperparameters will be epsilon ε which represents a radius of neighborhood around a point, and n will be a minimum number of points.

This algorithm follows a three-step process as follow:

1. Take a point
2. Find the neighbors within a distance epsilon ε
3. Expand if the number of points is above n to see the neighbors.

The algorithm stops once the distance is too big. This is one cluster, and we repeat the same process to find the next clusters.

# DBSCAN Hyperparameters: eps=0.45, min_points=7Output:
point cloud has 255 clusters
Time to cluster outliers using DBSCAN 0.8933331966400146

LiDAR 3D Object Detection With Bounding boxes

The final step is to add the bounding box surrounding the LiDAR objects. We will take the labels and group them together.

Looping through the indexes and looking at the number of points per cluster, we will have a 3D bounding box.

# Bounding boxes parameters
MIN_POINTS = 20
MAX_POINTS = 300

Bounding boxes will appear around each cluster containing between 20 and 300 points.

AI/ML

Trending AI/ML Article Identified & Digested via Granola by Ramsey Elbasheer; a Machine-Driven RSS Bot