Search code examples
point-cloud-librarypoint-cloudsopen3d

How do I downsample a point cloud to have a specific number of points so I can feed new data to a model based on PointNet?


I want to make my own dataset so I can use it for training and testing purposes. The problem is that I can handpick the points for training and testing to be a certain number of points (4096 in my case) but for new data it is not possible as I want to go for a real-time scenario and handpicking points is not an option.

Every time, the number of points that I get as new data is different. Sometimes the points are around 100k, other times it's ~200k. Is there a way I can downsample the point cloud to a specific number of points?

I am working with Open3D, but I cannot find any method which can help me with this. Any kind of help would be appreciated.


Solution

  • I think that farthest_point_down_sample is what you're looking for.

    farthest_point_down_sample(self: open3d.cpu.pybind.geometry.PointCloud, num_samples: int) → open3d.cpu.pybind.geometry.PointCloud

    Downsamples input pointcloud into output pointcloud with a set of points has farthest distance. The sample is performed by selecting the farthest point from previous selected points iteratively.

    Unlike other options, it allows you to set the exact number of points you want. Worth noting that this selection strategy should give good results considering how sparse your sampling is (~2% based on your example).