don't filter point cloud when estimating normals to avoid mismatch of number of points and normals

This commit is contained in:
wmayer
2017-08-24 13:05:21 +02:00
parent 5996ebcf61
commit 7321fa6b7e
2 changed files with 20 additions and 2 deletions

View File

@@ -114,7 +114,22 @@ public:
"filterVoxelGrid(dim)."
);
add_keyword_method("normalEstimation",&Module::normalEstimation,
"normalEstimation(Points)."
"normalEstimation(Points,[KSearch=0, SearchRadius=0]) -> Normals\n"
"KSearch is an int and used to search the k-nearest neighbours in\n"
"the k-d tree. Alternatively, SearchRadius (a float) can be used\n"
"as spatial distance to determine the neighbours of a point\n"
"Example:\n"
"\n"
"import ReverseEngineering as Reen\n"
"pts=App.ActiveDocument.ActiveObject.Points\n"
"nor=Reen.normalEstimation(pts,KSearch=5)\n"
"\n"
"f=App.ActiveDocument.addObject('Points::FeaturePython','Normals')\n"
"f.addProperty('Points::PropertyNormalList','Normal')\n"
"f.Points=pts\n"
"f.Normal=nor\n"
"f.ViewObject.Proxy=0\n"
"f.ViewObject.DisplayMode=1\n"
);
#endif
#if defined(HAVE_PCL_SEGMENTATION)

View File

@@ -179,6 +179,7 @@ void NormalEstimation::perform(std::vector<Base::Vector3d>& normals)
cloud->width = int (cloud->points.size ());
cloud->height = 1;
#if 0
// Build a passthrough filter to remove spurious NaNs
pcl::PointCloud<PointXYZ>::Ptr cloud_filtered (new pcl::PointCloud<PointXYZ>);
pcl::PassThrough<PointXYZ> pass;
@@ -186,13 +187,15 @@ void NormalEstimation::perform(std::vector<Base::Vector3d>& normals)
pass.setFilterFieldName ("z");
pass.setFilterLimits (0, 1.5);
pass.filter (*cloud_filtered);
#endif
// Estimate point normals
pcl::PointCloud<pcl::Normal>::Ptr cloud_normals (new pcl::PointCloud<pcl::Normal>);
pcl::search::KdTree<PointXYZ>::Ptr tree (new pcl::search::KdTree<PointXYZ> ());
pcl::NormalEstimation<PointXYZ, pcl::Normal> ne;
ne.setSearchMethod (tree);
ne.setInputCloud (cloud_filtered);
//ne.setInputCloud (cloud_filtered);
ne.setInputCloud (cloud);
if (kSearch > 0)
ne.setKSearch (kSearch);
if (searchRadius > 0)