基础环境配置都是比较简单的,请按照下面几篇博客完成配置
https://blog.csdn.net/uniqueyyc/article/details/79245009
https://blog.csdn.net/u013541523/article/details/84194207
https://blog.csdn.net/liukunrs/article/details/80216329
如果按照上述几篇博客配置成功,后面的就不需要看了。
确保上述配置无误,文件最起码是可以编译成功的。
下面是我使用的试验代码,也是摘自上面几篇博客中的代码。
#include "stdafx.h"
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/ModelCoefficients.h>
#include <pcl/filters/project_inliers.h>
int main(int argc, char** argv)
{
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_projected(new pcl::PointCloud<pcl::PointXYZ>);
// Fill in the cloud data
cloud->width = 5;
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 * rand() / (RAND_MAX + 1.0f);
cloud->points[i].y = 1024 * rand() / (RAND_MAX + 1.0f);
cloud->points[i].z = 1024 * rand() / (RAND_MAX + 1.0f);
}
std::cerr << "Cloud before projection: " << std::endl;
for (size_t i = 0; i < cloud->points.size(); ++i)
std::cerr << " " << cloud->points[i].x << " "
<< cloud->points[i].y << " "
<< cloud->points[i].z << std::endl;
// Create a set of planar coefficients with X=Y=0,Z=1
pcl::ModelCoefficients::Ptr coefficients(new pcl::ModelCoefficients());
coefficients->values.resize(4);
coefficients->values[0] = coefficients->values[1] = 0;
coefficients->values[2] = 1.0;
coefficients->values[3] = 0;
// Create the filtering object
pcl::ProjectInliers<pcl::PointXYZ> proj;
proj.setModelType(pcl::SACMODEL_PLANE);
proj.setInputCloud(cloud);
proj.setModelCoefficients(coefficients);
proj.filter(*cloud_projected);
std::cerr << "Cloud after projection: " << std::endl;
for (size_t i = 0; i < cloud_projected->points.size(); ++i)
std::cerr << " " << cloud_projected->points[i].x << " "
<< cloud_projected->points[i].y << " "
<< cloud_projected->points[i].z << std::endl;
system("pause");
return (0);
}
第一个问题
严重性 代码 说明 项目 文件 行 禁止显示状态
错误 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 pcltest d:\program files\pcl 1.8.1\include\pcl-1.8\pcl\sample_consensus\model_types.h 99
属性-c/c+±常规-sdl检查-选择否
如果上述方法没解决,请试着修改model_type.h程序
将
`/*
namespace pcl
{
const static std::map<pcl::SacModel, unsigned int>
PCL_DEPRECATED("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")
SAC_SAMPLE_SIZE (sample_size_pairs, sample_size_pairs + sizeof (sample_size_pairs) / sizeof (SampleSizeModel));
}
*/`
修改为
namespace pcl
{
const static std::map<pcl::SacModel, unsigned int>
//PCL_DEPRECATED("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")
SAC_SAMPLE_SIZE(sample_size_pairs, sample_size_pairs + sizeof(sample_size_pairs) / sizeof(SampleSizeModel));
}
第二个问题
无法定位程序输入点、、、、、于动态链接库.exe
将属性-c/c+±预处理器-预处理器定义 添加一行 PCL_NO_PRECOMPILE
第三个问题
有时候会遇到一个问题 先前遇到过但是没法复现了
调试输出中一般会出现下面几个类似的字符 需要#define _CRT_SECURE_NO_WARNINGS之类的
针对这个问题,还是在预处理器定义中,添加一行_CRT_SECURE_NO_WARNINGS即可