c++ - 如何访问 PCLPointCloud2 类型的点

标签 c++ point-cloud-library

通过以下代码从 STL 文件“sphere.STL”获取点云是否正确?

pcl::PolygonMesh mesh;
pcl::io::loadPolygonFileSTL("sphere.stl", mesh);
pcl::PCLPointCloud2::Ptr ThisCloud = boost::make_shared<pcl::PCLPointCloud2>(mesh.ThisCloud);

那么,如何访问'ThisCloud'的各个点?

最佳答案

我想我转换了 pcl::PCLPointCloud2pcl::PointCloud<PointXYZ> :

...
// conversion
pcl::PointCloud<pcl::PointXYZ>::Ptr vertices( new pcl::PointCloud<pcl::PointXYZ> );
pcl::fromPCLPointCloud2( mesh.cloud, *vertices ); 

// access each vertex 
for( int idx = 0; idx < vertices->size(); idx++ )
{
   pcl::PointXYZ v = vertices->points[ idx ];

   float x = v._PointXYZ::data[ 0 ];
   float y = v._PointXYZ::data[ 1 ];
   float z = v._PointXYZ::data[ 2 ];
}

关于c++ - 如何访问 PCLPointCloud2 类型的点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43719848/

相关文章:

c++ - 是否存在用于文件系统事件的跨平台库?

c++ - 在 C++ 中将数字显式舍入到小数点后 7 位以上

c++ - 如何访问点云库中matrix3f的第一列?

c++ - 带有 Visual Studio 2017 的点云库

Python - 显示 3D 点云

c++ - 删除给定框内的点云

C++构造函数格式

c++ - boost::unique_lock 和 boost::upgrade_lock 之间的区别?

c++ - Visual Studio 2015 : Build successful but debugging never stops loading

c++ - 如何为 OpenNI2 构建 PCL?