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

Normal calculation and comparation of points, how to perform this?

asked 2016-01-15 12:11:44 -0500

Nxzx gravatar image

I have a problem do you know how to estimate a normal for a single point using the function:

computePointNormal (const pcl::PointCloud<pointint> &cloud, const std::vector<int> &indices, Eigen::Vector4f &plane_parameters, float &curvature);

How can I fill the indices?

After the normal calculation how can I compare two normals of different points and check if their pointing directions?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
3

answered 2016-01-16 04:03:46 -0500

Akif gravatar image

updated 2016-01-20 12:57:21 -0500

This is more like a PCL question. Though I can give some insight.

As it is told in pcl tutorial Normal Estimation,

To compute a single point normal, use:

computePointNormal (const pcl::PointCloud<PointInT> &cloud, const std::vector<int> &indices, Eigen::Vector4f &plane_parameters, float &curvature);

Where cloud is the input point cloud that contains the points, indices represents the set of k-nearest neighbors from cloud, and plane_parameters and curvature represent the output of the normal estimation, with plane_parameters holding the normal (nx, ny, nz) on the first 3 coordinates, and the fourth coordinate is D = nc . p_plane (centroid here) + p.

To be able to estimate a normal for a single point you need to use neighbouring points to estimate a surface. Without those you can not have a normal for a point. For those neighbouring points you should use a method like kNN. In PCL we have kNN implementation with KdTree Class.

Depending on your application you can use KdTree to gather k-nearest neighbour points to your target point for normal estimation. Then, you should supply indices of those points to computePointNormal method. For usage of KdTree, you can check this tutorial.

Hope this helps. For further questions you can visit pcl-users.org.

Update

About your code in your answer, computePointNormal waits const pcl::PointCloud<PointInT> &cloud as first argument, but you are passing point cloud pointer. Possibly it will be fine if you change it to this (Note the * );

computePointNormal(*filteredCloud1,pointIdxRadiusSearch,plane_parameters,curvature);
edit flag offensive delete link more

Comments

Thank you! It is working now!

Nxzx gravatar image Nxzx  ( 2016-01-21 03:08:07 -0500 )edit

Glad you made it! Then you can mark this answer as accepted so that future users will use the same solution with you.

Akif gravatar image Akif  ( 2016-01-21 03:31:58 -0500 )edit

Sir, do you mind taking a look at this post? Thank you. https://answers.ros.org/question/3000...

thompson104 gravatar image thompson104  ( 2018-08-08 16:30:46 -0500 )edit
0

answered 2016-01-20 11:48:48 -0500

Nxzx gravatar image

updated 2016-01-20 11:50:56 -0500

Thanks for your reply, I tried to solve the problem using the following approach, but, my code didn't work as expected, could you help me?

for (size_t i = 0; i < filteredCloud1->points.size(); i++) 
  {
     //Radial search for estimating neighborhood indices 
     pcl::KdTreeFLANN<PointT> kdtree; 
     kdtree.setInputCloud (filteredCloud1); 
     pcl::PointXYZRGBA searchPoint = filteredCloud1->points[i]; 
     float radius = 0.03; 
     std::vector<int> pointIdxRadiusSearch; 
     std::vector<float> pointRadiusSquaredDistance; 
     kdtree.radiusSearch (searchPoint, radius, pointIdxRadiusSearch, pointRadiusSquaredDistance); 

 //Compute normal of a single point 
     float curvature; 
     Eigen::Vector4f plane_parameters; 
     computePointNormal(filteredCloud1,pointIdxRadiusSearch,plane_parameters,curvature); 


  }

I keep getting the following error: http://imgur.com/fO5CQKN

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-01-15 12:11:44 -0500

Seen: 2,480 times

Last updated: Jan 20 '16