vs2017配置PCL1.8.1

目录

前言

一、VS2017的安装与下载

二、pcl1.8.1下载与安装

1.下载

2.安装

 三、vs2107配置pcl

1.系统环境变量

 2.配置相关目录

2.1新建属性表

 2.2 设置包含目录、库目录等

2.3测试

总结



前言

由于PCL的环境配置过程中出现的问题较多,鉴于本次对pcl库的配置

一、VS2017的安装与下载


vs2107的下载相对来说还是比较简单的,因此这里就不多赘述,下面会把vs2017以及其对应的pcl库放在网盘里,有需要的朋友可以自行下载,均是对于本次流程所对应的版本。

链接:https://pan.baidu.com/s/1BzKkCeq5jlrWu7v4ti41Sg 
提取码:1234 
-超级会员V3的分享

二、pcl1.8.1下载与安装

1.下载

github上有可直接下载的PCL版本,根据本文配置版本的pcl已经放置在上步的网盘中。下载后可看到PCL-1.9.0-AllInOne-msvc2017-win64.exe、pcl-1.9.0-pdb-msvc2017-win64.zip这两个文件。

vs2017配置PCL1.8.1_第1张图片

2.安装

安装的步骤按照下述流程来就可以:

vs2017配置PCL1.8.1_第2张图片vs2017配置PCL1.8.1_第3张图片

这里建议选择第二个:“Add PCL to the system PATH for all users”,它可以自动添加系统路径,但是这里我没有成功,安装结束以后可以去环境变量里面查看一下,如果已经自动配置了就可以忽略后面环境变量的添加,如果和我一样的画,可以参照我的步骤进行;

vs2017配置PCL1.8.1_第4张图片

这里我选择了这个路径下,可以自定义;

vs2017配置PCL1.8.1_第5张图片

 vs2017配置PCL1.8.1_第6张图片

 这里选择第三方库的画话,可以都选上

vs2017配置PCL1.8.1_第7张图片

 vs2017配置PCL1.8.1_第8张图片

 安装到快结束的时候会弹出安装OpenNI的提示,这里我是安装在3rdParty下的OpenNI2目录下面,在进行这步的时候参考别的博主,尽量按照这个路径来;

vs2017配置PCL1.8.1_第9张图片

vs2017配置PCL1.8.1_第10张图片

 vs2017配置PCL1.8.1_第11张图片

 vs2017配置PCL1.8.1_第12张图片

 OpenNI安装完了之后点击确定你会发现PCL要不了几秒钟也就安装成功了,到此安装成功了一大半了:解压“pcl-1.8.1-pdb-msvc2017-win64.zip”,将解压得到的文件夹中的内容添加到你的PCL安装目录中,如下图所示:

vs2017配置PCL1.8.1_第13张图片

 三、vs2107配置pcl

1.系统环境变量

安装的时候选了“Add PCL to the system PATH for all users”并且没有报错的,理论上来说可以跳过这一步,博主提示“路径太长添加失败”还是什么的,需要手动添加一次。
计算机—>属性—>高级系统属性—>高级—>环境变量

 vs2017配置PCL1.8.1_第14张图片

 添加红框里面的8个,找到你自己刚刚安装的目录,然后添加你自己对应的目录。

vs2017配置PCL1.8.1_第15张图片

 2.配置相关目录

2.1新建属性表

打开vs2017建立一个新的项目:

vs2017配置PCL1.8.1_第16张图片

 首先确保编译环境是X64,我这里选择的是Release版本,Debug版本配置只有一步不一样,其他都是一样的,我会在下文中指出。)这里还是推荐使用新建属性表,这样的话你可以配置多个版本,在你需要的时候直接添加对应的属性表就可以了,如果你全添加在自带的属性表中的话,当你以后添加的版本太多或者添加的其他库太多会导致灾难性的后果:配置属性冲突等…

vs2017配置PCL1.8.1_第17张图片

 新建项目后可以没有出现属性管理器,按照下图方式打开并新建属性表:

vs2017配置PCL1.8.1_第18张图片

 vs2017配置PCL1.8.1_第19张图片

 2.2 设置包含目录、库目录等

通用属性—>VC++目录—>包含目录中添加红框中的7个目录(读者注意检查自己的目录是否正确):

vs2017配置PCL1.8.1_第20张图片

 然后是添加库目录,在通用属性—>VC++目录—>库目录中添加如下6个目录:

vs2017配置PCL1.8.1_第21张图片

 在C/C++—>预处理器—>预处理器定义中添加:

_CRT_SECURE_NO_WARNINGS
_SCL_SECURE_NO_WARNINGS
_SILENCE_FPOS_SEEKPOS_DEPRECATION_WARNING

vs2017配置PCL1.8.1_第22张图片

 将C/C++—>所有选项—>SDL检查改为否

vs2017配置PCL1.8.1_第23张图片

 最后,也是最麻烦的一个:在通用属性—>链接器—>输入—>附加的依赖项中添加对应的.“lib”文件,主要是添加PCL的“.lib”文件和第三方库中VTK的“.lib”文件。


vs2017配置PCL1.8.1_第24张图片

 这是release版本对应的链接库列表:

注意VTK的版本,在你的路径:…PCL1.8.1\PCL 1.8.1\3rdParty\VTK\lib 中查看自己VTK的版本。我这里的VTK版本是1.8.0

pcl_common_release.lib
pcl_features_release.lib
pcl_filters_release.lib
pcl_io_ply_release.lib
pcl_io_release.lib
pcl_kdtree_release.lib
pcl_keypoints_release.lib
pcl_ml_release.lib
pcl_octree_release.lib
pcl_outofcore_release.lib
pcl_people_release.lib
pcl_recognition_release.lib
pcl_registration_release.lib
pcl_sample_consensus_release.lib
pcl_search_release.lib
pcl_segmentation_release.lib
pcl_stereo_release.lib
pcl_surface_release.lib
pcl_tracking_release.lib
pcl_visualization_release.lib
vtkalglib-8.0.lib
vtkChartsCore-8.0.lib
vtkCommonColor-8.0.lib
vtkCommonComputationalGeometry-8.0.lib
vtkCommonCore-8.0.lib
vtkCommonDataModel-8.0.lib
vtkCommonExecutionModel-8.0.lib
vtkCommonMath-8.0.lib
vtkCommonMisc-8.0.lib
vtkCommonSystem-8.0.lib
vtkCommonTransforms-8.0.lib
vtkDICOMParser-8.0.lib
vtkDomainsChemistry-8.0.lib
vtkexoIIc-8.0.lib
vtkexpat-8.0.lib
vtkFiltersAMR-8.0.lib
vtkFiltersCore-8.0.lib
vtkFiltersExtraction-8.0.lib
vtkFiltersFlowPaths-8.0.lib
vtkFiltersGeneral-8.0.lib
vtkFiltersGeneric-8.0.lib
vtkFiltersGeometry-8.0.lib
vtkFiltersHybrid-8.0.lib
vtkFiltersHyperTree-8.0.lib
vtkFiltersImaging-8.0.lib
vtkFiltersModeling-8.0.lib
vtkFiltersParallel-8.0.lib
vtkFiltersParallelImaging-8.0.lib
vtkFiltersPoints-8.0.lib
vtkFiltersProgrammable-8.0.lib
vtkFiltersSelection-8.0.lib
vtkFiltersSMP-8.0.lib
vtkFiltersSources-8.0.lib
vtkFiltersStatistics-8.0.lib
vtkFiltersTexture-8.0.lib
vtkFiltersTopology-8.0.lib
vtkFiltersVerdict-8.0.lib
vtkfreetype-8.0.lib
vtkGeovisCore-8.0.lib
vtkgl2ps-8.0.lib
vtkhdf5-8.0.lib
vtkhdf5_hl-8.0.lib
vtkImagingColor-8.0.lib
vtkImagingCore-8.0.lib
vtkImagingFourier-8.0.lib
vtkImagingGeneral-8.0.lib
vtkImagingHybrid-8.0.lib
vtkImagingMath-8.0.lib
vtkImagingMorphological-8.0.lib
vtkImagingSources-8.0.lib
vtkImagingStatistics-8.0.lib
vtkImagingStencil-8.0.lib
vtkInfovisCore-8.0.lib
vtkInfovisLayout-8.0.lib
vtkInteractionImage-8.0.lib
vtkInteractionStyle-8.0.lib
vtkInteractionWidgets-8.0.lib
vtkIOAMR-8.0.lib
vtkIOCore-8.0.lib
vtkIOEnSight-8.0.lib
vtkIOExodus-8.0.lib
vtkIOExport-8.0.lib
vtkIOExportOpenGL-8.0.lib
vtkIOGeometry-8.0.lib
vtkIOImage-8.0.lib
vtkIOImport-8.0.lib
vtkIOInfovis-8.0.lib
vtkIOLegacy-8.0.lib
vtkIOLSDyna-8.0.lib
vtkIOMINC-8.0.lib
vtkIOMovie-8.0.lib
vtkIONetCDF-8.0.lib
vtkIOParallel-8.0.lib
vtkIOParallelXML-8.0.lib
vtkIOPLY-8.0.lib
vtkIOSQL-8.0.lib
vtkIOTecplotTable-8.0.lib
vtkIOVideo-8.0.lib
vtkIOXML-8.0.lib
vtkIOXMLParser-8.0.lib
vtkjpeg-8.0.lib
vtkjsoncpp-8.0.lib
vtklibharu-8.0.lib
vtklibxml2-8.0.lib
vtklz4-8.0.lib
vtkmetaio-8.0.lib
vtkNetCDF-8.0.lib
vtkoggtheora-8.0.lib
vtkParallelCore-8.0.lib
vtkpng-8.0.lib
vtkproj4-8.0.lib
vtkRenderingAnnotation-8.0.lib
vtkRenderingContext2D-8.0.lib
vtkRenderingContextOpenGL-8.0.lib
vtkRenderingCore-8.0.lib
vtkRenderingFreeType-8.0.lib
vtkRenderingGL2PS-8.0.lib
vtkRenderingImage-8.0.lib
vtkRenderingLabel-8.0.lib
vtkRenderingLIC-8.0.lib
vtkRenderingLOD-8.0.lib
vtkRenderingOpenGL-8.0.lib
vtkRenderingVolume-8.0.lib
vtkRenderingVolumeOpenGL-8.0.lib
vtksqlite-8.0.lib
vtksys-8.0.lib
vtktiff-8.0.lib
vtkverdict-8.0.lib
vtkViewsContext2D-8.0.lib
vtkViewsCore-8.0.lib
vtkViewsInfovis-8.0.lib
vtkzlib-8.0.lib

这个Debug版本:注意VTK的版本

Debug版本:注意VTK的版本
pcl_common_debug.lib
pcl_features_debug.lib
pcl_filters_debug.lib
pcl_io_debug.lib
pcl_io_ply_debug.lib
pcl_kdtree_debug.lib
pcl_keypoints_debug.lib
pcl_ml_debug.lib
pcl_octree_debug.lib
pcl_outofcore_debug.lib
pcl_people_debug.lib
pcl_recognition_debug.lib
pcl_registration_debug.lib
pcl_sample_consensus_debug.lib
pcl_search_debug.lib
pcl_segmentation_debug.lib
pcl_stereo_debug.lib
pcl_surface_debug.lib
pcl_tracking_debug.lib
pcl_visualization_debug.lib
vtkalglib-8.0-gd.lib
vtkChartsCore-8.0-gd.lib
vtkCommonColor-8.0-gd.lib
vtkCommonComputationalGeometry-8.0-gd.lib
vtkCommonCore-8.0-gd.lib
vtkCommonDataModel-8.0-gd.lib
vtkCommonExecutionModel-8.0-gd.lib
vtkCommonMath-8.0-gd.lib
vtkCommonMisc-8.0-gd.lib
vtkCommonSystem-8.0-gd.lib
vtkCommonTransforms-8.0-gd.lib
vtkDICOMParser-8.0-gd.lib
vtkDomainsChemistry-8.0-gd.lib
vtkexoIIc-8.0-gd.lib
vtkexpat-8.0-gd.lib
vtkFiltersAMR-8.0-gd.lib
vtkFiltersCore-8.0-gd.lib
vtkFiltersExtraction-8.0-gd.lib
vtkFiltersFlowPaths-8.0-gd.lib
vtkFiltersGeneral-8.0-gd.lib
vtkFiltersGeneric-8.0-gd.lib
vtkFiltersGeometry-8.0-gd.lib
vtkFiltersHybrid-8.0-gd.lib
vtkFiltersHyperTree-8.0-gd.lib
vtkFiltersImaging-8.0-gd.lib
vtkFiltersModeling-8.0-gd.lib
vtkFiltersParallel-8.0-gd.lib
vtkFiltersParallelImaging-8.0-gd.lib
vtkFiltersPoints-8.0-gd.lib
vtkFiltersProgrammable-8.0-gd.lib
vtkFiltersSelection-8.0-gd.lib
vtkFiltersSMP-8.0-gd.lib
vtkFiltersSources-8.0-gd.lib
vtkFiltersStatistics-8.0-gd.lib
vtkFiltersTexture-8.0-gd.lib
vtkFiltersTopology-8.0-gd.lib
vtkFiltersVerdict-8.0-gd.lib
vtkfreetype-8.0-gd.lib
vtkGeovisCore-8.0-gd.lib
vtkgl2ps-8.0-gd.lib
vtkhdf5-8.0-gd.lib
vtkhdf5_hl-8.0-gd.lib
vtkImagingColor-8.0-gd.lib
vtkImagingCore-8.0-gd.lib
vtkImagingFourier-8.0-gd.lib
vtkImagingGeneral-8.0-gd.lib
vtkImagingHybrid-8.0-gd.lib
vtkImagingMath-8.0-gd.lib
vtkImagingMorphological-8.0-gd.lib
vtkImagingSources-8.0-gd.lib
vtkImagingStatistics-8.0-gd.lib
vtkImagingStencil-8.0-gd.lib
vtkInfovisCore-8.0-gd.lib
vtkInfovisLayout-8.0-gd.lib
vtkInteractionImage-8.0-gd.lib
vtkInteractionStyle-8.0-gd.lib
vtkInteractionWidgets-8.0-gd.lib
vtkIOAMR-8.0-gd.lib
vtkIOCore-8.0-gd.lib
vtkIOEnSight-8.0-gd.lib
vtkIOExodus-8.0-gd.lib
vtkIOExport-8.0-gd.lib
vtkIOExportOpenGL-8.0-gd.lib
vtkIOGeometry-8.0-gd.lib
vtkIOImage-8.0-gd.lib
vtkIOImport-8.0-gd.lib
vtkIOInfovis-8.0-gd.lib
vtkIOLegacy-8.0-gd.lib
vtkIOLSDyna-8.0-gd.lib
vtkIOMINC-8.0-gd.lib
vtkIOMovie-8.0-gd.lib
vtkIONetCDF-8.0-gd.lib
vtkIOParallel-8.0-gd.lib
vtkIOParallelXML-8.0-gd.lib
vtkIOPLY-8.0-gd.lib
vtkIOSQL-8.0-gd.lib
vtkIOTecplotTable-8.0-gd.lib
vtkIOVideo-8.0-gd.lib
vtkIOXML-8.0-gd.lib
vtkIOXMLParser-8.0-gd.lib
vtkjpeg-8.0-gd.lib
vtkjsoncpp-8.0-gd.lib
vtklibharu-8.0-gd.lib
vtklibxml2-8.0-gd.lib
vtklz4-8.0-gd.lib
vtkmetaio-8.0-gd.lib
vtkNetCDF-8.0-gd.lib
vtknetcdfcpp-8.0-gd.lib
vtkoggtheora-8.0-gd.lib
vtkParallelCore-8.0-gd.lib
vtkpng-8.0-gd.lib
vtkproj4-8.0-gd.lib
vtkRenderingAnnotation-8.0-gd.lib
vtkRenderingContext2D-8.0-gd.lib
vtkRenderingContextOpenGL-8.0-gd.lib
vtkRenderingCore-8.0-gd.lib
vtkRenderingFreeType-8.0-gd.lib
vtkRenderingGL2PS-8.0-gd.lib
vtkRenderingImage-8.0-gd.lib
vtkRenderingLabel-8.0-gd.lib
vtkRenderingLIC-8.0-gd.lib
vtkRenderingLOD-8.0-gd.lib
vtkRenderingOpenGL-8.0-gd.lib
vtkRenderingVolume-8.0-gd.lib
vtkRenderingVolumeOpenGL-8.0-gd.lib
vtksqlite-8.0-gd.lib
vtksys-8.0-gd.lib
vtktiff-8.0-gd.lib
vtkverdict-8.0-gd.lib
vtkViewsContext2D-8.0-gd.lib
vtkViewsCore-8.0-gd.lib
vtkViewsInfovis-8.0-gd.lib
vtkzlib-8.0-gd.lib

2.3测试

其中点云的数据保存在“test.txt“中,在工程目录中新建一个txt文档,添加:(这个代码是我参照某个博主的)

-3.03387	-3.03879	-2.05533
-3.03776	-3.03882	-2.05536
-3.04165	-3.03886	-2.05538
-3.04554	-3.0389	    -2.05541
-3.04943	-3.03894	-2.05543
-3.05332	-3.03897	-2.05546
-3.05721	-3.03901	-2.05548
-3.0611	    -3.03905	-2.05551
-3.06499	-3.03908	-2.05553
-3.06888	-3.03912	-2.05556
-3.07277	-3.03916	-2.05558
-3.07666	-3.03919	-2.05561
-3.08055	-3.03923	-2.05563
-3.08444	-3.03927	-2.05566
-3.08833	-3.03931	-2.05568
-3.09222	-3.03934	-2.05571
-3.09612	-3.03938	-2.05573
-3.10001	-3.03942	-2.05576
-3.1039	    -3.03945	-2.05578
-3.10779	-3.03949	-2.05581
-3.11168	-3.03953	-2.05583
-3.11557	-3.03956	-2.05586
-3.11947	-3.0396	    -2.05588
-3.12336	-3.03964	-2.05591
-3.12725	-3.03968	-2.05593
-3.13114	-3.03971	-2.05596
-3.13503	-3.03975	-2.05598
-3.13893	-3.03979	-2.05601
-3.14282	-3.03982	-2.05603
-3.14671	-3.03986	-2.05606
-3.1506	    -3.0399	   -2.05608
-3.1545  	-3.03993	-2.05611
-3.15839	-3.03997	-2.05613
-3.16228	-3.04001	-2.05616
-3.16618	-3.04005	-2.05618
-3.17007	-3.04008	-2.05621
-3.17396	-3.04012	-2.05623
-3.17786	-3.04016	-2.05626
-3.18175	-3.04019	-2.05628
-3.18564	-3.04023	-2.05631
-3.18954	-3.04027	-2.05633
-3.19343	-3.0403	    -2.05636
-3.19732	-3.04034	-2.05638
-3.20122	-3.04038	-2.05641
-3.20511	-3.04042	-2.05643
-3.20901	-3.04045	-2.05646
-3.2129	    -3.04049    -2.05648
-3.21679	-3.04053	-2.05651
-3.22069	-3.04056	-2.05653
-3.22458	-3.0406	    -2.05656
-3.22848	-3.04064	-2.05658
-3.23237	-3.04068	-2.05661
-3.23627	-3.04071	-2.05663
-3.24016	-3.04075	-2.05666
-3.24406	-3.04079	-2.05668
-3.24795	-3.04082	-2.05671
-3.25185	-3.04086	-2.05673
-3.25574	-3.0409	   -2.05676
-3.25964	-3.04093	-2.05678
-3.26353	-3.04097	-2.05681
-3.26743	-3.04101	-2.05683
-3.27132	-3.04105	-2.05686
-3.27522	-3.04108	-2.05688
-3.27912	-3.04112	-2.05691
-3.28301	-3.04116	-2.05693
-3.28691	-3.04119	-2.05696
-3.2908	   -3.04123	    -2.05698
-3.2947  	-3.0412    -2.05701
-3.2986  	-3.0413	     -2.05703
-3.30249	-3.04134	-2.05706
-3.30639	-3.04138	-2.05708
-3.31029	-3.04142	-2.05711
-3.31418	-3.04145	-2.05713
-3.31808	-3.04149	-2.05716
-3.32198	-3.04153	-2.05718
-3.32587	-3.04156	-2.05721
-3.32977	-3.0416	   -2.05723
-3.33367	-3.04164	-2.05726
-3.33756	-3.04168	-2.05728
-3.34146	-3.04171	-2.05731
-3.34536	-3.04175	-2.05733
-3.34926	-3.04179	-2.05736
-3.35315	-3.04182	-2.05738
-3.35705	-3.04186	-2.05741
-3.36095	-3.0419	    -2.05743
-3.36485	-3.04193	-2.05746
-3.36874	-3.04197	-2.05748
-3.37264	-3.04201	-2.05751
-3.37654	-3.04205	-2.05753
-3.38044	-3.04208	-2.05756
-3.38434	-3.04212	-2.05758
-3.38824	-3.04216	-2.05761
-3.39213	-3.04219	-2.05764

新建一个main.cpp,代码如下:

#include 
#include //标准C++库中的输入输出类相关头文件。
#include 
#include //pcd 读写类相关的头文件。
#include 
#include  //PCL中支持的点类型头文件。
#include  
#include   
#include  

using namespace std;

int main()
{
	typedef struct tagPOINT_3D
	{
		double x;  //mm world coordinate x  
		double y;  //mm world coordinate y  
		double z;  //mm world coordinate z  
		double r;
	}POINT_WORLD;


	//加载txt数据  
	int number_Txt;
	FILE *fp_txt;
	tagPOINT_3D TxtPoint;
	vector m_vTxtPoints;
	fp_txt = fopen("shuju.txt", "r");
	if (fp_txt)
	{
		while (fscanf(fp_txt, "%lf %lf %lf", &TxtPoint.x, &TxtPoint.y, &TxtPoint.z) != EOF)
		{
			m_vTxtPoints.push_back(TxtPoint);
		}
	}
	else
		cout << "txt数据加载失败!" << endl;
	number_Txt = m_vTxtPoints.size();
	//pcl::PointCloud cloud;
	
	pcl::PointCloud::Ptr cloud(new pcl::PointCloud);
	// Fill in the cloud data  
	cloud->width = number_Txt;
	cloud->height = 1;
	cloud->is_dense = false;
	cloud->points.resize(cloud->width * cloud->height);
	for (size_t i = 0; i < cloud->points.size(); ++i)
	{
		cloud->points[i].x = m_vTxtPoints[i].x;
		cloud->points[i].y = m_vTxtPoints[i].y;
		cloud->points[i].z = m_vTxtPoints[i].z;
	}
	pcl::io::savePCDFileASCII("txt2pcd_bunny1.pcd", *cloud);
	std::cerr << "Saved " << cloud->points.size() << " data points to txt2pcd.pcd." << 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;

	//PCL Visualizer
	// Viewer  
	pcl::visualization::PCLVisualizer viewer("Cloud Viewer");
	viewer.addPointCloud(cloud);
	viewer.setBackgroundColor(0, 0, 0);

	viewer.spin();
	system("pause");
	return 0;

}

最后得到运行结果如下图所示:

vs2017配置PCL1.8.1_第25张图片


总结

以上就是配置的完整过程。

你可能感兴趣的:(开发语言,c++)