I am using PCL to calculate the normal of point clouds. With Meshlab, normals are as the right one, although all normals are from outer to inner, it will be correct after I reverse them all.
But when I use PCL to do this, the direction of some normals are wrong as the left picture illustrates.
To make more sense, Below are reconstructed surfaces using meshlab and PCL, with the normal estimated by PCL, I cannot get the correct result.
My code are as follow and my sample .ply data is here, and my model could be found here, I have tried to change radius, number of neighbor and the centroid position, but coundn't fix this.
cout << "begin normal estimation" << endl;
NormalEstimationOMP<PointXYZ, Normal> ne;
pcl::search::KdTree<pcl::PointXYZ>::Ptr tree(new pcl::search::KdTree<pcl::PointXYZ>());
ne.setSearchMethod(tree);
ne.setNumberOfThreads(8);
ne.setInputCloud(filtered);
ne.setKSearch(15);
ne.setRadiusSearch(5);
Eigen::Vector4f centroid;
compute3DCentroid(*filtered, centroid);
ne.setViewPoint(centroid[0], centroid[1], centroid[2]);
PointCloud<Normal>::Ptr cloud_normals (new PointCloud<Normal>());
ne.compute(*cloud_normals);
cout << "normal estimation complete" << endl;
Maybe I should adjust some other parameters? Or switch to a better methods? Thank you for your attention!