std::vector<float> squaredDistances(1);如果是计算汉明距离,这个怎么改
时间: 2024-02-18 22:02:49 浏览: 66
如果你要计算汉明距离,那么你需要将 `squaredDistances` 的类型从 `std::vector<float>` 改为 `std::vector<int>`,因为汉明距离是一个整数,而不是浮点数。同时,你需要将 `nearestKSearch` 函数的第三个参数从 `squaredDistances` 改为 `hammingDistances`,它是一个 `std::vector<int>` 类型的变量,用于存储汉明距离。修改后的代码如下所示:
```
std::vector<int> hammingDistances(1);
if (pcl_isfinite(scene_descriptors->at(i).descriptor[0])) {
int neighborCount = matching.nearestKSearch(scene_descriptors->at(i), 1, neighbors, hammingDistances);
if (neighborCount == 1 && hammingDistances[0] < threshold) {
pcl::Correspondence correspondence(neighbors[0], static_cast<int>(i), hammingDistances[0]);
model_scene_corrs->push_back(correspondence);
}
}
```
其中,`threshold` 是你根据实际数据特征设置的汉明距离的阈值。
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20241231045021.png)
![-](https://img-home.csdnimg.cn/images/20241231045021.png)
![-](https://img-home.csdnimg.cn/images/20241231044833.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![txt](https://img-home.csdnimg.cn/images/20241231045021.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![txt](https://img-home.csdnimg.cn/images/20241231045021.png)
![cpp](https://img-home.csdnimg.cn/images/20250102104920.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![flv](https://img-home.csdnimg.cn/images/20250102104920.png)
![flv](https://img-home.csdnimg.cn/images/20250102104920.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241231045021.png)