pcl::IterativeClosestPoint<PointT, PointT> icp; icp.setInputSource(source_cloud); icp.setInputTarget(target_cloud); icp.setMaxCorrespondenceDistance(0.05); pcl::registration::CorrespondenceRejectorSampleConsensus<PointT>::Ptr ransac(new pcl::registration::CorrespondenceRejectorSampleConsensus<PointT>()); ransac->setInputSource(source_cloud); ransac->setInputTarget(target_cloud); ransac->setInlierThreshold(0.05); ransac->setMaximumIterations(1000); ransac->setInputCorrespondences(correspondences); pcl::CorrespondencesPtr correspondences_filtered(new pcl::Correspondences); ransac->getCorrespondences(*correspondences_filtered); PointCloudT::Ptr aligned_cloud(new PointCloudT); icp.setInputCorrespondences(correspondences_filtered); icp.align(*aligned_cloud);如何修改
时间: 2024-02-13 19:01:36 浏览: 145
1 cloud_viewer.rar_PCL1.8_cloud_pcl1.8.1_pointcloud_下载Cloud_View
5星 · 资源好评率100%
这段代码的问题在于,它将pcl::CorrespondencesPtr类型的指针correspondences_filtered作为参数传递给了icp.setInputCorrespondences()函数。实际上,pcl::IterativeClosestPoint<PointT, PointT>类中也没有定义setInputCorrespondences()函数。正确的做法是将pcl::Correspondences类型的对象correspondences_filtered作为参数传递给pcl::IterativeClosestPoint<PointT, PointT>类的align()函数,从而进行点云配准。修改后的代码如下:
```
pcl::IterativeClosestPoint<PointT, PointT> icp;
icp.setInputSource(source_cloud);
icp.setInputTarget(target_cloud);
icp.setMaxCorrespondenceDistance(0.05);
pcl::registration::CorrespondenceRejectorSampleConsensus<PointT>::Ptr ransac(new pcl::registration::CorrespondenceRejectorSampleConsensus<PointT>());
ransac->setInputSource(source_cloud);
ransac->setInputTarget(target_cloud);
ransac->setInlierThreshold(0.05);
ransac->setMaximumIterations(1000);
ransac->setInputCorrespondences(correspondences);
pcl::CorrespondencesPtr correspondences_filtered(new pcl::Correspondences);
ransac->getCorrespondences(*correspondences_filtered);
PointCloudT::Ptr aligned_cloud(new PointCloudT);
icp.align(*aligned_cloud, correspondences_filtered);
```
注意,这里通过icp.align()函数将点对应关系传递给ICP算法,从而进行点云配准。
阅读全文