data-structures - PCL 库,如何访问有组织的点云?
问题描述
我有一个非常简单的问题:
我有一个存储在数据结构中的有组织的点云。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;
}
推荐阅读
- git - 带有 monorepo 策略的 Spring Cloud Config Git 后端
- android - 将 AndroidInjector 用于通用 Activity/Fragment
- sockets - 如何克服我的有效应用程序被防火墙反复阻止
- sql - SQL查询选择两个日期之间的日期并排除两个日期之间的日期
- c# - 在哪里可以找到 FluentMigrator 类?
- css - 可滚动涡轮表中的 PrimeNG 过滤器下拉问题
- unix - 如何检查父子进程的状态?
- ruby-on-rails - 如何从 Rails 服务器调用(无头)chrome?
- mongodb - 感兴趣的挑战:是否可以根据给定的原型制作一个类?
- jquery - 如何检查两个时间之间的差异以及它是否在角度 2/4 的同一日期?时间格式,如“HH:mm AM”