void find_match_shot(pcl::PointCloud<pcl::BINARY>::Ptr shot1, pcl::PointCloud<pcl::BINARY>::Ptr shot2, pcl::CorrespondencesPtr model_scene_corrs) { clock_t start = clock(); pcl::KdTreeFLANNpcl::BINARY matching; matching.setInputCloud(shot1); for (size_t i = 0; i < shot2->size(); ++i) { std::vector<int> neighbors(1); std::vector<int> hammingDistances(1); int neighborCount = matching.nearestKSearch(shot2->at(i), 1, neighbors, hammingDistances); if (neighborCount == 1 && hammingDistances[0] < 0.05f) { pcl::Correspondence correspondence(neighbors[0], static_cast<int>(i), hammingDistances[0]); model_scene_corrs->push_back(correspondence); } }这样是对的吧
时间: 2024-02-18 13:02:58 浏览: 64
关于点云的匹配算法
是的,对于二进制描述子,不需要判断是否是有限值,因此你可以直接删除原先的那行 `if` 语句,修改后的代码如下:
```
void find_match_shot(pcl::PointCloud<pcl::BINARY>::Ptr shot1, pcl::PointCloud<pcl::BINARY>::Ptr shot2, pcl::CorrespondencesPtr model_scene_corrs) {
clock_t start = clock();
pcl::KdTreeFLANN<pcl::BINARY> matching;
matching.setInputCloud(shot1);
for (size_t i = 0; i < shot2->size(); ++i) {
std::vector<int> neighbors(1);
std::vector<int> hammingDistances(1);
int neighborCount = matching.nearestKSearch(shot2->at(i), 1, neighbors, hammingDistances);
if (neighborCount == 1 && hammingDistances[0] < 0.05f) {
pcl::Correspondence correspondence(neighbors[0], static_cast<int>(i), hammingDistances[0]);
model_scene_corrs->push_back(correspondence);
}
}
}
```
这段代码现在逻辑上是正确的。
阅读全文