我有一个函数,它成功地读入一个点云,并将其存储在< code>pcl::PointCloud中
然后我跑了
//filter the pointcloud to remove some noise while still keeping the cloud dense
pcl::PointCloud<pcl::PointXYZ>::Ptr tmp = filter_obj.filterVoxelGrid(pcd, 0.01, 0.01, 0.01);
其中filter_obj
是stereo_pointcloud_filter
的对象
pcl::PointCloud<pcl::PointXYZ>::Ptr stereo_pointcloud_filter::filterVoxelGrid(
pcl::PointCloud<pcl::PointXYZ>::Ptr inputcloud,
float voxelX, float voxelY, float voxelZ)
{
pcl::PointCloud<pcl::PointXYZ>::Ptr outputcloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl::VoxelGrid<pcl::PointXYZ> sor;
sor.setInputCloud(inputcloud);
sor.setLeafSize(voxelX, voxelY, voxelZ);
sor.filter(*outputcloud);
pcl::PointCloud<pcl::PointXYZ>::Ptr result(outputcloud);
return result;
}
在取消分配tmp
期间,我遇到了一个分段错误。我几乎可以肯定这个错误与filterVoxelGrid()
中的一些错误指针有关,但我不确定如何解决它。
这是调用堆栈
llocator_traits6!__GI___libc_free(空*mem)(/usr/src/grebc/grebc-2.23/malloc/malloc. c: 2951)Eigen::内部::handmade_aligned_free(空*ptr)(/home/shawn/Documents/Projects/catkin_ws/devel/包含/Eigen/src/Core/util/Memory. h: 98)Eigen::内部::aligned_free(空*ptr)(/home/shawn/Documents/catkin_ws/devel/包含/Eigen/src/Core/util/Mem. h: 179)Eigen::aligned_allocator::dea借阅(Eigen::a*const this,Eigen::a::指针p)(/home/shawn/Projects/catkin_ws/devel/包括/Eigen/src/Core/util/Memory. h: 755)d::a
虽然我无法找到解决这个问题的方法,但我找到了一个解决方法。我切换到使用pcl::PCLPointCloud2
集成pcl::PointCloud
pcl::PointCloud<pcl::PointXYZ>::Ptr stereo_pointcloud_filter::filterVoxelGrid(
pcl::PointCloud<pcl::PointXYZ>::Ptr inputcloud,
float voxelX, float voxelY, float voxelZ)
{
pcl::PCLPointCloud2::Ptr cloud(new pcl::PCLPointCloud2());
pcl::toPCLPointCloud2(*inputcloud, *cloud);
pcl::PointCloud<pcl::PointXYZ>::Ptr outputcloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PCLPointCloud2::Ptr cloud_filtered(new pcl::PCLPointCloud2());
// Create the filtering object
pcl::VoxelGrid<pcl::PCLPointCloud2> sor;
sor.setInputCloud(cloud);
sor.setLeafSize(voxelX, voxelY, voxelZ);
sor.filter(*cloud_filtered);
pcl::fromPCLPointCloud2(*cloud_filtered, *outputcloud);
return outputcloud;
}
问题出在PCL库的某处。我的机器上有几个不同版本的PCL版本,这可能导致了某种冲突。擦除所有内容并重新启动可清除此错误。