一、pcl下载
下载地址为:https://github.com/PointCloudLibrary/pcl/releases
下载过程中一定要注意vs版本和pcl版本是否对应。本次是vs2019版本配置1.12版本的点云库。
接下来无脑进行安装。
(注意:1、添加PCL到系统PATH。2、建议安装到非系统盘。3、安装路径全英文。)
1.pcl安装
2.pdb文件配置
在pcl安装完成后,需要将pcl-1.12.0-rc1-pdb-msvc2019-win64.zip解压,将.pdb文件拷贝到pcl\bin目录下。
至此pcl安装结束,接下来需要环境配置了。
二、系统环境配置
添加的路径主要有八个
D:\PCL\3rdParty\OpenNI2\Lib D:\PCL\3rdParty\OpenNI2\Redist D:\PCL\3rdParty\OpenNI2\Tools D:\PCL\bin D:\PCL\3rdParty\Boost\lib D:\PCL\3rdParty\FLANN\bin D:\PCL\3rdParty\Qhull\bin D:\PCL\3rdParty\VTK\bin
点击确定后,系统环境就配置完成了。
三、vs环境配置
在属性管理器中新建一个属性表,要区分好平台是x64(64位)还是x86(32位),同时也要分清楚你配置的是debug还release。接下来以debug为例进行配置。
第一步,配置包含目录
包含目录如下:
D:\PCL\include\pcl-1.12 D:\PCL\3rdParty\Boost\include\boost-1_76 D:\PCL\3rdParty\Eigen\eigen3 D:\PCL\3rdParty\FLANN\include D:\PCL\3rdParty\Qhull\include D:\PCL\3rdParty\VTK\include\vtk-9.0 D:\PCL\3rdParty\OpenNI2\Include
库目录如下:
D:\PCL\lib D:\PCL\3rdParty\Boost\lib D:\PCL\3rdParty\FLANN\lib D:\PCL\3rdParty\OpenNI2\Lib D:\PCL\3rdParty\Qhull\lib D:\PCL\3rdParty\VTK\lib
预处理器配置:
_CRT_SECURE_NO_WARNINGS _SCL_SECURE_NO_WARNINGS _SILENCE_FPOS_SEEKPOS_DEPRECATION_WARNING _CRT_NONSTDC_NO_DEPRECATE BOOST_USE_WINDOWS_H NOMINMAX _CRT_SECURE_NO_DEPRECATE
C++=》所有选项=》SDL检查 设置为否
附加依赖项配置,一定要小心
这个是依次将刚才库目录下的lib文件名全部提取出来
由于文件夹下文件很多,可以通过代码快速获取
@echo off for %%I in (*.lib) do echo %%I>>all.txt for %%I in (*d.lib) do echo %%I>>adebug.txt for %%I in (*9.0.lib) do echo %%I>>arelease.txt pause
在对应文件夹下新建txt文件,将上述代码复制进去后,将txt文件后缀名改为bat,运行即可生成包含文件名的txt文件。
还有一种方法是在控制台中输入指令
win+r调出运行窗口,并输入cmd 输入:cd /d C:\Program Files\PCL 1.12.0\3rdParty\VTK\lib 输入:dir /b *.lib *>VTK_lib.txt 输入:cd /d C:\Program Files\PCL 1.12.0\lib 输入:dir /b *.lib *>PCL_lib.txt
该方法也可以在文件夹下新建txt,然后将命令行复制进去后,将txt文件后缀改为bat。
依次运行后debug附加依赖项为:
pcl_commond.lib pcl_featuresd.lib pcl_filtersd.lib pcl_iod.lib pcl_io_plyd.lib pcl_kdtreed.lib pcl_keypointsd.lib pcl_mld.lib pcl_octreed.lib pcl_outofcored.lib pcl_peopled.lib pcl_recognitiond.lib pcl_registrationd.lib pcl_sample_consensusd.lib pcl_searchd.lib pcl_segmentationd.lib pcl_stereod.lib pcl_surfaced.lib pcl_trackingd.lib pcl_visualizationd.lib libboost_atomic-vc142-mt-gd-x64-1_76.lib libboost_bzip2-vc142-mt-gd-x64-1_76.lib libboost_chrono-vc142-mt-gd-x64-1_76.lib libboost_container-vc142-mt-gd-x64-1_76.lib libboost_context-vc142-mt-gd-x64-1_76.lib libboost_contract-vc142-mt-gd-x64-1_76.lib libboost_coroutine-vc142-mt-gd-x64-1_76.lib libboost_date_time-vc142-mt-gd-x64-1_76.lib libboost_exception-vc142-mt-gd-x64-1_76.lib libboost_fiber-vc142-mt-gd-x64-1_76.lib libboost_filesystem-vc142-mt-gd-x64-1_76.lib libboost_graph-vc142-mt-gd-x64-1_76.lib libboost_graph_parallel-vc142-mt-gd-x64-1_76.lib libboost_iostreams-vc142-mt-gd-x64-1_76.lib libboost_json-vc142-mt-gd-x64-1_76.lib libboost_locale-vc142-mt-gd-x64-1_76.lib libboost_log-vc142-mt-gd-x64-1_76.lib libboost_log_setup-vc142-mt-gd-x64-1_76.lib libboost_math_c99-vc142-mt-gd-x64-1_76.lib libboost_math_c99f-vc142-mt-gd-x64-1_76.lib libboost_math_c99l-vc142-mt-gd-x64-1_76.lib libboost_math_tr1-vc142-mt-gd-x64-1_76.lib libboost_math_tr1f-vc142-mt-gd-x64-1_76.lib libboost_math_tr1l-vc142-mt-gd-x64-1_76.lib libboost_mpi-vc142-mt-gd-x64-1_76.lib libboost_nowide-vc142-mt-gd-x64-1_76.lib libboost_numpy38-vc142-mt-gd-x64-1_76.lib libboost_prg_exec_monitor-vc142-mt-gd-x64-1_76.lib libboost_program_options-vc142-mt-gd-x64-1_76.lib libboost_python38-vc142-mt-gd-x64-1_76.lib libboost_random-vc142-mt-gd-x64-1_76.lib libboost_regex-vc142-mt-gd-x64-1_76.lib libboost_serialization-vc142-mt-gd-x64-1_76.lib libboost_stacktrace_noop-vc142-mt-gd-x64-1_76.lib libboost_stacktrace_windbg-vc142-mt-gd-x64-1_76.lib libboost_stacktrace_windbg_cached-vc142-mt-gd-x64-1_76.lib libboost_system-vc142-mt-gd-x64-1_76.lib libboost_test_exec_monitor-vc142-mt-gd-x64-1_76.lib libboost_thread-vc142-mt-gd-x64-1_76.lib libboost_timer-vc142-mt-gd-x64-1_76.lib libboost_type_erasure-vc142-mt-gd-x64-1_76.lib libboost_unit_test_framework-vc142-mt-gd-x64-1_76.lib libboost_wave-vc142-mt-gd-x64-1_76.lib libboost_wserialization-vc142-mt-gd-x64-1_76.lib libboost_zlib-vc142-mt-gd-x64-1_76.lib flann-gd.lib flann_cpp-gd.lib flann_cpp_s-gd.lib flann_s-gd.lib OpenNI2.lib qhullcpp_d.lib qhullstatic_d.lib qhullstatic_rd.lib qhull_rd.lib vtkChartsCore-9.0d.lib vtkCommonColor-9.0d.lib vtkCommonComputationalGeometry-9.0d.lib vtkCommonCore-9.0d.lib vtkCommonDataModel-9.0d.lib vtkCommonExecutionModel-9.0d.lib vtkCommonMath-9.0d.lib vtkCommonMisc-9.0d.lib vtkCommonSystem-9.0d.lib vtkCommonTransforms-9.0d.lib vtkDICOMParser-9.0d.lib vtkDomainsChemistry-9.0d.lib vtkDomainsChemistryOpenGL2-9.0d.lib vtkdoubleconversion-9.0d.lib vtkexodusII-9.0d.lib vtkexpat-9.0d.lib vtkFiltersAMR-9.0d.lib vtkFiltersCore-9.0d.lib vtkFiltersExtraction-9.0d.lib vtkFiltersFlowPaths-9.0d.lib vtkFiltersGeneral-9.0d.lib vtkFiltersGeneric-9.0d.lib vtkFiltersGeometry-9.0d.lib vtkFiltersHybrid-9.0d.lib vtkFiltersHyperTree-9.0d.lib vtkFiltersImaging-9.0d.lib vtkFiltersModeling-9.0d.lib vtkFiltersParallel-9.0d.lib vtkFiltersParallelImaging-9.0d.lib vtkFiltersPoints-9.0d.lib vtkFiltersProgrammable-9.0d.lib vtkFiltersSelection-9.0d.lib vtkFiltersSMP-9.0d.lib vtkFiltersSources-9.0d.lib vtkFiltersStatistics-9.0d.lib vtkFiltersTexture-9.0d.lib vtkFiltersTopology-9.0d.lib vtkFiltersVerdict-9.0d.lib vtkfreetype-9.0d.lib vtkGeovisCore-9.0d.lib vtkgl2ps-9.0d.lib vtkglew-9.0d.lib vtkhdf5-9.0d.lib vtkhdf5_hl-9.0d.lib vtkImagingColor-9.0d.lib vtkImagingCore-9.0d.lib vtkImagingFourier-9.0d.lib vtkImagingGeneral-9.0d.lib vtkImagingHybrid-9.0d.lib vtkImagingMath-9.0d.lib vtkImagingMorphological-9.0d.lib vtkImagingSources-9.0d.lib vtkImagingStatistics-9.0d.lib vtkImagingStencil-9.0d.lib vtkInfovisCore-9.0d.lib vtkInfovisLayout-9.0d.lib vtkInteractionImage-9.0d.lib vtkInteractionStyle-9.0d.lib vtkInteractionWidgets-9.0d.lib vtkIOAMR-9.0d.lib vtkIOAsynchronous-9.0d.lib vtkIOCityGML-9.0d.lib vtkIOCore-9.0d.lib vtkIOEnSight-9.0d.lib vtkIOExodus-9.0d.lib vtkIOExport-9.0d.lib vtkIOExportGL2PS-9.0d.lib vtkIOExportPDF-9.0d.lib vtkIOGeometry-9.0d.lib vtkIOImage-9.0d.lib vtkIOImport-9.0d.lib vtkIOInfovis-9.0d.lib vtkIOLegacy-9.0d.lib vtkIOLSDyna-9.0d.lib vtkIOMINC-9.0d.lib vtkIOMotionFX-9.0d.lib vtkIOMovie-9.0d.lib vtkIONetCDF-9.0d.lib vtkIOOggTheora-9.0d.lib vtkIOParallel-9.0d.lib vtkIOParallelXML-9.0d.lib vtkIOPLY-9.0d.lib vtkIOSegY-9.0d.lib vtkIOSQL-9.0d.lib vtkIOTecplotTable-9.0d.lib vtkIOVeraOut-9.0d.lib vtkIOVideo-9.0d.lib vtkIOXML-9.0d.lib vtkIOXMLParser-9.0d.lib vtkjpeg-9.0d.lib vtkjsoncpp-9.0d.lib vtklibharu-9.0d.lib vtklibproj-9.0d.lib vtklibxml2-9.0d.lib vtkloguru-9.0d.lib vtklz4-9.0d.lib vtklzma-9.0d.lib vtkmetaio-9.0d.lib vtknetcdf-9.0d.lib vtkogg-9.0d.lib vtkParallelCore-9.0d.lib vtkParallelDIY-9.0d.lib vtkpng-9.0d.lib vtkpugixml-9.0d.lib vtkRenderingAnnotation-9.0d.lib vtkRenderingContext2D-9.0d.lib vtkRenderingContextOpenGL2-9.0d.lib vtkRenderingCore-9.0d.lib vtkRenderingFreeType-9.0d.lib vtkRenderingGL2PSOpenGL2-9.0d.lib vtkRenderingImage-9.0d.lib vtkRenderingLabel-9.0d.lib vtkRenderingLOD-9.0d.lib vtkRenderingOpenGL2-9.0d.lib vtkRenderingSceneGraph-9.0d.lib vtkRenderingUI-9.0d.lib vtkRenderingVolume-9.0d.lib vtkRenderingVolumeOpenGL2-9.0d.lib vtkRenderingVtkJS-9.0d.lib vtksqlite-9.0d.lib vtksys-9.0d.lib vtkTestingRendering-9.0d.lib vtktheora-9.0d.lib vtktiff-9.0d.lib vtkverdict-9.0d.lib vtkViewsContext2D-9.0d.lib vtkViewsCore-9.0d.lib vtkViewsInfovis-9.0d.lib vtkWrappingTools-9.0d.lib vtkzlib-9.0d.lib
release附加依赖项为
pcl_common.lib pcl_features.lib pcl_filters.lib pcl_io.lib pcl_io_ply.lib pcl_kdtree.lib pcl_keypoints.lib pcl_ml.lib pcl_octree.lib pcl_outofcore.lib pcl_people.lib pcl_recognition.lib pcl_registration.lib pcl_sample_consensus.lib pcl_search.lib pcl_segmentation.lib pcl_stereo.lib pcl_surface.lib pcl_tracking.lib pcl_visualization.lib libboost_atomic-vc142-mt-x64-1_76.lib libboost_bzip2-vc142-mt-x64-1_76.lib libboost_chrono-vc142-mt-x64-1_76.lib libboost_container-vc142-mt-x64-1_76.lib libboost_context-vc142-mt-x64-1_76.lib libboost_contract-vc142-mt-x64-1_76.lib libboost_coroutine-vc142-mt-x64-1_76.lib libboost_date_time-vc142-mt-x64-1_76.lib libboost_exception-vc142-mt-x64-1_76.lib libboost_fiber-vc142-mt-x64-1_76.lib libboost_filesystem-vc142-mt-x64-1_76.lib libboost_graph-vc142-mt-x64-1_76.lib libboost_graph_parallel-vc142-mt-x64-1_76.lib libboost_iostreams-vc142-mt-x64-1_76.lib libboost_json-vc142-mt-x64-1_76.lib libboost_locale-vc142-mt-x64-1_76.lib libboost_log-vc142-mt-x64-1_76.lib libboost_log_setup-vc142-mt-x64-1_76.lib libboost_math_c99-vc142-mt-x64-1_76.lib libboost_math_c99f-vc142-mt-x64-1_76.lib libboost_math_c99l-vc142-mt-x64-1_76.lib libboost_math_tr1-vc142-mt-x64-1_76.lib libboost_math_tr1f-vc142-mt-x64-1_76.lib libboost_math_tr1l-vc142-mt-x64-1_76.lib libboost_mpi-vc142-mt-x64-1_76.lib libboost_nowide-vc142-mt-x64-1_76.lib libboost_numpy38-vc142-mt-x64-1_76.lib libboost_prg_exec_monitor-vc142-mt-x64-1_76.lib libboost_program_options-vc142-mt-x64-1_76.lib libboost_python38-vc142-mt-x64-1_76.lib libboost_random-vc142-mt-x64-1_76.lib libboost_regex-vc142-mt-x64-1_76.lib libboost_serialization-vc142-mt-x64-1_76.lib libboost_stacktrace_noop-vc142-mt-x64-1_76.lib libboost_stacktrace_windbg-vc142-mt-x64-1_76.lib libboost_stacktrace_windbg_cached-vc142-mt-x64-1_76.lib libboost_system-vc142-mt-x64-1_76.lib libboost_test_exec_monitor-vc142-mt-x64-1_76.lib libboost_thread-vc142-mt-x64-1_76.lib libboost_timer-vc142-mt-x64-1_76.lib libboost_type_erasure-vc142-mt-x64-1_76.lib libboost_unit_test_framework-vc142-mt-x64-1_76.lib libboost_wave-vc142-mt-x64-1_76.lib libboost_wserialization-vc142-mt-x64-1_76.lib libboost_zlib-vc142-mt-x64-1_76.lib flann.lib flann_cpp.lib flann_cpp_s.lib flann_s.lib OpenNI2.lib qhullcpp.lib qhullstatic.lib qhullstatic_r.lib qhull_r.lib vtkChartsCore-9.0.lib vtkCommonColor-9.0.lib vtkCommonComputationalGeometry-9.0.lib vtkCommonCore-9.0.lib vtkCommonDataModel-9.0.lib vtkCommonExecutionModel-9.0.lib vtkCommonMath-9.0.lib vtkCommonMisc-9.0.lib vtkCommonSystem-9.0.lib vtkCommonTransforms-9.0.lib vtkDICOMParser-9.0.lib vtkDomainsChemistry-9.0.lib vtkDomainsChemistryOpenGL2-9.0.lib vtkdoubleconversion-9.0.lib vtkexodusII-9.0.lib vtkexpat-9.0.lib vtkFiltersAMR-9.0.lib vtkFiltersCore-9.0.lib vtkFiltersExtraction-9.0.lib vtkFiltersFlowPaths-9.0.lib vtkFiltersGeneral-9.0.lib vtkFiltersGeneric-9.0.lib vtkFiltersGeometry-9.0.lib vtkFiltersHybrid-9.0.lib vtkFiltersHyperTree-9.0.lib vtkFiltersImaging-9.0.lib vtkFiltersModeling-9.0.lib vtkFiltersParallel-9.0.lib vtkFiltersParallelImaging-9.0.lib vtkFiltersPoints-9.0.lib vtkFiltersProgrammable-9.0.lib vtkFiltersSelection-9.0.lib vtkFiltersSMP-9.0.lib vtkFiltersSources-9.0.lib vtkFiltersStatistics-9.0.lib vtkFiltersTexture-9.0.lib vtkFiltersTopology-9.0.lib vtkFiltersVerdict-9.0.lib vtkfreetype-9.0.lib vtkGeovisCore-9.0.lib vtkgl2ps-9.0.lib vtkglew-9.0.lib vtkhdf5-9.0.lib vtkhdf5_hl-9.0.lib vtkImagingColor-9.0.lib vtkImagingCore-9.0.lib vtkImagingFourier-9.0.lib vtkImagingGeneral-9.0.lib vtkImagingHybrid-9.0.lib vtkImagingMath-9.0.lib vtkImagingMorphological-9.0.lib vtkImagingSources-9.0.lib vtkImagingStatistics-9.0.lib vtkImagingStencil-9.0.lib vtkInfovisCore-9.0.lib vtkInfovisLayout-9.0.lib vtkInteractionImage-9.0.lib vtkInteractionStyle-9.0.lib vtkInteractionWidgets-9.0.lib vtkIOAMR-9.0.lib vtkIOAsynchronous-9.0.lib vtkIOCityGML-9.0.lib vtkIOCore-9.0.lib vtkIOEnSight-9.0.lib vtkIOExodus-9.0.lib vtkIOExport-9.0.lib vtkIOExportGL2PS-9.0.lib vtkIOExportPDF-9.0.lib vtkIOGeometry-9.0.lib vtkIOImage-9.0.lib vtkIOImport-9.0.lib vtkIOInfovis-9.0.lib vtkIOLegacy-9.0.lib vtkIOLSDyna-9.0.lib vtkIOMINC-9.0.lib vtkIOMotionFX-9.0.lib vtkIOMovie-9.0.lib vtkIONetCDF-9.0.lib vtkIOOggTheora-9.0.lib vtkIOParallel-9.0.lib vtkIOParallelXML-9.0.lib vtkIOPLY-9.0.lib vtkIOSegY-9.0.lib vtkIOSQL-9.0.lib vtkIOTecplotTable-9.0.lib vtkIOVeraOut-9.0.lib vtkIOVideo-9.0.lib vtkIOXML-9.0.lib vtkIOXMLParser-9.0.lib vtkjpeg-9.0.lib vtkjsoncpp-9.0.lib vtklibharu-9.0.lib vtklibproj-9.0.lib vtklibxml2-9.0.lib vtkloguru-9.0.lib vtklz4-9.0.lib vtklzma-9.0.lib vtkmetaio-9.0.lib vtknetcdf-9.0.lib vtkogg-9.0.lib vtkParallelCore-9.0.lib vtkParallelDIY-9.0.lib vtkpng-9.0.lib vtkpugixml-9.0.lib vtkRenderingAnnotation-9.0.lib vtkRenderingContext2D-9.0.lib vtkRenderingContextOpenGL2-9.0.lib vtkRenderingCore-9.0.lib vtkRenderingFreeType-9.0.lib vtkRenderingGL2PSOpenGL2-9.0.lib vtkRenderingImage-9.0.lib vtkRenderingLabel-9.0.lib vtkRenderingLOD-9.0.lib vtkRenderingOpenGL2-9.0.lib vtkRenderingSceneGraph-9.0.lib vtkRenderingUI-9.0.lib vtkRenderingVolume-9.0.lib vtkRenderingVolumeOpenGL2-9.0.lib vtkRenderingVtkJS-9.0.lib vtksqlite-9.0.lib vtksys-9.0.lib vtkTestingRendering-9.0.lib vtktheora-9.0.lib vtktiff-9.0.lib vtkverdict-9.0.lib vtkViewsContext2D-9.0.lib vtkViewsCore-9.0.lib vtkViewsInfovis-9.0.lib vtkWrappingTools-9.0.lib vtkzlib-9.0.lib
验证:
#include<iostream> #include<pcl/io/ply_io.h> #include<pcl/point_types.h> #include<pcl/visualization/cloud_viewer.h> #include <chrono> #include <thread> #include <boost/thread/thread.hpp> using namespace std; int main() { //创建PointCloud的智能指针,pointcloud相当于点云的容器,里面存储pointXYZ点云类型 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud1(new pcl::PointCloud<pcl::PointXYZ>); pcl::PointCloud<pcl::PointXYZ>::Ptr cloud2(new pcl::PointCloud<pcl::PointXYZ>); if (pcl::io::loadPLYFile<pcl::PointXYZ>("E:\\乔大花进度\\PCL\\11-29\\点云读取\\1.ply", *cloud1) == -1) { cout << "请检查点云文件的路径" << endl; } if (pcl::io::loadPLYFile<pcl::PointXYZ>("E:\\乔大花进度\\PCL\\11-29\\点云读取\\2.ply", *cloud2) == -1) { cout << "请检查点云文件的路径" << endl; } //定义可视化话窗口 窗口的类型有两种第一种为 pclVisualization,第二种为CloudViewer //共享指针形式定义,new为指针开辟新的地址 boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer(new pcl::visualization::PCLVisualizer("3D 窗口")); //第二种定义只是将PCLvisualization换位CloudViewer //普通窗口定义形式 //pcl::visualization::PCLVisualizer Viewer("3D 窗口"); //设置窗口背景 viewer->setBackgroundColor(0, 0, 255); //设置显示点云颜色 pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ> Point_color(cloud1, 255, 0, 0); //将处理过的点云传入显示窗口中 viewer->addPointCloud<pcl::PointXYZ>(cloud1, Point_color, "cloud1"); viewer->addPointCloud<pcl::PointXYZ>(cloud2, "cloud2"); pcl::ModelCoefficients model; model.values.push_back(0); model.values.push_back(0); model.values.push_back(0); model.values.push_back(10); viewer->addSphere(model, "sphere"); //设置点云大小,只能设置指定点云的大小 viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 3, "cloud1"); while (!viewer->wasStopped()) { viewer->spinOnce(100); boost::this_thread::sleep(boost::posix_time::microseconds(10000)); } return 0; }
结果: