pcl::correspondence
时间: 2023-11-24 14:07:45 浏览: 41
pcl::correspondence 是 PCL(Point Cloud Library) 中的一个类,用于表示两个点云中的点之间的对应关系。在点云配准等应用中,需要找到两个点云中相对应的点,这个过程就叫做点云的对应。pcl::correspondence 中存储了两个点的索引以及它们之间的距离,可以用于后续的配准计算。在 PCL 中,点云对应的计算可以通过特征描述子匹配等方法来实现。
相关问题
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); } }这样是对的吧
是的,对于二进制描述子,不需要判断是否是有限值,因此你可以直接删除原先的那行 `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);
}
}
}
```
这段代码现在逻辑上是正确的。
pcl::Correspondence correspondence(i, best_index, best_distance);
这是一行基于 PCL(Point Cloud Library)的 C++ 代码,其中创建了一个名为 `correspondence` 的 `pcl::Correspondence` 对象,该对象的构造函数接受三个参数:`i`、`best_index` 和 `best_distance`。根据上下文来看,这行代码可能是在为某个点云中的某个点寻找最佳匹配点云中的最佳匹配点,并将匹配的结果保存在 `correspondence` 对象中。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)