pcl::VoxelGrid 如何获取每个体素网格中的点数?

问题描述 投票:0回答:1

我知道

pcl::VoxelGrid<PointT>
可用于对
PointCloud
进行下采样。在我的用例中,我想获取每个体素网格内的点数。从 PCL 文档中,我发现 leaf struct 允许我通过调用
getPointCount()
来获取一个体素中的点数。并且 pcl::VoxelGridCovariance 允许我通过调用
getLeaf()
来获取叶子。但我不知道如何将所有这些应用到点云中。我尝试通过
pcl::VoxelGridCovariance<PointT> 
初始化
pcl::VoxelGridCovariance<pcl::PCLPointCloud2> grid;
但收到如下错误。有谁知道这里有什么问题吗?或者还有其他方法来获取每个体素中的点数吗?任何建议表示赞赏!

    /usr/local/include/pcl-1.11/pcl/point_struct_traits.h: In instantiation of ‘struct pcl::traits::fieldList<pcl::PCLPointCloud2>’:
/usr/local/include/pcl-1.11/pcl/filters/voxel_grid_covariance.h:79:70:   required from ‘class pcl::VoxelGridCovariance<pcl::PCLPointCloud2>’
/home/linux/Documents/waymo_onTheGo/cart_boundary.cpp:549:60:   required from here
/usr/local/include/pcl-1.11/pcl/point_struct_traits.h:198:8: error: invalid use of incomplete type ‘struct pcl::traits::fieldList<pcl::PCLPointCloud2>’
 struct fieldList /** \cond NO_WARN_RECURSIVE */ : fieldList<typename POD<PointT>::type> /** \endcond */
        ^~~~~~~~~
/usr/local/include/pcl-1.11/pcl/point_struct_traits.h:198:8: note: declaration of ‘struct pcl::traits::fieldList<pcl::PCLPointCloud2>’
In file included from /usr/local/include/pcl-1.11/pcl/point_struct_traits.h:42:0,
                 from /usr/local/include/pcl-1.11/pcl/type_traits.h:40,
                 from /usr/local/include/pcl-1.11/pcl/memory.h:46,
                 from /usr/local/include/pcl-1.11/pcl/io/pcd_io.h:42,
                 from /home/linux/Documents/waymo_onTheGo/cart_boundary.cpp:8:
/usr/local/include/pcl-1.11/pcl/point_struct_traits.h:204:3: error: no matching function for call to ‘assertion_failed<false>(mpl_::failed************ (pcl::traits::fieldList<pcl::PCLPointCloud2>::POINT_TYPE_NOT_PROPERLY_REGISTERED::************)(pcl::PCLPointCloud2&))’
   BOOST_MPL_ASSERT_MSG((!std::is_same<PointT, typename POD<PointT>::type>::value),
   ^
/usr/include/boost/mpl/assert.hpp:83:5: note: candidate: template<bool C> int mpl_::assertion_failed(typename mpl_::assert<C>::type)
 int assertion_failed( typename assert<C>::type );
     ^~~~~~~~~~~~~~~~
/usr/include/boost/mpl/assert.hpp:83:5: note:   template argument deduction/substitution failed:
/usr/local/include/pcl-1.11/pcl/point_struct_traits.h:204:3: note:   cannot convert ‘pcl::traits::fieldList<pcl::PCLPointCloud2>::POINT_TYPE_NOT_PROPERLY_REGISTERED205::assert_arg()’ (type ‘mpl_::failed************ (pcl::traits::fieldList<pcl::PCLPointCloud2>::POINT_TYPE_NOT_PROPERLY_REGISTERED::************)(pcl::PCLPointCloud2&)’) to type ‘mpl_::assert<false>::type {aka mpl_::assert<false>}’
   BOOST_MPL_ASSERT_MSG((!std::is_same<PointT, typename POD<PointT>::type>::value),
   ^
In file included from /home/linux/Documents/waymo_onTheGo/cart_boundary.cpp:40:0:
/usr/local/include/pcl-1.11/pcl/filters/voxel_grid_covariance.h: In instantiation of ‘class pcl::VoxelGridCovariance<pcl::PCLPointCloud2>’:
/home/linux/Documents/waymo_onTheGo/cart_boundary.cpp:549:60:   required from here
/usr/local/include/pcl-1.11/pcl/filters/voxel_grid_covariance.h:79:70: error: no type named ‘type’ in ‘struct pcl::traits::fieldList<pcl::PCLPointCloud2>’
       using FieldList = typename pcl::traits::fieldList<PointT>::type;
                                                                      ^
/usr/local/include/pcl-1.11/pcl/filters/voxel_grid_covariance.h:80:61: error: no type named ‘PointCloud’ in ‘class pcl::Filter<pcl::PCLPointCloud2>’
       using PointCloud = typename Filter<PointT>::PointCloud;
                                                             ^
/usr/local/include/pcl-1.11/pcl/filters/voxel_grid_covariance.h:56:9: error: ‘std::__cxx11::string pcl::Filter<pcl::PCLPointCloud2>::filter_name_’ is protected within this context
   class VoxelGridCovariance : public VoxelGrid<PointT>
         ^~~~~~~~~~~~~~~~~~~
In file included from /usr/local/include/pcl-1.11/pcl/filters/filter_indices.h:42:0,
                 from /usr/local/include/pcl-1.11/pcl/filters/extract_indices.h:42,
                 from /home/linux/Documents/waymo_onTheGo/cart_boundary.cpp:13:
/usr/local/include/pcl-1.11/pcl/filters/filter.h:240:19: note: declared protected here
       std::string filter_name_;
                   ^~~~~~~~~~~~
In file included from /home/linux/Documents/waymo_onTheGo/cart_boundary.cpp:40:0:
/usr/local/include/pcl-1.11/pcl/filters/voxel_grid_covariance.h:56:9: error: ‘const string& pcl::Filter<pcl::PCLPointCloud2>::getClassName() const’ is protected within this context
   class VoxelGridCovariance : public VoxelGrid<PointT>
         ^~~~~~~~~~~~~~~~~~~
In file included from /usr/local/include/pcl-1.11/pcl/filters/filter_indices.h:42:0,
                 from /usr/local/include/pcl-1.11/pcl/filters/extract_indices.h:42,
                 from /home/linux/Documents/waymo_onTheGo/cart_boundary.cpp:13:
/usr/local/include/pcl-1.11/pcl/filters/filter.h:253:7: note: declared protected here
       getClassName () const
       ^~~~~~~~~~~~
In file included from /home/linux/Documents/waymo_onTheGo/cart_boundary.cpp:40:0:
/usr/local/include/pcl-1.11/pcl/filters/voxel_grid_covariance.h: In instantiation of ‘pcl::VoxelGridCovariance<PointT>::VoxelGridCovariance() [with PointT = pcl::PCLPointCloud2]’:
/home/linux/Documents/waymo_onTheGo/cart_boundary.cpp:549:60:   required from here
/usr/local/include/pcl-1.11/pcl/filters/voxel_grid_covariance.h:205:18: error: using invalid field ‘pcl::VoxelGridCovariance<PointT>::voxel_centroids_’
         kdtree_ ()
                  ^
c++ 3d geometry point-cloud-library voxel
1个回答
0
投票

要访问点数,请使用 OctreePointCloudDensity

要访问每个体素内的点,请使用 OctreePointCloudPointVector

© www.soinside.com 2019 - 2024. All rights reserved.