Skip to content

[feat] Improve clustering for motion detector

Tong Fu requested to merge feat/ImproveClusteringForMotionDetector into master

Goal

The goal of this MR is to improve the run time of the motion detector to ensure a real time usage (100ms/frame). Previously, copy lidar information such as "intensity", "distance_m" took a lot of time. In addition, if there are some objects near to the lidar, the points are dense.

Change

Now the filter has 3 outputs:

  • Motion detection: pointcloud of motion points (outliers are removed). They will be labelled by cluster id if extraction cluster is enabled
  • Clusters: Bounding box of clusters if extract clusters
  • Clusters information: display text in the render view

To improve runtime:

  • The process to filter outliers of motion point is done in the function of EstimateMotion.
  • If subsampling is required, the motion points near to lidar (controled by SubsampleRange) are subsampled.

Clustering and tracking:

  • A Gaussian Mixture model based clustering method is added, it can do a simple tracking job.
    • A new vtk internal class is created for this gmm model, which is a little bit different from gmm for motion estimation.

Bounding box orientation

PCA computation is added to correct the bounding box size and orientation in the clustering step.

Comprison runtime

livox-hap Before After
estimation motion 40ms 45ms
extract cluster with euclidean 49ms 3.0ms
extract cluster with GMM - 0.57ms

Previously, motion detector contains 2 steps: estimation motion and cluster extraction with euclidean distance. The total average execution time is 89ms. Some frames take 100 - 200ms for cluster extraction.

With the improvement of this MR, there are two choices for clustering: the old one (clustering with euclidean) and a new one, clustering with GMM which can also do a first tracking. The total average runtime with clustering euclidean is 48ms, The total average runtime with clustering GMM is 45.57ms.

The cluster extraction has gained 16 times (with old method), 85 times with GMM clustering method.

After adding pca for bounding box orientation and some refacts of motion estimation and clustering

livox-hap
estimation motion 37.6ms
extract cluster with euclidean 4.0ms
extract cluster with GMM 1.55ms

Result

Video

parameters used for this demo:

Screenshot_from_2024-06-23_18-18-02

ToDo

  • To debug: When I apply motion detector filter and play pcap with x1, the NbProcessedFrames (which is log info of motion detector) is greater than the number of frame played. (FYI @timothee.couble )
  • To improve more runtime, use vtkSMPTools to parallise vtk filter function.
  • To detail the documentation of interface
  • The distribution of cluster id could be improved to avoid too large cluster id. It could also resolve the problem of colormap display which can not be automatically adapted. (See in this version GetAvailableId())
Edited by Tong Fu

Merge request reports