pcl::SHOT352 descriptor1 = shot1->at(i);错误“std::vector<std::bitset<352>,std::allocator<std::bitset<352>>>”类型没有重载成员“operator ->”
时间: 2023-07-02 18:16:41 浏览: 57
这个错误提示表明变量shot1的类型是std::vector<std::bitset<352>>,不是指针类型,因此无法使用箭头运算符->获取其成员。解决这个问题的方法是使用下标运算符[]来访问std::vector容器中的元素。示例如下:
```
std::vector<std::bitset<352>> shot1; // 假设变量shot1是std::vector<std::bitset<352>>类型
pcl::SHOT352 descriptor1;
for(int i=0; i<shot1.size(); i++){
for(int j=0; j<352; j++){
descriptor1.descriptor[j] = shot1[i][j]; // 使用下标运算符访问std::vector容器中的元素
}
}
```
需要注意的是,bitset类型的元素可以使用下标运算符[]来访问每一位二进制数。在本例中,bitset的长度是352,因此需要使用for循环遍历每一位二进制数,将其赋值给SHOT352描述符的元素。
相关问题
pcl::SHOT352 descriptor1 = shot1->at(i); pcl::SHOT352 descriptor2 = shot2->at(i);如何对两个二进制数进行异或操作
由于`pcl::SHOT352`是由多个`uint32_t`类型的数据组成的,因此需要先将两个`pcl::SHOT352`类型的变量中对应的`uint32_t`类型数据分别进行异或操作,然后将结果存储到一个新的`pcl::SHOT352`类型变量中。可以使用循环遍历每个`uint32_t`类型数据,然后对其进行异或操作,例如:
```
pcl::SHOT352 descriptor1 = shot1->at(i);
pcl::SHOT352 descriptor2 = shot2->at(i);
pcl::SHOT352 diff;
for(int j = 0; j < 11; j++) // 11是352位二进制数中uint32_t类型数据的数量
{
diff.histogram[j] = descriptor1.histogram[j] ^ descriptor2.histogram[j];
}
```
在上面的代码中,`diff`是一个新的`pcl::SHOT352`类型的变量,`j`是循环变量,遍历每个`uint32_t`类型数据的下标。`^`是按位异或操作符,将`descriptor1.histogram[j]`和`descriptor2.histogram[j]`对应的`uint32_t`类型数据进行异或操作,将结果存储到`diff.histogram[j]`中。最终,`diff`中就存储了`descriptor1`和`descriptor2`两个二进制数的按位异或结果。
pcl::SHOT352 descriptor2 = shot2->at(i);如果shot2是二进制向量,要怎么改
如果变量shot2是二进制向量,那么要根据实际情况进行修改。如果二进制向量中的每个元素都是8位二进制数,则可以将其转换为一个unsigned char类型的数组,然后将其作为SHOT352描述符的元素赋值给变量descriptor2。示例如下:
```
std::vector<unsigned char> binary_descriptor = get_binary_descriptor(); // 假设获取到了二进制向量
pcl::SHOT352 descriptor2;
for(int j=0; j<352; j++){
descriptor2.descriptor[j] = binary_descriptor[j]; // 将二进制向量赋值给descriptor2
}
```
需要注意的是,二进制向量的长度必须与SHOT352描述符的长度相同,否则会导致数组越界或者信息丢失。同时,二进制向量的元素取值范围应该在0~255之间,否则可能会出现类型转换错误。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.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)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)