1,normalestimation對點云法線的評估,只輸出法線向量,并不輸出xyz值。
如果輸出類型是pointnormal,那么這點云的法向量有值,xyz值都是0
2,添加點云xyz數據。可以使用? pcl::concatenatefields(*a,*b,*c)函數
pcl::PointCloud<pcl::PointNormal>::Ptr cloud_con(new pcl::PointCloud<pcl::PointNormal>);pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);std::string filename = "D:\\Desktop\\pacl_learning\\cloud\\table_voxel.pcd";pcl::io::loadPCDFile(filename, *cloud);//法線評估pcl::NormalEstimation<pcl::PointXYZ, pcl::PointNormal>::Ptr normal_es(new pcl::NormalEstimation<pcl::PointXYZ, pcl::PointNormal>);normal_es->setInputCloud(cloud);pcl::search::KdTree < pcl::PointXYZ >::Ptr tree(new pcl::search::KdTree < pcl::PointXYZ >);normal_es->setSearchMethod(tree);normal_es->setKSearch(20);normal_es->compute(*cloud_con);cout << cloud_con->points.size() << endl;//不添加這一步的話,所或得的pointnormal類型是沒有xyz數據的,都是0-0-0//也就是說normalestimation對點云法線的評估,只輸出法線向量,并不輸出xyz值。pcl::concatenateFields(*cloud, *cloud_con, *cloud_con);pcl::PointCloud<pcl::PointXYZ>::Ptr aa(new pcl::PointCloud<pcl::PointXYZ>);for (int i=0;i<cloud_con->points.size();i++){pcl::PointXYZ po;po.x = cloud_con->points[i].x;po.y = cloud_con->points[i].y;po.z = cloud_con->points[i].z;cout << po.x << "--" << po.y << "--" << po.z << endl;aa->push_back(po);}