From b8c22e1c9981a10dfe85a9e901b778814bd0e0e7 Mon Sep 17 00:00:00 2001 From: matlabbe Date: Fri, 18 Jun 2021 16:02:17 -0400 Subject: [PATCH] Fixed pcl::voxelGrid filtering crash on Windows (latest PCL, eigen allocation issue) --- corelib/src/util3d_filtering.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/corelib/src/util3d_filtering.cpp b/corelib/src/util3d_filtering.cpp index 0f373e9c..d19e31fb 100644 --- a/corelib/src/util3d_filtering.cpp +++ b/corelib/src/util3d_filtering.cpp @@ -582,6 +582,10 @@ typename pcl::PointCloud::Ptr voxelizeImpl( pcl::VoxelGrid filter; filter.setLeafSize(voxelSize, voxelSize, voxelSize); filter.setInputCloud(cloud); +#ifdef WIN32 + // Pre-allocating the cloud helps to avoid crash when freeing memory allocated inside pcl library + output->resize(cloud->size()); +#endif if(!indices->empty()) { filter.setIndices(indices);