【PCL】点云库PCL常见错误

3 篇文章 0 订阅

本文转载于 《点云库PCL从入门到精通常见的编译错误》
原文连接:https://blog.csdn.net/jacken123456/article/details/105361314

(1)error c4996: ‘fopen’: This function or variable may be unsafe

解决方法:项目->属性->配置属性->C/C++ -> 预处理器 -> 预处理器定义,增加: _CRT_SECURE_NO_DEPRECATE。

参考博文:https://blog.csdn.net/wangyang20170901/article/details/78810068

(2)…\flann\algorithms\dist.h(523): error C3861: “pop_t”: 找不到标识符

解决方法:双击该行输出直接打开dist.h头文件;将第503行的typedef unsigned long long pop_t;移动到第480行前面。

参考博文:https://blog.csdn.net/weixin_41991128/article/details/83864713

(3)boost\typeof\msvc\typeof_impl.hpp(125): error C2988: 不可识别的模板声明/定义

解决方法:可以代码的源文件最开头的位置加上对BOOST_TYPEOF_EMULATION的定义:

#define BOOST_TYPEOF_EMULATION
#include <pcl\registration\icp.h>

参考博文:https://blog.csdn.net/qq_39031960/article/details/83544928

(4)error C4996: ‘pcl::SAC_SAMPLE_SIZE’: This map is deprecated and is kept only to prevent breaking existing user code. Starting from PCL 1.8.0 model sample size is a protected member of the SampleConsensusModel class。

解决方法:打开项目属性页>C/C++>常规>SDL检查(设置为否)。

参考博文:https://blog.csdn.net/qing101hua/article/details/70739391

(5)Failed to find match for field ‘rgba’.(例子5-1)

解决方法:用word打开pcd文件查看的类型,发现 Fields不包含RGBA。将PCL::PointXYZRGBA修改为pcl::PointXYZ。

在这里插入图片描述
(6) Error:no override found for ‘vtkPolyDataMapper’

解决方法:在源文件的开头加上:

#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL);
VTK_MODULE_INIT(vtkInteractionStyle);

参考博文:https://blog.csdn.net/zzh_AI/article/details/88861221

(7) error C2039: “camera_”: 不是“pcl::visualization::PCLVisualizer”的成员

解决方法:最新的pcl已经没有camera_成员了。所以需要替换为:

viewer.camera_.pos[0] = pos_vector[0];
viewer.camera_.pos[1] = pos_vector[1];
viewer.camera_.pos[2] = pos_vector[2];
viewer.camera_.focal[0] = look_at_vector[0];
viewer.camera_.focal[1] = look_at_vector[1];
viewer.camera_.focal[2] = look_at_vector[2];
viewer.camera_.view[0] = up_vector[0];
viewer.camera_.view[1] = up_vector[1];
viewer.camera_.view[2] = up_vector[2];
/***将以上的代码替换为以下函数*****/
viewer.setCameraPosition(pos_vector[0], pos_vector[1], pos_vector[2],
		look_at_vector[0], look_at_vector[1], look_at_vector[2],
		up_vector[0], up_vector[1], up_vector[2]);

参考博文:https://www.cnblogs.com/li-yao7758258/p/6444207.html

(8)range_image_visualization.cpp(129): error C3861: “sleep”: 找不到标识符(pcl_sleep识别不了)

解决方法:定位到pcl_sleep的头文件pcl_macros.h,修改pcl_sleep的宏定义sleep(x) 为Sleep(x),【首字母大写】

参考博文:https://blog.csdn.net/m0_37906001/article/details/97785515

(9)法向显示错误ERROR:no override found for ‘vtkActor’.

解决方法:在源文件中添加:

#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL);

参考博文:https://blog.csdn.net/bflong/article/details/79137692

(10)“error C2653: “sensor_msgs”: 不是类或命名空间名称”

解决方法:在PCL1.8中将PointCloud2加入了pcl名字空间,sensor_msgs是旧的方式,不再使用。将以下代码修改为:

sensor_msgs::PointCloud2::Ptr cloud (new sensor_msgs::PointCloud2 ());
sensor_msgs::PointCloud2::Ptr cloud_filtered (new sensor_msgs::PointCloud2 ());
//以上两行替换为
pcl::PCLPointCloud2::Ptr cloud(new pcl::PCLPointCloud2());
pcl::PCLPointCloud2::Ptr cloud_filtered(new pcl::PCLPointCloud2());

参考博文:https://blog.csdn.net/zfjBIT/article/details/92595768

(11)error C2039: “fromROSMsg”: 不是“pcl”的成员

解决方法:

pcl::fromROSMsg(*cloud_filtered_blob, *cloud_filtered);
//将以上代码修改为
pcl::fromPCLPointCloud2(*cloud_filtered_blob, *cloud_filtered);

(12)error C2039: “compute”: 不是“pcl::UniformSampling”的成员。(例8-4)

解决方法:

//将下面的两行替换
//uniform_sampling.compute(sampled_indices);
//pcl::copyPointCloud(*model, sampled_indices.points, *model_keypoints);
//将上面的两行替换为下面的一行
uniform_sampling.filter(*model_keypoints);   //滤波

参考博文:https://www.cnblogs.com/li-yao7758258/p/6612856.html

(13)使用OpenMP报错,“User Error 1001: argument to num_threads clause must be positive”

解决办法:这是由于设置的线程数必须为正,而程序中可能没有设置,有时候甚至环境变量中设置了,但是依然报错,我们不妨手动设置一下,使用setNumberOfThreads()函数设置一个线程数。例如对于PCL中的一段程序:

pcl::SHOTEstimationOMP<PointType, NormalType, DescriptorType> descr_est;
descr_est.setNumberOfThreads(4);
descr_est.setRadiusSearch(descr_rad_);
 
descr_est.setInputCloud(model_keypoints);
descr_est.setInputNormals(model_normals);
descr_est.setSearchSurface(model);
descr_est.compute(*model_descriptors);

参考博文:https://blog.csdn.net/lch_vison/article/details/80806454

(14)error C2589: “(”:“::”右边的非法标记错误的处理

函数模板中的std::max或者std::min与Visual C++中的全局的宏max冲突。

解决办法:

第一种办法:设置项目属性,在预定义处理器中添加定义NOMINMAX来禁止使用Visual C++的min/max宏定义。项目属性——> C/C++ ——> 预处理器 ——> 预处理器定义 (此处添加预定义编译开关 NOMINMAX)

但是visual C++中定义能自动匹配double和int,如果进行了上述设置,代码中手动将int型的数据乘以1.0来达到double的目的。

第二种办法: 加上括号,与Vsual C++的min/max宏定义区分开:(std::numeric_limits::max)()

参考博文:https://blog.csdn.net/martinkeith/article/details/90896584

(15)error C2440: “初始化”: 无法从“const float [3]”转换为“Eigen::Map<const Eigen::Vector3f,0,Eigen::Stride<0,0>>”

解决办法:将以下代码替换为:

Eigen::Map<const Eigen::Vector3f> point_a_normal = point_a.normal, point_b_normal = point_b.normal;
]//将以上代码替换为下面的代码
Eigen::Map<const Eigen::Vector3f> point_a_normal = point_a.getNormalVector3fMap(); 
Eigen::Map<const Eigen::Vector3f> point_b_normal = point_b.getNormalVector3fMap();

(16)PCL use getColor() without parameters instead 报错

解决办法:在头文件point_cloud_color_handlers.h中注释掉如下代码 大概在117和619行

PCL_DEPRECATED(1,12,"use getColor() without parameters instead")

(16)error C2661: “pcl::PointCloud::operator new”: 没有重载函数接受 3 个参数
MFC在最开头加了这样的预编译,导致PCL的new报错。
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
解决方法:
把这三行注释,位置在你的dlg.cpp中

  • 7
    点赞
  • 52
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值