1

在下面的代碼段中,我得到'Debug assertion failed'錯誤消息,它說'向量下標超出範圍',在兩次打印之間。我在64位機器上使用PCL 1.7.1,Win7和VS2010。調試錯誤 - 向量下標超出範圍 - PCL

事情是,這發生在隨機的基礎上,我不知道該怎麼做。我如何調試這樣的事情,因爲這看起來像點雲庫(PCL)中的錯誤,但我很猶豫,因爲通常錯誤與我在一起。

代碼的作用是,從文件中加載一個.pcd文件和點雲數據,然後嘗試從中創建一個ESF描述符。現在我知道,我已經脫離了該向量的索引,但仍然沒有發生在我的代碼中......任何想法我可能做錯了什麼?

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; 
} 

回答