PCL中Ptr释放问题 aligned_free

/** \internal Frees memory allocated with aligned_malloc. */
EIGEN_DEVICE_FUNC inline void aligned_free(void *ptr)
{
  #if (EIGEN_DEFAULT_ALIGN_BYTES==0) || EIGEN_MALLOC_ALREADY_ALIGNED
    EIGEN_USING_STD(free)
    free(ptr);
  #else
    handmade_aligned_free(ptr);
  #endif
}

解决办法:

VS:通过项目属性->C/C++->代码生成->启用增强指令集->选择AVX

事情的起因是这样的

我用的是PCL1.12.1版本,创建了一个函数,用来计算法向,然后我发现计算出的法向中有值为NaN的点,所以我想要看看这些点是哪些,pcl中有函数removeNaNNormalsFromPointCloud可以直接将这些点剔除,并且还能够返回这些点的下标。总之,因为以上的种种原因,我写出了下面的代码

xxx func(pcl::PointCloud<pcl::PointXYZ>::ConstPtr input_cloud)

{

    pcl::PointCloud<pcl::Normal>::Ptr cloud_with_normals(new pcl::PointCloud<pcl::Normal>);

    /*

        计算法向

    */


    pcl::PointCloud<pcl::Normal>::Ptr cloud_removeNan(new pcl::PointCloud<pcl::Normal>);

    pcl::removeNaNNormalsFromPointCloud(*cloud_with_normals, *cloud_removeNan, indices);

    return;

}

然后在 return的时候函数报错如下:

debug后发现问题出在 cloud_removeNan上,

如果替换为原始指针就能成功返回

pcl::PointCloud<pcl::Normal>::Ptr cloud_removeNan(new pcl::PointCloud<pcl::Normal>);

事情到这里就解决了,但是代码写的太多太长了,如果全部替换为原始指针能累死。

还有一个原因是因为PCL中很多函数的参数类型是Ptr

继续找,肯定有人跟我有一样的问题

https://github.com/PointCloudLibrary/pcl/issues/4859

上面的链接中提到通过启用AVX可以解决这个问题

提到CMake时添加选项来启用AVX:https://github.com/PointCloudLibrary/pcl/pull/4698

但是我的PCL是all in one安装的,不想再去CMake了。于是继续找VS有没有方法能够直接解决

/arch (x86) | Microsoft Docs

VS:通过项目属性->C/C++->代码生成->启用增强指令集->选择AVX

评论 28
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值