PCL对应点对可视化:
要想显示点对之间的对应关系, 首先必须计算出对应点对, pcl中对应点对的计算可通过pcl::registration::CorrespondenceEstimation<pcl::PointT,pcl::PointT> correspond_est;
计算,计算出对应点对后, source 和 target对应点的索引会存储在vector<int> A
或pcl::Correspondences A
中.要想显示点对的对应关系,只需 view->addCorrespondences<pcl::PointXYZ>(source,target,A,"correspond",v1);
其中,pcl::PointXYZ
表示所添加对应点对的类型为PointXYZ
类型的,参数中的前两个表示目标点云和源点云,A
存储从目标点云到源点云的对应点的索引,”correspond“依然是自定义的标签,v1表示添加到哪个窗口.
为了使得对应点更加个性化,我们可以对它进行一下”定制“:
-
view->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_LINE_WIDTH,2,"correspond"); //设置对应点连线的粗细.PCL_VISUALIZER_LINE_WIDTH,表示
线
操作,线段的宽度为2(提醒一下自己: 线段的宽度最好不要超过自定义的点的大小),"correspond"表示对 对应的标签 做处理. -
view->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_COLOR,0,0,1,"correspond"); //设置对应点连线的颜色,范围从0-1之间。
pcl::registration::CorrespondenceEstimation<pcl::FPFHSignature33,pcl::FPFHSignature33> crude_cor_est;
boost::shared_ptr<pcl::Correspondences> cru_correspondences (new pcl::Correspondences);
crude_cor_est.setInputSource(source_fpfh);
crude_cor_est.setInputTarget(target_fpfh);
// crude_cor_est.determineCorrespondences(cru_correspondences);
crude_cor_est.determineReciprocalCorrespondences(*cru_correspondences);
cout<<"crude size is:"<<cru_correspondences->size()<<endl;
文章参考地址:
点击打开链接