int main (int, char** argv) { std::string filename = argv[1]; std::cout << "Reading " << filename << std::endl; pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>); if (pcl::io::loadPCDFile<pcl::PointXYZ> (filename, *cloud) == -1) //* load the file { PCL_ERROR ("Couldn't read file"); return (-1); } std::cout << "Loaded " << cloud->points.size () << " points." << std::endl; // Compute the normals pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> normal_estimation; normal_estimation.setInputCloud (cloud); pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ>); normal_estimation.setSearchMethod (tree); pcl::PointCloud<pcl::Normal>::Ptr cloud_with_normals (new pcl::PointCloud<pcl::Normal>); normal_estimation.setRadiusSearch (0.03); normal_estimation.compute (*cloud_with_normals); // Setup the feature computation pcl::PFHEstimation<pcl::PointXYZ, pcl::Normal, pcl::PFHSignature125> pfh_estimation; // Provide the original point cloud (without normals) pfh_estimation.setInputCloud (cloud); // Provide the point cloud with normals pfh_estimation.setInputNormals (cloud_with_normals); // pfh_estimation.setInputWithNormals (cloud, cloud_with_normals); PFHEstimation does not have this function // Use the same KdTree from the normal estimation pfh_estimation.setSearchMethod (tree); pcl::PointCloud<pcl::PFHSignature125>::Ptr pfh_features (new pcl::PointCloud<pcl::PFHSignature125>); pfh_estimation.setRadiusSearch (0.2); // Actually compute the spin images pfh_estimation.compute (*pfh_features); std::cout << "output points.size (): " << pfh_features->points.size () << std::endl; // Display and retrieve the shape context descriptor vector for the 0th point. pcl::PFHSignature125 descriptor = pfh_features->points[0]; std::cout << descriptor << std::endl; return 0; }
void Get_ToTal_FPFH(const char *path_pcd,float normal_search_radius, float fpfh_search_radius, float a[33]) { std::string fileName = path_pcd; // std::cout << "Reading " << fileName << std::endl; pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>); if (pcl::io::loadPCDFile<pcl::PointXYZ> (fileName, *cloud) == -1) // load the file { PCL_ERROR ("Couldn't read file"); exit(0); } // std::cout << "Loaded " << cloud->points.size () << " points." << std::endl; // Compute the normals pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> normal_estimation; normal_estimation.setInputCloud (cloud); pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ>); normal_estimation.setSearchMethod (tree); pcl::PointCloud<pcl::Normal>::Ptr cloud_with_normals (new pcl::PointCloud<pcl::Normal>); normal_estimation.setRadiusSearch (0.05); normal_estimation.compute (*cloud_with_normals); // Setup the feature computation pcl::FPFHEstimation<pcl::PointXYZ, pcl::Normal, pcl::FPFHSignature33> fpfh_estimation; // Provide the original point cloud (without normals) fpfh_estimation.setInputCloud (cloud); // Provide the point cloud with normals fpfh_estimation.setInputNormals (cloud_with_normals); // fpfhEstimation.setInputWithNormals(cloud, cloudWithNormals); PFHEstimation does not have this function // Use the same KdTree from the normal estimation fpfh_estimation.setSearchMethod (tree); pcl::PointCloud<pcl::FPFHSignature33>::Ptr pfh_features (new pcl::PointCloud<pcl::FPFHSignature33>); fpfh_estimation.setRadiusSearch (0.25); // Actually compute the spin images fpfh_estimation.compute (*pfh_features); // std::cout << "output points.size (): " << pfh_features->points.size () << std::endl; // float a[33] = {0.0f}; // Display and retrieve the shape context descriptor vector for the 0th point. for (std::size_t i = 0; i < pfh_features->points.size(); i++) { pcl::FPFHSignature33 descriptor = pfh_features->points[i]; for (int j = 0; j < 33; j++) a[j] = descriptor.histogram[j]; } }