Ask Your Question
1

Question about Surface Normal Calculation

asked 2013-05-04 02:32:53 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

I am new in PCL framework. I want to know how PCL calculate surface normal. I used only three points to calculate surface normal, but failed to estimate surface normal. I collected the code from the link http://www.pointclouds.org/documentation/tutorials/normal_estimation.php#normal-estimation. I modied little. According to my understanding about surface normal, it should provide some value. Unfornately, it provided garbage value (-1.#ND). Here is my sample code and input file. Thanx in advance.

Input: 1 1 1 
         2 2 2 
         3 3 3 

Output: -1.#ND -1.#ND -1.#ND 
           -1.#ND -1.#ND -1.#ND 
           -1.#ND -1.#ND -1.#ND

Code:

int main(..) 
{ 
pcl::PointCloud<pcl::PointXYZ> cloud; 

  cloud.width    = 3; 
  cloud.height   = 1; 
  cloud.is_dense = false; 
  cloud.points.resize (cloud.width * cloud.height); 

  int x_i=1,y_i=1,z_i=1; 
  for (size_t i = 0; i < cloud.points.size (); ++i) 
  { 

    cloud.points[i].x = x_i; 
    cloud.points[i].y = y_i; 
    cloud.points[i].z = z_i; 
        x_i++; 
        y_i++; 
        z_i++; 

  } 

pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> ne; 
ne.setInputCloud (cloud.makeShared()); 
pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ> ()); 
ne.setSearchMethod (tree); 
pcl::PointCloud<pcl::Normal>::Ptr cloud_normals (new pcl::PointCloud<pcl::Normal>); 
int k=3; 
ne.setKSearch (k); 
ne.compute (*cloud_normals); 
std::cerr << "Normal cloud size " << cloud_normals->points.size()<< std::endl; 

for (size_t i = 0; i < cloud_normals->points.size(); ++i) 
        std::cerr << "    " << cloud_normals->points[i].normal_x << " " << cloud_normals->points[i].normal_y << " " << cloud_normals->points[i].normal_z << std::endl; 

}
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2013-05-05 23:21:55 -0500

If you don't get an answer here, try the PCL IRC chat or mailing list, the PCL people usually hang out there.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-05-04 02:32:53 -0500

Seen: 742 times

Last updated: May 04 '13