点云学习--PCl 1.7.2 FLANN bug解决

最近在使用pcl库,目前已知更新到pcl 1.7.2。但是官网还是挂着 pcl 1.6的版本。 由于我是用vs2013 所以用”PCL-1.7.2-ALLINOne-msvs2013-win32.exe”

这里写图片描述

但是在跑kdtree example时,总是出现在kdtree.setInputCloud(cloud)出现错误。
google了半天,原来是FLANN 1.7.1 有bug
“This is a known bug in FLANN 1.7.1: http://dev.pointclouds.org/issues/832. The fix is to upgrade to FLANN >= 1.8.0.”
地址:http://www.pcl-users.org/Kdtree-Radius-Search-Debug-Assertion-Failed-td4025503.html

解决方法:

  1. 下载flann最新代码 http://www.cs.ubc.ca/research/flann/uploads/FLANN/flann-1.8.4-src.zip
  2. cmake 构建得到lib
    这里写图片描述
    这里写图片描述
  3. 把构建得到的lib替换PCL 1.7.2 自带的lib

这里写图片描述

附上示例代码

QTime time;
    time = QTime::currentTime();
    qsrand(time.msec() + time.second() * 1000);

    //srand(time(NULL));

    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>());

    // Generate pointcloud data
    cloud->width = 1000;
    cloud->height = 1;
    cloud->points.resize(cloud->width * cloud->height);

    for (size_t i = 0; i < cloud->points.size(); ++i)
    {
        //cloud->points[i].x = 1024.0f * rand() / (RAND_MAX + 1.0f);
        //cloud->points[i].y = 1024.0f * rand() / (RAND_MAX + 1.0f);
        //cloud->points[i].z = 1024.0f * rand() / (RAND_MAX + 1.0f);
        cloud->points[i].x = (float)(qrand() % 1024);
        cloud->points[i].y = (float)(qrand() % 1024);
        cloud->points[i].z = (float)(qrand() % 1024);
    }

    //pcl::search::KdTree<pcl::PointXYZ>::Ptr kdtree(new pcl::search::KdTree<pcl::PointXYZ>());
    pcl::KdTreeFLANN<pcl::PointXYZ> kdtree;

    kdtree.setInputCloud(cloud);

    pcl::PointXYZ searchPoint;

    //searchPoint.x = 1024.0f * rand() / (RAND_MAX + 1.0f);
    //searchPoint.y = 1024.0f * rand() / (RAND_MAX + 1.0f);
    //searchPoint.z = 1024.0f * rand() / (RAND_MAX + 1.0f);
    searchPoint.x = (float)(qrand() % 1024);
    searchPoint.y = (float)(qrand() % 1024);
    searchPoint.z = (float)(qrand() % 1024);
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值