PCL特征匹配失败
PCL feature matching failure
我试图通过更改许多参数来匹配我测试的两个点云之间的特征,但它总是产生错误的匹配。我正在计算 SIFT 特征的 PFH 特征描述符。
感谢您的建议。
下面是我使用的代码
// load the both point clouds
pcl::io::loadPCDFile("Tee.pcd", *cloud_1);
pcl::PLYReader Reader;
Reader.read("tee.ply", *cloud_2);
//pcl::io::loadPCDFile("Tee.pcd", *cloud_2);
// Create the filtering object
pcl::PassThrough<pcl::PointXYZRGB> pass;
pass.setInputCloud(cloud_2);
pass.setFilterFieldName("z");
pass.setFilterLimits(0.0, 1.0);
//pass.setFilterLimitsNegative (true);
pass.filter(*cloud_2_filtered);
// Downsample the cloud
const float voxel_grid_leaf_size = 0.009f;
downsample(cloud_1, voxel_grid_leaf_size, downsampledCloud_1);
std::cout << "First cloud: downsampled " << std::endl;
const float voxel_grid_leaf_size2 = 0.003f;
downsample(cloud_2_filtered, voxel_grid_leaf_size2, downsampledCloud_2);
std::cout << "second cloud: downsampled " << std::endl;
// Compute surface normals
const float normal_radius = 0.03;
compute_surface_normals(downsampledCloud_1, normal_radius, normalsFromCloud_1);
compute_surface_normals(downsampledCloud_2, normal_radius, normalsFromCloud_2);
std::cout << "second cloud: normals computed " << std::endl;
// Compute keypoints
const float min_scale = 0.01;
const int nr_octaves = 3;
const int nr_octaves_per_scale = 6;
const float min_contrast = 1.0;
detect_keypoints(cloud_1, min_scale, nr_octaves, nr_octaves_per_scale, min_contrast, keypointsFromCloud_1);
std::cout << "first cloud: keypoints computed " << std::endl;
//const float min_scale1 = 0.1;
detect_keypoints(cloud_2_filtered, min_scale, nr_octaves, nr_octaves_per_scale, min_contrast, keypointsFromCloud_2);
std::cout << "second cloud: keypoints computed " << std::endl;
//visualize_keypoints(cloud_2, keypointsFromCloud_2);
// Compute PFH features
const float feature_radius = 0.08;
compute_PFH_features_at_keypoints(downsampledCloud_1, normalsFromCloud_1, keypointsFromCloud_1, feature_radius, descriptors1);
std::cout << "first cloud: descriptor computed " << std::endl;
compute_PFH_features_at_keypoints(downsampledCloud_2, normalsFromCloud_2, keypointsFromCloud_2, feature_radius, descriptors2);
std::cout << "second cloud: descriptor computed " << std::endl;
// Find feature correspondences
std::vector<int> correspondences;
std::vector<float> correspondence_scores;
find_feature_correspondences(descriptors1, descriptors2, correspondences, correspondence_scores);
// Print out ( number of keypoints / number of points )
std::cout << "First cloud: Found " << keypointsFromCloud_1->size() << " keypoints "
<< "out of " << downsampledCloud_1->size() << " total points." << std::endl;
std::cout << "Second cloud: Found " << keypointsFromCloud_2->size() << " keypoints "
<< "out of " << downsampledCloud_2->size() << " total points." << std::endl;
// Visualize the two point clouds and their feature correspondences
visualize_correspondences(cloud_1, keypointsFromCloud_1, cloud_2_filtered, keypointsFromCloud_2, correspondences, correspondence_scores);
结果图如图:
数据和预处理
您似乎在尝试将仅包含对象的点云与对象位于场景内部的点云进行匹配。
为了获得一致且稳健的结果,请事先从场景中提取所有对象,并尝试将参考与所有检测到的对象相匹配,select 最佳匹配。
描述符
我使用 SHOT 描述符而不是 PFH 获得了更好的结果。
Here 您可以从 PCL 的作者那里阅读更多关于 Object Recognition 的内容,他们在其中描述和解释对象识别的整个流程。
我试图通过更改许多参数来匹配我测试的两个点云之间的特征,但它总是产生错误的匹配。我正在计算 SIFT 特征的 PFH 特征描述符。
感谢您的建议。
下面是我使用的代码
// load the both point clouds
pcl::io::loadPCDFile("Tee.pcd", *cloud_1);
pcl::PLYReader Reader;
Reader.read("tee.ply", *cloud_2);
//pcl::io::loadPCDFile("Tee.pcd", *cloud_2);
// Create the filtering object
pcl::PassThrough<pcl::PointXYZRGB> pass;
pass.setInputCloud(cloud_2);
pass.setFilterFieldName("z");
pass.setFilterLimits(0.0, 1.0);
//pass.setFilterLimitsNegative (true);
pass.filter(*cloud_2_filtered);
// Downsample the cloud
const float voxel_grid_leaf_size = 0.009f;
downsample(cloud_1, voxel_grid_leaf_size, downsampledCloud_1);
std::cout << "First cloud: downsampled " << std::endl;
const float voxel_grid_leaf_size2 = 0.003f;
downsample(cloud_2_filtered, voxel_grid_leaf_size2, downsampledCloud_2);
std::cout << "second cloud: downsampled " << std::endl;
// Compute surface normals
const float normal_radius = 0.03;
compute_surface_normals(downsampledCloud_1, normal_radius, normalsFromCloud_1);
compute_surface_normals(downsampledCloud_2, normal_radius, normalsFromCloud_2);
std::cout << "second cloud: normals computed " << std::endl;
// Compute keypoints
const float min_scale = 0.01;
const int nr_octaves = 3;
const int nr_octaves_per_scale = 6;
const float min_contrast = 1.0;
detect_keypoints(cloud_1, min_scale, nr_octaves, nr_octaves_per_scale, min_contrast, keypointsFromCloud_1);
std::cout << "first cloud: keypoints computed " << std::endl;
//const float min_scale1 = 0.1;
detect_keypoints(cloud_2_filtered, min_scale, nr_octaves, nr_octaves_per_scale, min_contrast, keypointsFromCloud_2);
std::cout << "second cloud: keypoints computed " << std::endl;
//visualize_keypoints(cloud_2, keypointsFromCloud_2);
// Compute PFH features
const float feature_radius = 0.08;
compute_PFH_features_at_keypoints(downsampledCloud_1, normalsFromCloud_1, keypointsFromCloud_1, feature_radius, descriptors1);
std::cout << "first cloud: descriptor computed " << std::endl;
compute_PFH_features_at_keypoints(downsampledCloud_2, normalsFromCloud_2, keypointsFromCloud_2, feature_radius, descriptors2);
std::cout << "second cloud: descriptor computed " << std::endl;
// Find feature correspondences
std::vector<int> correspondences;
std::vector<float> correspondence_scores;
find_feature_correspondences(descriptors1, descriptors2, correspondences, correspondence_scores);
// Print out ( number of keypoints / number of points )
std::cout << "First cloud: Found " << keypointsFromCloud_1->size() << " keypoints "
<< "out of " << downsampledCloud_1->size() << " total points." << std::endl;
std::cout << "Second cloud: Found " << keypointsFromCloud_2->size() << " keypoints "
<< "out of " << downsampledCloud_2->size() << " total points." << std::endl;
// Visualize the two point clouds and their feature correspondences
visualize_correspondences(cloud_1, keypointsFromCloud_1, cloud_2_filtered, keypointsFromCloud_2, correspondences, correspondence_scores);
结果图如图:
数据和预处理
您似乎在尝试将仅包含对象的点云与对象位于场景内部的点云进行匹配。
为了获得一致且稳健的结果,请事先从场景中提取所有对象,并尝试将参考与所有检测到的对象相匹配,select 最佳匹配。
描述符
我使用 SHOT 描述符而不是 PFH 获得了更好的结果。
Here 您可以从 PCL 的作者那里阅读更多关于 Object Recognition 的内容,他们在其中描述和解释对象识别的整个流程。