ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange

# Question about Surface Normal Calculation

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 close merge delete

Sort by » oldest newest most voted

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

more