icp点云匹配,及相关点云文件。vs2013

  • 虫虫123456
    了解作者
  • matlab
    开发工具
  • 41.7MB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 5 积分
    下载积分
  • 0
    下载次数
  • 2022-07-19 22:34
    上传日期
icp点云匹配,及相关点云文件。vs2013
icp.rar
内容介绍
#include"function.h" #include<pcl/registration/icp.h> int main(){ string model_filename = "model.obj"; string model_hole_filename = "model_hole3.obj"; // Load the input file pcl::PointCloud<PointT> cloud = obj2cloud(model_filename); pcl::PointCloud<PointT> cloud_hole = obj2cloud(model_hole_filename); //icp实现 pcl::PointCloud<PointT>::Ptr cloud_pr(new pcl::PointCloud<PointT>); *cloud_pr = cloud; pcl::PointCloud<PointT>::Ptr cloud_hole_pr(new pcl::PointCloud<PointT>); *cloud_hole_pr = cloud_hole; pcl::IterativeClosestPoint<PointT, PointT> icp; icp.setInputSource(cloud_pr); //原点云 icp.setInputTarget(cloud_hole_pr);//目标点云 pcl::PointCloud<PointT> final_cloud;//配准后点云 //icp 参数设置 icp.setMaximumIterations(1000); //最大迭代次数,几十上百都可能出现。 icp.setEuclideanFitnessEpsilon(0.5);//前后两次迭代误差的差值,这个值一般设为1e-6或者更小. icp.setTransformationEpsilon(1e-10); //上次转换与当前转换的差值; icp.setMaxCorrespondenceDistance(0.7); //忽略在此距离之外的点,如果两个点云距离较大,这个值要设的大一些(PCL默认距离单位是m),对配准影响较大 //保存配准后的点 icp.align(final_cloud); //icp匹配后的转换矩阵及得分 cout << "has converged: " << icp.hasConverged() << endl << "score: " << icp.getFitnessScore() << endl; cout << icp.getFinalTransformation() << endl; //向点云里添加颜色信息,方便查看 for (size_t i = 0; i < cloud.size(); ++i){ cloud.points[i].rgb = 2.3418052e-038; //红 } for (size_t i = 0; i < cloud_hole.size(); ++i){ cloud_hole.points[i].rgb =3.5733111e-043 ;//绿 } for (size_t i = 0; i < final_cloud.size(); ++i){ final_cloud.points[i].rgb =9.1476764e-041 ;//蓝 //final_cloud.points[i].rgb = 2.3418052e-038; } //show cloud cloud += cloud_hole; cloud += final_cloud; showCloud(cloud, "匹配效果"); cout << "ICP 算法执行完成" << endl; system("pause"); return (0); }
评论
    相关推荐