匹配器
2.1 ICP點云精配準
template < typename PointCloudPtr > bool ex_segmentor::icp_registration(PointCloudPtr &input_obj, PointCloudPtr &input_scene, PointCloudPtr &output_obj, Eigen::Matrix4f &result_transform, float &result_error, uint max_iteration, float max_distance, float ransac_th) // icp匹配
{ pcl::IterativeClosestPoint< PointXYZRGB, PointXYZRGB > icp; // icp對象
icp.setInputSource(input_obj); //設置輸入源點云
icp.setInputTarget(input_scene); //設置輸入目標點云 //
Set the max correspondence distance to 5cm (e.g., correspondences with higher distances will be ignored) icp.setMaxCorrespondenceDistance(max_distance); //設置最大匹配距離 0.05 //
Set the maximum number of iterations (criterion 1) icp.setMaximumIterations(max_iteration); //設置最大迭代次數 50 // Set the transformation epsilon (criterion 2) //
icp.setTransformationEpsilon (1e-5); //1e-8 //
Set the euclidean distance difference epsilon (criterion 3) //
icp.setEuclideanFitnessEpsilon (0.000001); //1
icp.setRANSACOutlierRejectionThreshold(ransac_th); //設置RANSAC閾值
icp.align(*output_obj); // icp匹配 if (icp.hasConverged()) //如果icp匹配成功
{ result_transform = icp.getFinalTransformation(); //獲取最終變換矩陣
result_error = icp.getFitnessScore(); //獲取最終匹配誤差
return true; }
else
{ result_transform = Eigen::Matrix4f::Identity(4, 4); result_error = 1.0; return false; } }/** icp_registration(object_aligned, cluster, Final, icp_result_transform, icp_error);**/
2.2 FPFH點云粗配準
void FPFH_generation(pcl::PointCloud<PointXYZRGB>::Ptr &input, FPFHCloud::Ptr &output) // FPFH特征提取 { // 首先,生成法線
pcl::NormalEstimationOMP<PointNormal, PointNormal> nest; // OMP線程數
pcl::PointCloud<PointNormal>::Ptr temp(new pcl::PointCloud<PointNormal>); //構建暫時點云
pcl::copyPointCloud(*input, *temp); //拷貝點云
nest.setRadiusSearch(0.01); //設置半徑搜索范圍
nest.setInputCloud(temp); //設置輸入點云
nest.compute(*temp); //計算暫時點云 // 然后生成FPFH點云 pcl::FPFHEstimationOMP<PointNormal, PointNormal, FPFH> fest; // OMP線程數
fest.setRadiusSearch(0.01); // 0.025
fest.setInputCloud(temp);
fest.setInputNormals(temp); fest.compute(*output); }
template <typename PointType, typename PointCloudPtr> bool
FPFH_matching(PointCloudPtr &object, FPFHCloud::Ptr &object_feature, PointCloudPtr &scene, FPFHCloud::Ptr &scene_feature, PointCloudPtr &result_cloud, Eigen::Matrix4f &result_transformation) // FPFH粗配準方法
{ pcl::SampleConsensusPrerejective<PointType, PointType, FPFH> align; //采樣一致性預排除算法
align.setInputSource(object); //設置輸入源點云
align.setSourceFeatures(object_feature); //設置輸入源特征點云
align.setInputTarget(scene); //設置輸入目標點云
align.setTargetFeatures(scene_feature); //設置輸入目標特征點云
align.setMaximumIterations(5000); // 設置最大迭代次數
align.setNumberOfSamples(7); // 設置采樣點數
align.setCorrespondenceRandomness(10); // 設置隨機匹配點數
align.setSimilarityThreshold(0.5f); // 設置相似度閾值
align.setMaxCorrespondenceDistance(0.01f); // 設置最大匹配距離
align.setInlierFraction(0.05f); // 設置內點比例 align.align(*result_cloud); if (align.hasConverged())
{ result_transformation = align.getFinalTransformation(); //獲取最終變換矩陣 // pcl::console::print_info("Inliers: %i/%i , %in", align.getInliers().size(), scene->size(), object->size()); // return (float(align.getInliers().size()) / float(object->size())); return true; } // return 0.0f; return false; }/**
FPFHCloud::Ptr cluster_feature(new FPFHCloud); FPFH_generation(cluster, cluster_feature);
ROS_INFO("cluster_size : %d, feature size : %d", cluster->size(), cluster_feature->size());
bool FPFH_match_success = FPFH_matching<PointXYZRGB>(object_, object_feature_, cluster, cluster_feature, object_aligned, align_result_transform);**/
2.3 PCA點云粗配準
void ex_segmentor::PCA_registration(pcl::PointCloud< PointXYZRGB >::Ptr
-
匹配器
+關注
關注
0文章
6瀏覽量
5754 -
PCL
+關注
關注
1文章
35瀏覽量
13694 -
點云
+關注
關注
0文章
58瀏覽量
3807
發布評論請先 登錄
相關推薦
評論