4
votes

I get a 'Debug assertion failed' error message where it says 'vector subscript out of range', between the two prints in the code snippet below. I am using PCL 1.7.1 on a 64bit machine, Win7 and VS2010.

The thing is, this happens on a random basis and I have no idea what to do. How do I debug such a thing as this looks like an error in the Point cloud library (PCL) but I am hesitant because normally the error is with me.

What the code does is, load a .pcd file with Point cloud data from a file and then try to create an ESF descriptor from it. Now I know, that I am out of index in that vector but still, it does not happen in my code... Any ideas what I might be doing wrong?

pcl::PointCloud<pcl::ESFSignature640>::Ptr  createESFDescriptor(std::vector<float> v) {

    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
    pcl::io::loadPCDFile("data.pcd", *cloud);
    std::cout << "size: " << cloud->size() << std::endl;

    pcl::ESFEstimation<pcl::PointXYZ,pcl::ESFSignature640> esf;
    esf.setInputCloud(cloud);

    pcl::search::KdTree<pcl::PointXYZ>::Ptr kdtree (new pcl::search::KdTree<pcl::PointXYZ>);
    esf.setSearchMethod(kdtree);

    pcl::PointCloud<pcl::ESFSignature640>::Ptr esfPointer(new pcl::PointCloud<pcl::ESFSignature640> ());

    printf("dbg1");
    esf.compute(*esfPointer);
    printf("dbg2");

    return esfPointer;
}
1

1 Answers

0
votes

Your kdtree has no input, add kdtree.setInputCloud (cloud);under pcl::search::KdTree<pcl::PointXYZ>::Ptr kdtree (new pcl::search::KdTree<pcl::PointXYZ>);

check the official tutorial:http://pointclouds.org/documentation/tutorials/kdtree_search.php#kdtree-search