pcl :: VoxelGrid<> :: filter crash:未分配被释放的指针

时间:2017-04-11 15:19:45

标签: c++ point-cloud-library

我正在尝试使用PointXYZRGB在macOS Sierra上使用brewed PCL-1.8(最新酿造版本)对pcl::VoxelGrid<>::filter点云进行下采样。<​​/ p>

我按照这里的教程http://pointclouds.org/documentation/tutorials/voxel_grid.php,这很好。然后我将点类型修改为pcl :: PointXYZRGB。修改后,程序崩溃并出现错误:

  

过滤前的PointCloud:460400个数据点(x y z).PointCloud   过滤后:41049个数据点(x y   z).test_voxel(22372,0x7fff9663e3c0)malloc:   对象0x10d4bc020的 *错误:未分配的指针被释放* 在malloc_error_break中设置断点以进行调试

源代码:

#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/filters/voxel_grid.h>

typedef pcl::PointXYZRGB PointT;
typedef pcl::PointCloud<pcl::PointXYZRGB> CloudT;

int
main (int argc, char** argv)
{
    CloudT::Ptr cloud (new CloudT());
    CloudT::Ptr cloud_filtered (new CloudT());

  // Fill in the cloud data
  pcl::PCDReader reader;
  // Replace the path below with the path where you saved your file
  reader.read ("table_scene_lms400.pcd", *cloud); // Remember to download the file first!

  std::cerr << "PointCloud before filtering: " << cloud->width * cloud->height 
       << " data points (" << pcl::getFieldsList (*cloud) << ").";

  // Create the filtering object
  pcl::VoxelGrid<PointT> sor;
  sor.setInputCloud (cloud);
  const float grid_size = 0.01f;
  sor.setLeafSize (grid_size, grid_size, grid_size);
  sor.filter (*cloud_filtered); // <==== culprit

  std::cerr << "PointCloud after filtering: " << cloud_filtered->width * cloud_filtered->height 
       << " data points (" << pcl::getFieldsList (*cloud_filtered) << ").";

  return (0);
}

我试图破解这个,但仍然无法弄清楚可能出现的问题。任何帮助将不胜感激。

0 个答案:

没有答案