0
$\begingroup$

Rosanswers logo

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; 

}

Originally posted by Nihad on ROS Answers with karma: 22 on 2013-05-04

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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


Originally posted by Martin Günther with karma: 11816 on 2013-05-05

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.