I have a list of preconceived survey points I need to go through and get their K nearest neighbours and/or neighbours within a given radius in a point cloud. I was trying the following code:
pc = pclpy.read("my_point_cloud.las", point_type="PointXYZ")
To me, everything seems to be like interpreted from PCL tutorials, and no errors are raised with this. The problem is, no matter what xyz values I give for the query point p, the K-nn search gives always the same indices, which correspond to the lowest points in the data set, i.e. closest to origin. Is there something wrong in the way I define the query point?
Radius search returns nothing, but raises no error either. The problem there seems to be with the query point, too, because when I increased the search radius enough, it started finding the lowest points.
Hi,
I have a list of preconceived survey points I need to go through and get their K nearest neighbours and/or neighbours within a given radius in a point cloud. I was trying the following code:
pc = pclpy.read("my_point_cloud.las", point_type="PointXYZ")
octree_search = pcl.octree.OctreePointCloudSearch.PointXYZ(0.01) octree_search.setInputCloud(pc) octree_search.addPointsFromInputCloud()
survey_points = [i.split() for i in open("my_file.txt")]
for i in survey_points: x,y,z = i p = pcl.point_types.PointXYZ p.x = float(x) p.y = float(y) p.z = float(z) p_ind = pcl.vectors.Int() p_dist = pcl.vectors.Float() octree_search.nearestKSearch(p(), 100, p_ind, p_dist)
or:
To me, everything seems to be like interpreted from PCL tutorials, and no errors are raised with this. The problem is, no matter what xyz values I give for the query point p, the K-nn search gives always the same indices, which correspond to the lowest points in the data set, i.e. closest to origin. Is there something wrong in the way I define the query point? Radius search returns nothing, but raises no error either. The problem there seems to be with the query point, too, because when I increased the search radius enough, it started finding the lowest points.
The survey_points look like this: [['-3.2108', '-0.048323', '255.47'], ['-3.2109', '-0.066852', '255.27'], ['-3.219', '-0.095729', '255.07'], ['-3.2047', '-0.080146', '254.89'], ['-3.2081', '-0.094139', '254.69'], ...
And pc.xyz like this: array([[-5.291900e+00, -2.289000e-01, 2.582123e+02], [-5.291400e+00, -2.307000e-01, 2.582149e+02], [-5.291700e+00, -2.324000e-01, 2.582130e+02], ..., [-2.979500e+00, -5.420000e-02, 2.409765e+02], [-2.877800e+00, -4.320000e-02, 2.409444e+02], [-3.032600e+00, -5.940000e-02, 2.409108e+02]], dtype=float32)
Thanks!