Normals calculation fails

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Normals calculation fails

This post was updated on .
Hi all!
First of all, I wish you a good 2017, and only luck and positive for this new year! ;)

My problem concern the normals calculation from a point Cloud.
I'm using :
        pcl::NormalEstimationOMP<pcl::PointXYZ, pcl::Normal> neOMP(8);
        pcl::search::KdTree<pcl::PointXYZ>::Ptr tree(new pcl::search::KdTree<pcl::PointXYZ>());

        pcl::PointCloud<pcl::Normal>::Ptr cloud_normals(new pcl::PointCloud<pcl::Normal>);


        return cloud_normals;

as used on the documentation.
I'm using it on a Pointcloud found by a RANSAC SampleConsensusModel (in order to make a plane PointCloud):       
        pcl::PointCloud<pcl::PointXYZ>::Ptr finale(new pcl::PointCloud<pcl::PointXYZ>);

        std::vector<int> inliers;
        model_p(new pcl::SampleConsensusModelPlane<pcl::PointXYZ>(nearests_));
        pcl::RandomSampleConsensus<pcl::PointXYZ> ransac(model_p);
        pcl::copyPointCloud<pcl::PointXYZ>(*nearests_, inliers, *finale);
        pcl::PointCloud<pcl::Normal>::Ptr cloud_normals(new pcl::PointCloud<pcl::Normal>);
        cloud_normals = find_normals(finale, 0.1);

But the result is :

Can it be a problem with the algorithm.
Since I only have to find the normal of the plane created with RANSAC, I was going to implement an algorithm of plane-fitting. Do you know one that is good? PCA? But in what I know, Finding normal is based on PCA algorithm no? So if there is errors here, maybe another could be good?

I'm about to use what I found here since it seem to be working, and "fast" enough. Do you think it's a good idea?