Compute distances of points relatively to reference point cloud
Asked Answered
C

2

6

A point-cloud to point-cloud distance can be simply computed using the nearest neighbor distance. The issue is that the nearest neighbour is not necessarily the actual nearest point on the surface represented by the cloud. Especially in our case: the reference cloud has a low density. In this case, an interpolation technique was used (pseudo code):

from scipy import interpolate
import numpy as np

ref_point_cloud = np.load("ref_point_cloud.npy").item() # Grid
f = interpolate.interp2d(ref_point_cloud['x'], ref_point_cloud['y'], ref_point_cloud['z'], kind='linear', copy=False, bounds_error=True)

#### Read dense point cloud (point_cloud_dense) code here ####

for point in point_cloud_dense:
    distance = abs(f(point(x), point(y)) - ref_point_cloud['z'])

The interpolation seems a time consuming technique, but it works. Is there a more time efficient technique to compute the distances of the points relatively to the reference point cloud?

Final goal: Remove ground points from a dense MLS point cloud, using a reference point cloud with only ground level points. A distance threshold will decide if a point belongs to the ground surface.

Refs: https://www.cloudcompare.org/doc/wiki/index.php?title=Cloud-to-Cloud_Distance https://pointclouds.org/documentation/tutorials/kdtree_search.html

enter image description here

Connelley answered 19/4, 2021 at 19:4 Comment(0)
M
0

You could get the k nearest neighbors, fit a plane on them and calculate the point to plane distance.

Messer answered 26/4, 2021 at 7:15 Comment(0)
K
0

I think that you have the right approach, but you need to vectorize your usage of interpolate.interp2d. So assuming point_cloud_dense is of type pcl.PointCloud.PointXYZ:

distances = abs(f(point_cloud_dense.x, point_cloud_dense.y) - ref_point_cloud['z'])

Note: point_cloud_dense.x / point_cloud_dense.y return a 1D numpy array.

Kremer answered 18/4, 2022 at 11:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.