vs2010+pcl运行cloudviewer时出现Failed to find match for field 'rgba'.

以下附上可视化点云的cloudviewer.cpp代码:

#include <pcl/visualization/cloud_viewer.h>
#include <iostream>
#include <pcl/io/io.h>
#include <pcl/io/pcd_io.h>
    
int user_data;
    
void 
viewerOneOff (pcl::visualization::PCLVisualizer& viewer)
{
    viewer.setBackgroundColor (1.0, 0.5, 1.0);//设置背景颜色
    pcl::PointXYZ o;//存储球心的位置
    o.x = 1.0;
    o.y = 0;
    o.z = 0;
    viewer.addSphere (o, 0.25, "sphere", 0);//添加球
    std::cout << "i only run once" << std::endl;
    
}
//添加一个刷新显示字符串,在主函数中注册后每帧显示都执行一次    
void 
viewerPsycho (pcl::visualization::PCLVisualizer& viewer)
{
    static unsigned count = 0;
    std::stringstream ss;
    ss << "Once per viewer loop: " << count++;
    viewer.removeShape ("text", 0);
    viewer.addText (ss.str(), 200, 300, "text", 0);
    
    //FIXME: possible race condition here:
    user_data++;
}
    
int 
main ()
{
    pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGBA>);
    pcl::io::loadPCDFile ("bunny.pcd", *cloud);
    
    pcl::visualization::CloudViewer viewer("Cloud Viewer");
    //showCloud函数是同步的,在此处等待直到渲染显示为止
    //blocks until the cloud is actually rendered
    viewer.showCloud(cloud);
    
    //use the following functions to get access to the underlying more advanced/powerful
    //PCLVisualizer
    //该注册函数在可视化时只调用一次
    //This will only get called once
    viewer.runOnVisualizationThreadOnce (viewerOneOff);
     //该注册函数在渲染输出时每次都调用
    //This will get called once per visualization iteration
    viewer.runOnVisualizationThread (viewerPsycho);
    while (!viewer.wasStopped ())
    {//在此处可以添加其他处理
    //you can also do cool processing here
    //FIXME: Note that this is running in a separate thread from viewerPsycho
    //and you should guard against race conditions yourself...
    user_data++;
    }
    return 0;
}

Exe文件运行后出现:Failed to find match for field 'rgba'.

Assertion failed: mlf_ >= minimum_max_load_factor, file D:\Program Files\boost_1_55_0\boost_1_55_0\boost/unordered/detail/table.hpp, line 326

并且弹出窗口显示:R6010 -abort() has been called

vs2010+pcl运行cloudviewer时出现Failed to find match for field 'rgba'.

vs2010+pcl运行cloudviewer时出现Failed to find match for field 'rgba'.

找到table.hpp文件的326行:

BOOST_ASSERT(mlf_ >= minimum_max_load_factor);

查看变量值发现mlf_ =-4.3160208e+008,minimum_max_load_factor=0.001000000.

vs2010+pcl运行cloudviewer时出现Failed to find match for field 'rgba'.

关于出现abort()终止程序,找到了一篇文章:https://www.cnblogs.com/milanleon/p/5868703.html

网上查询关于Failed to find match for field 'rgba'.问题的文章,解决办法如下:

导致出现这样的原因有:

1.非法指针访问和内存泄漏

2.设置的指针范围跟你运行的不对

3.指针访问内存越界出现问题。

4.因为不支持中文。

5.内存不够分配

6.多线程访问资源出的问题。

7.检查exe和dll是否混用的不同版本的crt

解决方法:

第一:检查申请的空间没有释放

第二:检查堆栈空间是否已经被全部分配满,建议每次内存分配尽量不要太大,并且记得释放

第三:指针指向了不可预期的内存位置

       一开始以为是PointXYZRGBA点云格式的用法有问题,将类型改为PointXYZRGB发现还是会出现Failed to find match for field 'rgb'.的错误。已经排除了路径为中文的问题,pcd数据文件的路径问题,貌似也不存在指针的用法错误。本人最近才开始pcl的学习,不知道出现这类问题的根本原因是什么,请各位大神指教,感谢!