使用 pcl::VoxelGrid报错In template: type ‘detail::CopyPointHelper<PointXYZ, PointXYZ>‘ does not provide
// Voxel Grid Downsampling
pcl::VoxelGrid<pcl::PointXYZ> sor;
sor.setInputCloud(cloud_filtered);
//三个参数分别代表x、y、z方向上的体素尺寸,都被设置为0.025米。这意味着在每个维度上,每0.025米的距离内,所有点都将被合并到一个体素中,从而选择一个代表点或者进行某种聚合操作(如平均值),以此来减少点云的密度
sor.setLeafSize(0.025f, 0.025f, 0.025f); // Set voxel size to 0.025 meters
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_downsampled(new pcl::PointCloud<pcl::PointXYZ>);
// sor.filter(*cloud_downsampled);
sor.filter(*cloud_downsampled);
报错:
In template: type 'detail::CopyPointHelper<PointXYZ, PointXYZ>' does not provide a call operator error occurred here in instantiation of function template specialization 'pcl::copyPoint<pcl::PointXYZ, pcl::PointXYZ>' requested here in instantiation of function template specialization 'pcl::copyPointCloud<pcl::PointXYZ, pcl::PointXYZ>' requested here in instantiation of member function 'pcl::Filterpcl::PointXYZ::filter' requested here
sr/include/pcl-1.10/pcl/common/impl/io.hpp: In function ‘int pcl::getFieldIndex(const string&, const std::vector<pcl::PCLPointField>&)’:
/usr/include/pcl-1.10/pcl/common/impl/io.hpp:73:27: error: use of ‘auto’ in lambda parameter declaration only available with ‘-std=c++14’ or ‘-std=gnu++14’
73 | [&field_name](const auto& field) { return field.name == field_name; });
| ^~~~
/usr/include/pcl-1.10/pcl/common/impl/io.hpp: In lambda function:
/usr/include/pcl-1.10/pcl/common/impl/io.hpp:73:55: error: request for member ‘name’ in ‘field’, which is of non-class type ‘const int’
73 | [&field_name](const auto& field) { return field.name == field_name; });
| ^~~~
/usr/include/pcl-1.10/pcl/common/impl/io.hpp: In function ‘void pcl::copyPointCloud(const pcl::PointCloud<PointT>&, const std::vector<pcl::PointIndices>&, pcl::PointCloud<PointOutT>&)’:
/usr/include/pcl-1.10/pcl/common/impl/io.hpp:272:16: error: use of ‘auto’ in lambda parameter declaration only available with ‘-std=c++14’ or ‘-std=gnu++14’
272 | [](const auto& acc, const auto& index) { return index.indices.size() + acc; });
| ^~~~
/usr/include/pcl-1.10/pcl/common/impl/io.hpp:272:33: error: use of ‘auto’ in lambda parameter declaration only available with ‘-std=c++14’ or ‘-std=gnu++14’
272 | [](const auto& acc, const auto& index) { return index.indices.size() + acc; });
| ^~~~
/usr/include/pcl-1.10/pcl/common/impl/io.hpp: In lambda function:
/usr/include/pcl-1.10/pcl/common/impl/io.hpp:272:61: error: request for member ‘indices’ in ‘index’, which is of non-class type ‘const int’
272 | [](const auto& acc, const auto& index) { return index.indices.size() + acc; });
解决:
原因 pcl版本过高
cmakeList.txt 中使用 C++14
if( CMAKE_BUILD_TYPE STREQUAL "Release")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -std=c++14 -fPIC")
else()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -std=c++14 -fPIC")
endif()