Reputation: 147
I am trying to merge point clouds from two frames into one bigger point cloud. I will use ICP for that but I understand I need to per-align the point clouds. I am trying to do it with PCL template_alignment
code from:
https://pcl.readthedocs.io/projects/tutorials/en/latest/template_alignment.html#template-alignment
The program computes surface normals after loading pointcloud
. It works fine for the sample data used in the code but for my own data the "norm_est.compute(*normals_)
" statement on line 89 returns NaN
values. I read on PCL library documention that if the function can't find the neighbouring points it will return NaN values. That is my question, why the program is unable to find neighbourung points and what do I do about it? I am using the same settings as in the code in the above link for radius search and other perimeters for normal estimation.My left Image and point cloud are given below. I have uploaded a coloured pointcloud for better visualization but for alignment purposes I am using point cloud without RGB and my pointcloud.ply
file contains only xyz coordinates.
Upvotes: 3
Views: 2941
Reputation: 1671
Simple fix: modify that line (89) as such Old:
norm_est.setRadiusSearch (normal_radius_);
new:
norm_est.setKSearch(5);
What this does is instead of looking inside a particular size sphere (unknown number of entries) it looks for a specific number of nearest neighbors.
Note that 5 is a pretty arbitrary number. You could go faster by lowering to 3 (minimum required) or slower but more accurate by increasing that number. It is probably best to not actually drop a hardcoded value right there and as such I suggest you pipe it out similar to how normal_radius_ was before, but this should get you past this issue for now.
Other options:
1: remove nan from point cloud after calculating normals (pcl::removeNaNFromPointCloud)
2: Run a reprocess step where you do a statistical outlier removal filter. Or an outright minimum neighbor radius filter. This will remove points with too few neighbors (which are what is generating nan values in your normal calculation)
3: increase radius of normal calculation or perform a nearest neighbor (not radius based) normal calculation.
Upvotes: 5