目录
1、安装vs2019
访问官网:https://visualstudio.microsoft.com/zh-hans/vs/
下载community2019,下载下来文件名为:vs_community__728649195.1582080497.exe
运行exe,安装Visual Studio Community 2019,勾选
开始安装,需要下载很多东西,内心等待,安装好了重启电脑,可以打开vs2019即安装完毕;
2、安装PCL1.11.1
访问PCL包下载页面: https://github.com/PointCloudLibrary/pcl/releases
下载最新版本 PCL-1.11.1-AllInOne-msvc2019-win64.exe
双击exe运行,按照默认选项安装,主要包括安装所有第三方库和添加PCL的环境变量;
一直点击下一步,运行无错误即安装完成;
3、建立第一个PCL项目
新建vs项目,打开vs2019,点击文件->新建,选择控制台应用(C++,windows);
填写项目名称,和保存项目路径,点击创建即可;
开始PCL项目配置以x64项目,release为例进行配置,debug版本类似需要这些配置文件的debug版本:
打开项目 属性管理器,在 Release | x64 添加一个pcl属性文件(其它名字也可以),如下图,方便在其它与PCL相关的项目中使用相同配置,因为配置项目比较多:
双击PCL,弹出pcl属性页如下,在这里配置包含目录和库目录:
(1)包含目录
主要需要添加 PCL的头文件,以及PCL需要的第三方库的头文件目录。
假如安装pcl的位置为 D:Program Files\PCL 1.11.1,包含目录配置如下:
(2)库目录
主要需要添加 PCL的库文件,以及PCL需要的第三方库的库文件目录。
假如安装pcl的位置为 D:Program Files\PCL 1.11.1,包含目录配置如下,这里要注意的是OpenNI2这个默认安装到C盘了,所以添加目录的时候要去找到这个库:
(3)预处理器设置
主要为了屏蔽一些警告,C/C++ 预处理器,添加下面三项:
_CRT_SECURE_NO_WARNINGS
_SCL_SECURE_NO_WARNINGS
_SILENCE_FPOS_SEEKPOS_DEPRECATION_WARNING
如下:
(4)附加依赖项
最好是添加所有库文件目录下所有lib文件的名称,本文相同配置对应的附加依赖项列表在文章末尾附件部分,往下拉,然后复制粘贴;
如何得到自己的附加依赖项?参考文章:https://blog.csdn.net/weixin_41991128/article/details/83864713,感谢这位作者!!!点赞。
win+r调出“运行”窗口并输出cmd
输入:cd /d D:\P_pcl\PCL1.9.0\PCL 1.9.0\3rdParty\VTK\lib (填自己的路径)回车
输入:dir /b *.lib *>0.txt 回车
然后从0.txt中,复制lib列表,对每一个库目录都是这样操作得到列表拼接起来得到所有的附加依赖项。
(5)dll文件配置
右击项目名称,点击属性,来到项目属性页,点击环境,输入:PATH=$(PCL_ROOT)\bin;$(PCL_ROOT)\3rdParty\FLANN\bin;$(PCL_ROOT)\3rdParty\VTK\bin;$(PCL_ROOT)\Qhull\bin;C:\Program Files\OpenNI2\Tools;$(PATH)
(6)平台工具集确认
保证平台数据集为v142,从而保证程序正常编译运行
(7)跑一个例子确认安装成功
复制下面代码到main.cpp 文件中,运行出结果即可成功:(当然只是为了验证一下环境正确,只是一个例子)
#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL2);
VTK_MODULE_INIT(vtkInteractionStyle);
VTK_MODULE_INIT(vtkRenderingFreeType);
#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.0f, 0.5f, 1.0f);
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);//this is to set the coordination of text "Once per viewer loop:"
//FIXME : possible race condition here
user_data++;
}
int
main()
{
pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZRGBA>);
pcl::io::loadPCDFile("maize.pcd", *cloud);
pcl::visualization::CloudViewer viewer("Cloud Viewer");
//showCloud 函数是同步的,在此处等待直到渲染显示为止
viewer.showCloud(cloud);
//该注册函数在可视化时只调用一次
viewer.runOnVisualizationThreadOnce(viewerOneOff);
//该注册函数在渲染输出是每次都调用
viewer.runOnVisualizationThread(viewerPsycho);
while (!viewer.wasStopped())
{
//在此处可以添加其他处理
user_data++;
}
return 0;
}
5、附件
(1)附加依赖项列表
需要注意_d后缀的是debug下的配置,最好不要在release中配置,否则会出现很多异常,这是因为调用库的时候是按照顺序来调,debug库的名称写在release库的前面会默认调用debug库。
libboost_atomic-vc142-mt-gd-x64-1_74.lib
libboost_atomic-vc142-mt-x64-1_74.lib
libboost_bzip2-vc142-mt-gd-x64-1_74.lib
libboost_bzip2-vc142-mt-x64-1_74.lib
libboost_chrono-vc142-mt-gd-x64-1_74.lib
libboost_chrono-vc142-mt-x64-1_74.lib
libboost_container-vc142-mt-gd-x64-1_74.lib
libboost_container-vc142-mt-x64-1_74.lib
libboost_context-vc142-mt-gd-x64-1_74.lib
libboost_context-vc142-mt-x64-1_74.lib
libboost_contract-vc142-mt-gd-x64-1_74.lib
libboost_contract-vc142-mt-x64-1_74.lib
libboost_coroutine-vc142-mt-gd-x64-1_74.lib
libboost_coroutine-vc142-mt-x64-1_74.lib
libboost_date_time-vc142-mt-gd-x64-1_74.lib
libboost_date_time-vc142-mt-x64-1_74.lib
libboost_exception-vc142-mt-gd-x64-1_74.lib
libboost_exception-vc142-mt-x64-1_74.lib
libboost_fiber-vc142-mt-gd-x64-1_74.lib
libboost_fiber-vc142-mt-x64-1_74.lib
libboost_filesystem-vc142-mt-gd-x64-1_74.lib
libboost_filesystem-vc142-mt-x64-1_74.lib
libboost_graph-vc142-mt-gd-x64-1_74.lib
libboost_graph-vc142-mt-x64-1_74.lib
libboost_graph_parallel-vc142-mt-gd-x64-1_74.lib
libboost_graph_parallel-vc142-mt-x64-1_74.lib
libboost_iostreams-vc142-mt-gd-x64-1_74.lib
libboost_iostreams-vc142-mt-x64-1_74.lib
libboost_locale-vc142-mt-gd-x64-1_74.lib
libboost_locale-vc142-mt-x64-1_74.lib
libboost_log-vc142-mt-gd-x64-1_74.lib
libboost_log-vc142-mt-x64-1_74.lib
libboost_log_setup-vc142-mt-gd-x64-1_74.lib
libboost_log_setup-vc142-mt-x64-1_74.lib
libboost_math_c99-vc142-mt-gd-x64-1_74.lib
libboost_math_c99-vc142-mt-x64-1_74.lib
libboost_math_c99f-vc142-mt-gd-x64-1_74.lib
libboost_math_c99f-vc142-mt-x64-1_74.lib
libboost_math_c99l-vc142-mt-gd-x64-1_74.lib
libboost_math_c99l-vc142-mt-x64-1_74.lib
libboost_math_tr1-vc142-mt-gd-x64-1_74.lib
libboost_math_tr1-vc142-mt-x64-1_74.lib
libboost_math_tr1f-vc142-mt-gd-x64-1_74.lib
libboost_math_tr1f-vc142-mt-x64-1_74.lib
libboost_math_tr1l-vc142-mt-gd-x64-1_74.lib
libboost_math_tr1l-vc142-mt-x64-1_74.lib
libboost_mpi-vc142-mt-gd-x64-1_74.lib
libboost_mpi-vc142-mt-x64-1_74.lib
libboost_nowide-vc142-mt-gd-x64-1_74.lib
libboost_nowide-vc142-mt-x64-1_74.lib
libboost_numpy38-vc142-mt-gd-x64-1_74.lib
libboost_numpy38-vc142-mt-x64-1_74.lib
libboost_prg_exec_monitor-vc142-mt-gd-x64-1_74.lib
libboost_prg_exec_monitor-vc142-mt-x64-1_74.lib
libboost_program_options-vc142-mt-gd-x64-1_74.lib
libboost_program_options-vc142-mt-x64-1_74.lib
libboost_python38-vc142-mt-gd-x64-1_74.lib
libboost_python38-vc142-mt-x64-1_74.lib
libboost_random-vc142-mt-gd-x64-1_74.lib
libboost_random-vc142-mt-x64-1_74.lib
libboost_regex-vc142-mt-gd-x64-1_74.lib
libboost_regex-vc142-mt-x64-1_74.lib
libboost_serialization-vc142-mt-gd-x64-1_74.lib
libboost_serialization-vc142-mt-x64-1_74.lib
libboost_stacktrace_noop-vc142-mt-gd-x64-1_74.lib
libboost_stacktrace_noop-vc142-mt-x64-1_74.lib
libboost_stacktrace_windbg-vc142-mt-gd-x64-1_74.lib
libboost_stacktrace_windbg-vc142-mt-x64-1_74.lib
libboost_stacktrace_windbg_cached-vc142-mt-gd-x64-1_74.lib
libboost_stacktrace_windbg_cached-vc142-mt-x64-1_74.lib
libboost_system-vc142-mt-gd-x64-1_74.lib
libboost_system-vc142-mt-x64-1_74.lib
libboost_test_exec_monitor-vc142-mt-gd-x64-1_74.lib
libboost_test_exec_monitor-vc142-mt-x64-1_74.lib
libboost_thread-vc142-mt-gd-x64-1_74.lib
libboost_thread-vc142-mt-x64-1_74.lib
libboost_timer-vc142-mt-gd-x64-1_74.lib
libboost_timer-vc142-mt-x64-1_74.lib
libboost_type_erasure-vc142-mt-gd-x64-1_74.lib
libboost_type_erasure-vc142-mt-x64-1_74.lib
libboost_unit_test_framework-vc142-mt-gd-x64-1_74.lib
libboost_unit_test_framework-vc142-mt-x64-1_74.lib
libboost_wave-vc142-mt-gd-x64-1_74.lib
libboost_wave-vc142-mt-x64-1_74.lib
libboost_wserialization-vc142-mt-gd-x64-1_74.lib
libboost_wserialization-vc142-mt-x64-1_74.lib
libboost_zlib-vc142-mt-gd-x64-1_74.lib
libboost_zlib-vc142-mt-x64-1_74.lib
flann-gd.lib
flann.lib
flann_cpp-gd.lib
flann_cpp.lib
flann_cpp_s-gd.lib
flann_cpp_s.lib
flann_s-gd.lib
flann_s.lib
qhull.lib
qhullcpp.lib
qhullcpp_d.lib
qhullstatic.lib
qhullstatic_d.lib
qhullstatic_r.lib
qhullstatic_r_d.lib
qhull_d.lib
qhull_p.lib
qhull_p_d.lib
qhull_r.lib
qhull_r_d.lib
vtkChartsCore-8.2-gd.lib
vtkChartsCore-8.2.lib
vtkCommonColor-8.2-gd.lib
vtkCommonColor-8.2.lib
vtkCommonComputationalGeometry-8.2-gd.lib
vtkCommonComputationalGeometry-8.2.lib
vtkCommonCore-8.2-gd.lib
vtkCommonCore-8.2.lib
vtkCommonDataModel-8.2-gd.lib
vtkCommonDataModel-8.2.lib
vtkCommonExecutionModel-8.2-gd.lib
vtkCommonExecutionModel-8.2.lib
vtkCommonMath-8.2-gd.lib
vtkCommonMath-8.2.lib
vtkCommonMisc-8.2-gd.lib
vtkCommonMisc-8.2.lib
vtkCommonSystem-8.2-gd.lib
vtkCommonSystem-8.2.lib
vtkCommonTransforms-8.2-gd.lib
vtkCommonTransforms-8.2.lib
vtkDICOMParser-8.2-gd.lib
vtkDICOMParser-8.2.lib
vtkDomainsChemistry-8.2-gd.lib
vtkDomainsChemistry-8.2.lib
vtkDomainsChemistryOpenGL2-8.2-gd.lib
vtkDomainsChemistryOpenGL2-8.2.lib
vtkdoubleconversion-8.2-gd.lib
vtkdoubleconversion-8.2.lib
vtkexodusII-8.2-gd.lib
vtkexodusII-8.2.lib
vtkexpat-8.2-gd.lib
vtkexpat-8.2.lib
vtkFiltersAMR-8.2-gd.lib
vtkFiltersAMR-8.2.lib
vtkFiltersCore-8.2-gd.lib
vtkFiltersCore-8.2.lib
vtkFiltersExtraction-8.2-gd.lib
vtkFiltersExtraction-8.2.lib
vtkFiltersFlowPaths-8.2-gd.lib
vtkFiltersFlowPaths-8.2.lib
vtkFiltersGeneral-8.2-gd.lib
vtkFiltersGeneral-8.2.lib
vtkFiltersGeneric-8.2-gd.lib
vtkFiltersGeneric-8.2.lib
vtkFiltersGeometry-8.2-gd.lib
vtkFiltersGeometry-8.2.lib
vtkFiltersHybrid-8.2-gd.lib
vtkFiltersHybrid-8.2.lib
vtkFiltersHyperTree-8.2-gd.lib
vtkFiltersHyperTree-8.2.lib
vtkFiltersImaging-8.2-gd.lib
vtkFiltersImaging-8.2.lib
vtkFiltersModeling-8.2-gd.lib
vtkFiltersModeling-8.2.lib
vtkFiltersParallel-8.2-gd.lib
vtkFiltersParallel-8.2.lib
vtkFiltersParallelImaging-8.2-gd.lib
vtkFiltersParallelImaging-8.2.lib
vtkFiltersPoints-8.2-gd.lib
vtkFiltersPoints-8.2.lib
vtkFiltersProgrammable-8.2-gd.lib
vtkFiltersProgrammable-8.2.lib
vtkFiltersSelection-8.2-gd.lib
vtkFiltersSelection-8.2.lib
vtkFiltersSMP-8.2-gd.lib
vtkFiltersSMP-8.2.lib
vtkFiltersSources-8.2-gd.lib
vtkFiltersSources-8.2.lib
vtkFiltersStatistics-8.2-gd.lib
vtkFiltersStatistics-8.2.lib
vtkFiltersTexture-8.2-gd.lib
vtkFiltersTexture-8.2.lib
vtkFiltersTopology-8.2-gd.lib
vtkFiltersTopology-8.2.lib
vtkFiltersVerdict-8.2-gd.lib
vtkFiltersVerdict-8.2.lib
vtkfreetype-8.2-gd.lib
vtkfreetype-8.2.lib
vtkGeovisCore-8.2-gd.lib
vtkGeovisCore-8.2.lib
vtkgl2ps-8.2-gd.lib
vtkgl2ps-8.2.lib
vtkglew-8.2-gd.lib
vtkglew-8.2.lib
vtkGUISupportMFC-8.2-gd.lib
vtkGUISupportMFC-8.2.lib
vtkhdf5-8.2-gd.lib
vtkhdf5-8.2.lib
vtkhdf5_hl-8.2-gd.lib
vtkhdf5_hl-8.2.lib
vtkImagingColor-8.2-gd.lib
vtkImagingColor-8.2.lib
vtkImagingCore-8.2-gd.lib
vtkImagingCore-8.2.lib
vtkImagingFourier-8.2-gd.lib
vtkImagingFourier-8.2.lib
vtkImagingGeneral-8.2-gd.lib
vtkImagingGeneral-8.2.lib
vtkImagingHybrid-8.2-gd.lib
vtkImagingHybrid-8.2.lib
vtkImagingMath-8.2-gd.lib
vtkImagingMath-8.2.lib
vtkImagingMorphological-8.2-gd.lib
vtkImagingMorphological-8.2.lib
vtkImagingSources-8.2-gd.lib
vtkImagingSources-8.2.lib
vtkImagingStatistics-8.2-gd.lib
vtkImagingStatistics-8.2.lib
vtkImagingStencil-8.2-gd.lib
vtkImagingStencil-8.2.lib
vtkInfovisCore-8.2-gd.lib
vtkInfovisCore-8.2.lib
vtkInfovisLayout-8.2-gd.lib
vtkInfovisLayout-8.2.lib
vtkInteractionImage-8.2-gd.lib
vtkInteractionImage-8.2.lib
vtkInteractionStyle-8.2-gd.lib
vtkInteractionStyle-8.2.lib
vtkInteractionWidgets-8.2-gd.lib
vtkInteractionWidgets-8.2.lib
vtkIOAMR-8.2-gd.lib
vtkIOAMR-8.2.lib
vtkIOAsynchronous-8.2-gd.lib
vtkIOAsynchronous-8.2.lib
vtkIOCityGML-8.2-gd.lib
vtkIOCityGML-8.2.lib
vtkIOCore-8.2-gd.lib
vtkIOCore-8.2.lib
vtkIOEnSight-8.2-gd.lib
vtkIOEnSight-8.2.lib
vtkIOExodus-8.2-gd.lib
vtkIOExodus-8.2.lib
vtkIOExport-8.2-gd.lib
vtkIOExport-8.2.lib
vtkIOExportOpenGL2-8.2-gd.lib
vtkIOExportOpenGL2-8.2.lib
vtkIOExportPDF-8.2-gd.lib
vtkIOExportPDF-8.2.lib
vtkIOGeometry-8.2-gd.lib
vtkIOGeometry-8.2.lib
vtkIOImage-8.2-gd.lib
vtkIOImage-8.2.lib
vtkIOImport-8.2-gd.lib
vtkIOImport-8.2.lib
vtkIOInfovis-8.2-gd.lib
vtkIOInfovis-8.2.lib
vtkIOLegacy-8.2-gd.lib
vtkIOLegacy-8.2.lib
vtkIOLSDyna-8.2-gd.lib
vtkIOLSDyna-8.2.lib
vtkIOMINC-8.2-gd.lib
vtkIOMINC-8.2.lib
vtkIOMovie-8.2-gd.lib
vtkIOMovie-8.2.lib
vtkIONetCDF-8.2-gd.lib
vtkIONetCDF-8.2.lib
vtkIOParallel-8.2-gd.lib
vtkIOParallel-8.2.lib
vtkIOParallelXML-8.2-gd.lib
vtkIOParallelXML-8.2.lib
vtkIOPLY-8.2-gd.lib
vtkIOPLY-8.2.lib
vtkIOSegY-8.2-gd.lib
vtkIOSegY-8.2.lib
vtkIOSQL-8.2-gd.lib
vtkIOSQL-8.2.lib
vtkIOTecplotTable-8.2-gd.lib
vtkIOTecplotTable-8.2.lib
vtkIOVeraOut-8.2-gd.lib
vtkIOVeraOut-8.2.lib
vtkIOVideo-8.2-gd.lib
vtkIOVideo-8.2.lib
vtkIOXML-8.2-gd.lib
vtkIOXML-8.2.lib
vtkIOXMLParser-8.2-gd.lib
vtkIOXMLParser-8.2.lib
vtkjpeg-8.2-gd.lib
vtkjpeg-8.2.lib
vtkjsoncpp-8.2-gd.lib
vtkjsoncpp-8.2.lib
vtklibharu-8.2-gd.lib
vtklibharu-8.2.lib
vtklibxml2-8.2-gd.lib
vtklibxml2-8.2.lib
vtklz4-8.2-gd.lib
vtklz4-8.2.lib
vtklzma-8.2-gd.lib
vtklzma-8.2.lib
vtkmetaio-8.2-gd.lib
vtkmetaio-8.2.lib
vtkNetCDF-8.2-gd.lib
vtkNetCDF-8.2.lib
vtkogg-8.2-gd.lib
vtkogg-8.2.lib
vtkParallelCore-8.2-gd.lib
vtkParallelCore-8.2.lib
vtkpng-8.2-gd.lib
vtkpng-8.2.lib
vtkproj-8.2-gd.lib
vtkproj-8.2.lib
vtkpugixml-8.2-gd.lib
vtkpugixml-8.2.lib
vtkRenderingAnnotation-8.2-gd.lib
vtkRenderingAnnotation-8.2.lib
vtkRenderingContext2D-8.2-gd.lib
vtkRenderingContext2D-8.2.lib
vtkRenderingContextOpenGL2-8.2-gd.lib
vtkRenderingContextOpenGL2-8.2.lib
vtkRenderingCore-8.2-gd.lib
vtkRenderingCore-8.2.lib
vtkRenderingExternal-8.2-gd.lib
vtkRenderingExternal-8.2.lib
vtkRenderingFreeType-8.2-gd.lib
vtkRenderingFreeType-8.2.lib
vtkRenderingGL2PSOpenGL2-8.2-gd.lib
vtkRenderingGL2PSOpenGL2-8.2.lib
vtkRenderingImage-8.2-gd.lib
vtkRenderingImage-8.2.lib
vtkRenderingLabel-8.2-gd.lib
vtkRenderingLabel-8.2.lib
vtkRenderingLOD-8.2-gd.lib
vtkRenderingLOD-8.2.lib
vtkRenderingOpenGL2-8.2-gd.lib
vtkRenderingOpenGL2-8.2.lib
vtkRenderingVolume-8.2-gd.lib
vtkRenderingVolume-8.2.lib
vtkRenderingVolumeOpenGL2-8.2-gd.lib
vtkRenderingVolumeOpenGL2-8.2.lib
vtksqlite-8.2-gd.lib
vtksqlite-8.2.lib
vtksys-8.2-gd.lib
vtksys-8.2.lib
vtktheora-8.2-gd.lib
vtktheora-8.2.lib
vtktiff-8.2-gd.lib
vtktiff-8.2.lib
vtkverdict-8.2-gd.lib
vtkverdict-8.2.lib
vtkViewsContext2D-8.2-gd.lib
vtkViewsContext2D-8.2.lib
vtkViewsCore-8.2-gd.lib
vtkViewsCore-8.2.lib
vtkViewsInfovis-8.2-gd.lib
vtkViewsInfovis-8.2.lib
vtkzlib-8.2-gd.lib
vtkzlib-8.2.lib
OpenNI2.lib
pcl_recognitiond.lib
pcl_registration.lib
pcl_registrationd.lib
pcl_sample_consensus.lib
pcl_sample_consensusd.lib
pcl_search.lib
pcl_searchd.lib
pcl_segmentation.lib
pcl_segmentationd.lib
pcl_stereo.lib
pcl_stereod.lib
pcl_surface.lib
pcl_surfaced.lib
pcl_tracking.lib
pcl_trackingd.lib
pcl_visualization.lib
pcl_visualizationd.lib
pcl_common.lib
pcl_commond.lib
pcl_features.lib
pcl_featuresd.lib
pcl_filters.lib
pcl_filtersd.lib
pcl_io.lib
pcl_iod.lib
pcl_io_ply.lib
pcl_io_plyd.lib
pcl_kdtree.lib
pcl_kdtreed.lib
pcl_keypoints.lib
pcl_keypointsd.lib
pcl_ml.lib
pcl_mld.lib
pcl_octree.lib
pcl_octreed.lib
pcl_outofcore.lib
pcl_outofcored.lib
pcl_people.lib
pcl_peopled.lib
pcl_recognition.lib