Problem with Normal estimation in point clouds

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with Normal estimation in point clouds

chris_chris
This post was updated on .
Hello everybody,

I have a pointcloud from a file (pointXYZ from a .txt file). I have to estimate normal for this. I made all pointXYZ from the file as a single point cloud.  Then I tried to estimate the normals using the tutorial in the link: http://www.pointclouds.org/documentation/tutorials/normal_estimation.php

I made the following code (from the above link) as a function with my pointcloud as input to get the normal pointclouds.
{
  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);

  ... read, pass in or create a point cloud ...

  // Create the normal estimation class, and pass the input dataset to it
  pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> ne;
  ne.setInputCloud (cloud);

  // Create an empty kdtree representation, and pass it to the normal estimation object.
  // Its content will be filled inside the object, based on the given input dataset (as no other search surface is given).
  pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ> ());
  ne.setSearchMethod (tree);

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

  // Use all neighbors in a sphere of radius 3cm
  ne.setRadiusSearch (0.03);

  // Compute the features
  ne.compute (*cloud_normals);

  // cloud_normals->points.size () should have the same size as the input cloud->points.size ()*
}

The problem is I get same Normal (same Normal_x, Normal_y, Normal_z) for all PointCloud. I think I have did some mistake.
Does anyone have idea about what is the problem?
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Normal estimation in point clouds

Nathan_
Hi,

Are you sure that your point cloud is correctly created ? Can you save it in a pcd file and open it to check the points coordinates ?
If points coordinates are correct, increase or decrease the radius search of the normals estimation according to your point cloud resolution.

Hope that'll help you :)
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Normal estimation in point clouds

chris_chris
@nathan - The point cloud is correctly created and I can write it to a file and also read it. I also tried in changing the radius. Still the result is same.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Normal estimation in point clouds

Nathan_
This post was updated on .
Did you try using setKSearch instead of setRadiusSearch ? To be sure that the problem doesn't come from the radius search size.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Normal estimation in point clouds

chris_chris
I didn't change any thing in the above code. What should I use setKSearch or setRadiusSearch?
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Normal estimation in point clouds

Nathan_
Try with setKSearch to be sure that the radius search is not the cause of your issue.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Normal estimation in point clouds

star
In reply to this post by chris_chris
Hi~

Use the blow lines

 // Use all neighbors in a sphere of radius 3cm
 // ne.setRadiusSearch (0.03);
// Use 4 nearest neighbors
ne.setKSearch(4);

Cheers
Star.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Normal estimation in point clouds

chris_chris
This post was updated on .
Hi,

While trying to view the output of the normals with setRadiusSearch, it seems like tangent. When using something with setKSearch, I can see some vectors perpendicular to the surface (looking like a perfect normals). My input point clouds is almost like a plane. But I can see normals in both the directions of the plane.

Still I cannot understand the difference between the setRadiusSearch and setKSearch
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Normal estimation in point clouds

aichim
Administrator
Hi,

It all depends on how many points you are using to estimate the normal. It might be the case that the radius search returns a completely different neighborhood size than your k search. And obviously, different neighborhoods => different normals.

You can verify this by using a separate kdtree and checking how many points you get with certain radii.

Cheers,
Alex
---
http://www.openperception.org



On Feb 27, 2013, at 7:21 AM, chris_chris <[hidden email]> wrote:

> Hi,
>
> While trying to view the output of the normals with setRadiusSearch, it
> seems like tangent. When using something with setKSearch, I can see some
> vectors perpendicular to the surface (looking like a perfect normals).
>
> But, Why is this difference?
>
>
>
> --
> View this message in context: http://www.pcl-users.org/Problem-with-Normal-estimation-in-point-clouds-tp4026387p4026420.html
> Sent from the Point Cloud Library (PCL) Users mailing list mailing list archive at Nabble.com.
> _______________________________________________
> [hidden email] / http://pointclouds.org
> http://pointclouds.org/mailman/listinfo/pcl-users

_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Normal estimation in point clouds

chris_chris
This post was updated on .
Thanks everyone, I got it now.