我有一个非常简单的问题:
我有一个 organized点云存储在 pcl::PointCloud<pcl::PointXYZ>
数据结构。
如果我没有弄错,有组织的点云应该存储在类似矩阵的结构中。
所以,我的问题是:有没有办法用行和列索引访问这个结构?而不是以通常的方式访问它,即作为线性数组。
举个例子:
//data structure
pcl::PointCloud<pcl::PointXYZ> cloud;
//linearized access
cloud[j + cols*i] = ....
//matrix-like access
cloud.at(i,j) = ...
谢谢。
最佳答案
您可以通过 () operator
访问积分
//creating the cloud
PointCloud<PointXYZ> organizedCloud;
organizedCloud.width = 2;
organizedCloud.height = 3;
organizedCloud.is_dense = false;
organizedCloud.points.resize(organizedCloud.height*organizedCloud.width);
//setting random values
for(std::size_t i=0; i<organizedCloud.height; i++){
for(std::size_t j=0; j<organizedCloud.width; j++){
organizedCloud.at(i,j).x = 1024*rand() / (RAND_MAX + 1.0f);
organizedCloud.at(i,j).y = 1024*rand() / (RAND_MAX + 1.0f);
organizedCloud.at(i,j).z = 1024*rand() / (RAND_MAX + 1.0f);
}
}
//display
std::cout << "Organized Cloud" <<std:: endl;
for(std::size_t i=0; i<organizedCloud.height; i++){
for(std::size_t j=0; j<organizedCloud.width; j++){
std::cout << organizedCloud.at(i,j).x << organizedCloud.at(i,j).y << organizedCloud.at(i,j).z << " - "; }
std::cout << std::endl;
}
关于data-structures - PCL 库,如何访问有组织的点云?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50907298/