之前在win10系统下配置了PCL1.8.1+QT5.9.1+VS2015的开发环境,由于PCL库已经更新到了1.12.1而且1.8.1一直有bug,为了使用下新的算法库,今天配置一下新的开发环境。
1. 安装Qt5.14.2
Qt5.14.2的安装包可以从国内各大镜像源里下载,我是从清华大学开源镜像网站上下载的https://mirrors.tuna.tsinghua.edu.cn/qt/archive/qt/5.14/5.14.2/,选中如下所示的文件点击即可,会自动跳转到迅雷下载的。5.14.2版本需要你登录账号,如果没有注册直接点击下图红色框注册即可,注册完毕再登录账号,然后安装位置自己设置或者按照默认位置安装也行。 对于安装的模块,因为我只需要MSVC编译器,所以MinGW编译器以及其他的我没有安装,我的安装模块选择如下图: 然后,剩下的一路安装即可。
2. 安装VS2019
安装vs2019需要先下载相应的visual studio installer,微软官网现在都是VS2022的下载链接,你需要所搜历史版本然后登录账号才可以下载,下载链接如下https://visualstudio.microsoft.com/zh-hans/vs/older-downloads/,按照下图红框中的提示选择相应的vs版本。 运行visual studio installer,选择相应的组件进行安装,我只选择了使用C++的桌面开发,然后又添加了MSVC V141-VS2017 C++ x64/x86生成工具,如下图: 还可以在安装位置界面手动修改vs的安装位置,然后一路安装即可。
3. 安装PCL1.12.0
PCL1.12.0的安装包直接去github上下载就行,下载链接:https://github.com/PointCloudLibrary/pcl/releases, 安装PCL的时候一定要注意安装路径不要有空格!!! 记住自己的安装路径,等会需要根据安装路径添加PCL的环境变量。安装过程中,选择将PCL添加到环境变量中,如下图: PCL的OPENNI2需要重新安装一下,安装路径最好与VTK等其他第三方库一致。我的安装路径如下图所示。
4.添加环境变量
当所有的软件安装完毕后,需要添加qt,pcl的环境变量,我的环境变量如下图所示。 首先添加系统变量: 然后添加path变量:
5. 设置QT
打开qt后,依次选择工具栏中的工具(T)、选项(O)…,打开kits界面,设置相应的编译器,如下图: 我安装的编译器版本如下图所示:
6. PCL测试
(1) pro文件配置:
INCLUDEPATH += "D:\PCL1.12.0\PCL-1.12.0\include\pcl-1.12"
INCLUDEPATH += "D:\PCL1.12.0\PCL-1.12.0\3rdParty\Boost\include\boost-1_76"
INCLUDEPATH += "D:\PCL1.12.0\PCL-1.12.0\3rdParty\FLANN\include"
INCLUDEPATH += "D:\PCL1.12.0\PCL-1.12.0\3rdParty\OpenNI2\Include"
INCLUDEPATH += "D:\PCL1.12.0\PCL-1.12.0\3rdParty\Qhull\include"
INCLUDEPATH += "D:\PCL1.12.0\PCL-1.12.0\3rdParty\VTK\include\vtk-9.0"
INCLUDEPATH += "D:\PCL1.12.0\PCL-1.12.0\3rdParty\Eigen\eigen3"
#MSVC编译器添加静态库文件方式:
#设置添加的静态库文件,根据当前项目的编译模式确定是调用debug库还是release库
win32:CONFIG(debug,debug|release):LIBS += -LD:\PCL1.12.0\PCL-1.12.0\3rdParty\Boost\lib\
-llibboost_atomic-vc142-mt-gd-x64-1_76 \
-llibboost_bzip2-vc142-mt-gd-x64-1_76 \
-llibboost_chrono-vc142-mt-gd-x64-1_76 \
-llibboost_container-vc142-mt-gd-x64-1_76 \
-llibboost_context-vc142-mt-gd-x64-1_76 \
-llibboost_contract-vc142-mt-gd-x64-1_76 \
-llibboost_coroutine-vc142-mt-gd-x64-1_76 \
-llibboost_date_time-vc142-mt-gd-x64-1_76 \
-llibboost_exception-vc142-mt-gd-x64-1_76 \
-llibboost_fiber-vc142-mt-gd-x64-1_76 \
-llibboost_filesystem-vc142-mt-gd-x64-1_76 \
-llibboost_graph-vc142-mt-gd-x64-1_76 \
-llibboost_graph_parallel-vc142-mt-gd-x64-1_76 \
-llibboost_iostreams-vc142-mt-gd-x64-1_76 \
-llibboost_json-vc142-mt-gd-x64-1_76 \
-llibboost_locale-vc142-mt-gd-x64-1_76 \
-llibboost_log-vc142-mt-gd-x64-1_76 \
-llibboost_log_setup-vc142-mt-gd-x64-1_76 \
-llibboost_math_c99-vc142-mt-gd-x64-1_76 \
-llibboost_math_c99f-vc142-mt-gd-x64-1_76 \
-llibboost_math_c99l-vc142-mt-gd-x64-1_76 \
-llibboost_math_tr1-vc142-mt-gd-x64-1_76 \
-llibboost_math_tr1f-vc142-mt-gd-x64-1_76 \
-llibboost_math_tr1l-vc142-mt-gd-x64-1_76 \
-llibboost_mpi-vc142-mt-gd-x64-1_76 \
-llibboost_nowide-vc142-mt-gd-x64-1_76 \
-llibboost_numpy38-vc142-mt-gd-x64-1_76 \
-llibboost_prg_exec_monitor-vc142-mt-gd-x64-1_76 \
-llibboost_program_options-vc142-mt-gd-x64-1_76 \
-llibboost_python38-vc142-mt-gd-x64-1_76 \
-llibboost_random-vc142-mt-gd-x64-1_76 \
-llibboost_regex-vc142-mt-gd-x64-1_76 \
-llibboost_serialization-vc142-mt-gd-x64-1_76 \
-llibboost_stacktrace_noop-vc142-mt-gd-x64-1_76 \
-llibboost_stacktrace_windbg-vc142-mt-gd-x64-1_76 \
-llibboost_stacktrace_windbg_cached-vc142-mt-gd-x64-1_76 \
-llibboost_system-vc142-mt-gd-x64-1_76 \
-llibboost_test_exec_monitor-vc142-mt-gd-x64-1_76 \
-llibboost_thread-vc142-mt-gd-x64-1_76 \
-llibboost_timer-vc142-mt-gd-x64-1_76 \
-llibboost_type_erasure-vc142-mt-gd-x64-1_76 \
-llibboost_unit_test_framework-vc142-mt-gd-x64-1_76 \
-llibboost_wave-vc142-mt-gd-x64-1_76 \
-llibboost_wserialization-vc142-mt-gd-x64-1_76 \
-llibboost_zlib-vc142-mt-gd-x64-1_76
else:win32:CONFIG(release,debug|release):
LIBS += -LD:\PCL1.12.0\PCL-1.12.0\3rdParty\Boost\lib\
-llibboost_atomic-vc142-mt-x64-1_76 \
-llibboost_bzip2-vc142-mt-x64-1_76 \
-llibboost_chrono-vc142-mt-x64-1_76 \
-llibboost_container-vc142-mt-x64-1_76 \
-llibboost_context-vc142-mt-x64-1_76 \
-llibboost_contract-vc142-mt-x64-1_76 \
-llibboost_coroutine-vc142-mt-x64-1_76 \
-llibboost_date_time-vc142-mt-x64-1_76 \
-llibboost_exception-vc142-mt-x64-1_76 \
-llibboost_fiber-vc142-mt-x64-1_76 \
-llibboost_filesystem-vc142-mt-x64-1_76 \
-llibboost_graph-vc142-mt-x64-1_76 \
-llibboost_graph_parallel-vc142-mt-x64-1_76 \
-llibboost_iostreams-vc142-mt-x64-1_76 \
-llibboost_json-vc142-mt-x64-1_76 \
-llibboost_locale-vc142-mt-x64-1_76 \
-llibboost_log-vc142-mt-x64-1_76 \
-llibboost_log_setup-vc142-mt-x64-1_76 \
-llibboost_math_c99-vc142-mt-x64-1_76 \
-llibboost_math_c99f-vc142-mt-x64-1_76 \
-llibboost_math_c99l-vc142-mt-x64-1_76 \
-llibboost_math_tr1-vc142-mt-x64-1_76 \
-llibboost_math_tr1f-vc142-mt-x64-1_76 \
-llibboost_math_tr1l-vc142-mt-x64-1_76 \
-llibboost_mpi-vc142-mt-x64-1_76 \
-llibboost_nowide-vc142-mt-x64-1_76 \
-llibboost_numpy38-vc142-mt-x64-1_76 \
-llibboost_prg_exec_monitor-vc142-mt-x64-1_76 \
-llibboost_program_options-vc142-mt-x64-1_76 \
-llibboost_python38-vc142-mt-x64-1_76 \
-llibboost_random-vc142-mt-x64-1_76 \
-llibboost_regex-vc142-mt-x64-1_76 \
-llibboost_serialization-vc142-mt-x64-1_76 \
-llibboost_stacktrace_noop-vc142-mt-x64-1_76 \
-llibboost_stacktrace_windbg-vc142-mt-x64-1_76 \
-llibboost_stacktrace_windbg_cached-vc142-mt-x64-1_76 \
-llibboost_system-vc142-mt-x64-1_76 \
-llibboost_test_exec_monitor-vc142-mt-x64-1_76 \
-llibboost_thread-vc142-mt-x64-1_76 \
-llibboost_timer-vc142-mt-x64-1_76 \
-llibboost_type_erasure-vc142-mt-x64-1_76 \
-llibboost_unit_test_framework-vc142-mt-x64-1_76 \
-llibboost_wave-vc142-mt-x64-1_76 \
-llibboost_wserialization-vc142-mt-x64-1_76 \
-llibboost_zlib-vc142-mt-x64-1_76
win32:CONFIG(debug, debug|release): LIBS += -LD:\PCL1.12.0\PCL-1.12.0\lib\
-lpcl_commond \
-lpcl_featuresd \
-lpcl_filtersd \
-lpcl_io_plyd \
-lpcl_iod \
-lpcl_kdtreed \
-lpcl_keypointsd \
-lpcl_mld \
-lpcl_octreed \
-lpcl_outofcored \
-lpcl_peopled \
-lpcl_recognitiond \
-lpcl_registrationd \
-lpcl_sample_consensusd \
-lpcl_searchd \
-lpcl_segmentationd \
-lpcl_stereod \
-lpcl_surfaced \
-lpcl_trackingd \
-lpcl_visualizationd
else:win32:CONFIG(release, debug|release): LIBS += -LD:\PCL1.12.0\PCL-1.12.0\lib\
-lpcl_common \
-lpcl_features \
-lpcl_filters \
-lpcl_io \
-lpcl_io_ply \
-lpcl_kdtree \
-lpcl_keypoints \
-lpcl_ml \
-lpcl_octree \
-lpcl_outofcore \
-lpcl_people \
-lpcl_recognition \
-lpcl_registration \
-lpcl_sample_consensus \
-lpcl_search \
-lpcl_segmentation \
-lpcl_stereo \
-lpcl_surface \
-lpcl_tracking \
-lpcl_visualization
win32:CONFIG(debug, debug|release): LIBS += -LD:\PCL1.12.0\PCL-1.12.0\3rdParty\FLANN\lib\
-lflann-gd \
-lflann_cpp-gd \
-lflann_cpp_s-gd \
-lflann_s-gd
else:win32:CONFIG(release, debug|release): LIBS += -LD:\PCL1.12.0\PCL-1.12.0\3rdParty\FLANN\lib\
-lflann \
-lflann_cpp \
-lflann_cpp_s \
-lflann_s
win32:CONFIG(debug, debug|release): LIBS += -LD:\PCL1.12.0\PCL-1.12.0\3rdParty\OpenNI2\Lib\
-lOpenNI2
else:win32:CONFIG(release, debug|release): LIBS += -LD:\PCL1.12.0\PCL-1.12.0\3rdParty\OpenNI2\Lib\
-lOpenNI2
win32:CONFIG(debug, debug|release): LIBS += -LD:\PCL1.12.0\PCL-1.12.0\3rdParty\Qhull\lib\
-lqhull_rd \
-lqhullcpp_d \
-lqhullstatic_d \
-lqhullstatic_rd
else:win32:CONFIG(release, debug|release): LIBS += -LD:\PCL1.12.0\PCL-1.12.0\3rdParty\Qhull\lib\
-lqhull_r \
-lqhullcpp \
-lqhullstatic \
-lqhullstatic_r
win32:CONFIG(debug, debug|release): LIBS += -LD:\PCL1.12.0\PCL-1.12.0\3rdParty\VTK\lib\
-lvtkChartsCore-9.0d \
-lvtkCommonColor-9.0d \
-lvtkCommonComputationalGeometry-9.0d \
-lvtkCommonCore-9.0d \
-lvtkCommonDataModel-9.0d \
-lvtkCommonExecutionModel-9.0d \
-lvtkCommonMath-9.0d \
-lvtkCommonMisc-9.0d \
-lvtkCommonSystem-9.0d \
-lvtkCommonTransforms-9.0d \
-lvtkDICOMParser-9.0d \
-lvtkDomainsChemistry-9.0d \
-lvtkDomainsChemistryOpenGL2-9.0d \
-lvtkFiltersAMR-9.0d \
-lvtkFiltersCore-9.0d \
-lvtkFiltersExtraction-9.0d \
-lvtkFiltersFlowPaths-9.0d \
-lvtkFiltersGeneral-9.0d \
-lvtkFiltersGeneric-9.0d \
-lvtkFiltersGeometry-9.0d \
-lvtkFiltersHybrid-9.0d \
-lvtkFiltersHyperTree-9.0d \
-lvtkFiltersImaging-9.0d \
-lvtkFiltersModeling-9.0d \
-lvtkFiltersParallel-9.0d \
-lvtkFiltersParallelImaging-9.0d \
-lvtkFiltersPoints-9.0d \
-lvtkFiltersProgrammable-9.0d \
-lvtkFiltersSMP-9.0d \
-lvtkFiltersSelection-9.0d \
-lvtkFiltersSources-9.0d \
-lvtkFiltersStatistics-9.0d \
-lvtkFiltersTexture-9.0d \
-lvtkFiltersTopology-9.0d \
-lvtkFiltersVerdict-9.0d \
-lvtkGeovisCore-9.0d \
-lvtkIOAMR-9.0d \
-lvtkIOAsynchronous-9.0d \
-lvtkIOCityGML-9.0d \
-lvtkIOCore-9.0d \
-lvtkIOEnSight-9.0d \
-lvtkIOExodus-9.0d \
-lvtkIOExport-9.0d \
-lvtkIOExportGL2PS-9.0d \
-lvtkIOExportPDF-9.0d \
-lvtkIOGeometry-9.0d \
-lvtkIOImage-9.0d \
-lvtkIOImport-9.0d \
-lvtkIOInfovis-9.0d \
-lvtkIOLSDyna-9.0d \
-lvtkIOLegacy-9.0d \
-lvtkIOMINC-9.0d \
-lvtkIOMotionFX-9.0d \
-lvtkIOMovie-9.0d \
-lvtkIONetCDF-9.0d \
-lvtkIOOggTheora-9.0d \
-lvtkIOPLY-9.0d \
-lvtkIOParallel-9.0d \
-lvtkIOParallelXML-9.0d \
-lvtkIOSQL-9.0d \
-lvtkIOSegY-9.0d \
-lvtkIOTecplotTable-9.0d \
-lvtkIOVeraOut-9.0d \
-lvtkIOVideo-9.0d \
-lvtkIOXML-9.0d \
-lvtkIOXMLParser-9.0d \
-lvtkImagingColor-9.0d \
-lvtkImagingCore-9.0d \
-lvtkImagingFourier-9.0d \
-lvtkImagingGeneral-9.0d \
-lvtkImagingHybrid-9.0d \
-lvtkImagingMath-9.0d \
-lvtkImagingMorphological-9.0d \
-lvtkImagingSources-9.0d \
-lvtkImagingStatistics-9.0d \
-lvtkImagingStencil-9.0d \
-lvtkInfovisCore-9.0d \
-lvtkInfovisLayout-9.0d \
-lvtkInteractionImage-9.0d \
-lvtkInteractionStyle-9.0d \
-lvtkInteractionWidgets-9.0d \
-lvtkParallelCore-9.0d \
-lvtkParallelDIY-9.0d \
-lvtkRenderingAnnotation-9.0d \
-lvtkRenderingContext2D-9.0d \
-lvtkRenderingContextOpenGL2-9.0d \
-lvtkRenderingCore-9.0d \
-lvtkRenderingFreeType-9.0d \
-lvtkRenderingGL2PSOpenGL2-9.0d \
-lvtkRenderingImage-9.0d \
-lvtkRenderingLOD-9.0d \
-lvtkRenderingLabel-9.0d \
-lvtkRenderingOpenGL2-9.0d \
-lvtkRenderingSceneGraph-9.0d \
-lvtkRenderingUI-9.0d \
-lvtkRenderingVolume-9.0d \
-lvtkRenderingVolumeOpenGL2-9.0d \
-lvtkRenderingVtkJS-9.0d \
-lvtkTestingRendering-9.0d \
-lvtkViewsContext2D-9.0d \
-lvtkViewsCore-9.0d \
-lvtkViewsInfovis-9.0d \
-lvtkWrappingTools-9.0d \
-lvtkdoubleconversion-9.0d \
-lvtkexodusII-9.0d \
-lvtkexpat-9.0d \
-lvtkfreetype-9.0d \
-lvtkgl2ps-9.0d \
-lvtkglew-9.0d \
-lvtkhdf5-9.0d \
-lvtkhdf5_hl-9.0d \
-lvtkjpeg-9.0d \
-lvtkjsoncpp-9.0d \
-lvtklibharu-9.0d \
-lvtklibproj-9.0d \
-lvtklibxml2-9.0d \
-lvtkloguru-9.0d \
-lvtklz4-9.0d \
-lvtklzma-9.0d \
-lvtkmetaio-9.0d \
-lvtknetcdf-9.0d \
-lvtkogg-9.0d \
-lvtkpng-9.0d \
-lvtkpugixml-9.0d \
-lvtksqlite-9.0d \
-lvtksys-9.0d \
-lvtktheora-9.0d \
-lvtktiff-9.0d \
-lvtkverdict-9.0d \
-lvtkzlib-9.0d
else:win32:CONFIG(release, debug|release): LIBS += -LD:\PCL1.12.0\PCL-1.12.0\3rdParty\VTK\lib\
-lvtkChartsCore-9.0 \
-lvtkCommonColor-9.0 \
-lvtkCommonComputationalGeometry-9.0 \
-lvtkCommonCore-9.0 \
-lvtkCommonDataModel-9.0 \
-lvtkCommonExecutionModel-9.0 \
-lvtkCommonMath-9.0 \
-lvtkCommonMisc-9.0 \
-lvtkCommonSystem-9.0 \
-lvtkCommonTransforms-9.0 \
-lvtkDICOMParser-9.0 \
-lvtkDomainsChemistry-9.0 \
-lvtkDomainsChemistryOpenGL2-9.0 \
-lvtkFiltersAMR-9.0 \
-lvtkFiltersCore-9.0 \
-lvtkFiltersExtraction-9.0 \
-lvtkFiltersFlowPaths-9.0 \
-lvtkFiltersGeneral-9.0 \
-lvtkFiltersGeneric-9.0 \
-lvtkFiltersGeometry-9.0 \
-lvtkFiltersHybrid-9.0 \
-lvtkFiltersHyperTree-9.0 \
-lvtkFiltersImaging-9.0 \
-lvtkFiltersModeling-9.0 \
-lvtkFiltersParallel-9.0 \
-lvtkFiltersParallelImaging-9.0 \
-lvtkFiltersPoints-9.0 \
-lvtkFiltersProgrammable-9.0 \
-lvtkFiltersSMP-9.0 \
-lvtkFiltersSelection-9.0 \
-lvtkFiltersSources-9.0 \
-lvtkFiltersStatistics-9.0 \
-lvtkFiltersTexture-9.0 \
-lvtkFiltersTopology-9.0 \
-lvtkFiltersVerdict-9.0 \
-lvtkGeovisCore-9.0 \
-lvtkIOAMR-9.0 \
-lvtkIOAsynchronous-9.0 \
-lvtkIOCityGML-9.0 \
-lvtkIOCore-9.0 \
-lvtkIOEnSight-9.0 \
-lvtkIOExodus-9.0 \
-lvtkIOExport-9.0 \
-lvtkIOExportGL2PS-9.0 \
-lvtkIOExportPDF-9.0 \
-lvtkIOGeometry-9.0 \
-lvtkIOImage-9.0 \
-lvtkIOImport-9.0 \
-lvtkIOInfovis-9.0 \
-lvtkIOLSDyna-9.0 \
-lvtkIOLegacy-9.0 \
-lvtkIOMINC-9.0 \
-lvtkIOMotionFX-9.0 \
-lvtkIOMovie-9.0 \
-lvtkIONetCDF-9.0 \
-lvtkIOOggTheora-9.0 \
-lvtkIOPLY-9.0 \
-lvtkIOParallel-9.0 \
-lvtkIOParallelXML-9.0 \
-lvtkIOSQL-9.0 \
-lvtkIOSegY-9.0 \
-lvtkIOTecplotTable-9.0 \
-lvtkIOVeraOut-9.0 \
-lvtkIOVideo-9.0 \
-lvtkIOXML-9.0 \
-lvtkIOXMLParser-9.0 \
-lvtkImagingColor-9.0 \
-lvtkImagingCore-9.0 \
-lvtkImagingFourier-9.0 \
-lvtkImagingGeneral-9.0 \
-lvtkImagingHybrid-9.0 \
-lvtkImagingMath-9.0 \
-lvtkImagingMorphological-9.0 \
-lvtkImagingSources-9.0 \
-lvtkImagingStatistics-9.0 \
-lvtkImagingStencil-9.0 \
-lvtkInfovisCore-9.0 \
-lvtkInfovisLayout-9.0 \
-lvtkInteractionImage-9.0 \
-lvtkInteractionStyle-9.0 \
-lvtkInteractionWidgets-9.0 \
-lvtkParallelCore-9.0 \
-lvtkParallelDIY-9.0 \
-lvtkRenderingAnnotation-9.0 \
-lvtkRenderingContext2D-9.0 \
-lvtkRenderingContextOpenGL2-9.0 \
-lvtkRenderingCore-9.0 \
-lvtkRenderingFreeType-9.0 \
-lvtkRenderingGL2PSOpenGL2-9.0 \
-lvtkRenderingImage-9.0 \
-lvtkRenderingLOD-9.0 \
-lvtkRenderingLabel-9.0 \
-lvtkRenderingOpenGL2-9.0 \
-lvtkRenderingSceneGraph-9.0 \
-lvtkRenderingUI-9.0 \
-lvtkRenderingVolume-9.0 \
-lvtkRenderingVolumeOpenGL2-9.0 \
-lvtkRenderingVtkJS-9.0 \
-lvtkTestingRendering-9.0 \
-lvtkViewsContext2D-9.0 \
-lvtkViewsCore-9.0 \
-lvtkViewsInfovis-9.0 \
-lvtkWrappingTools-9.0 \
-lvtkdoubleconversion-9.0 \
-lvtkexodusII-9.0 \
-lvtkexpat-9.0 \
-lvtkfreetype-9.0 \
-lvtkgl2ps-9.0 \
-lvtkglew-9.0 \
-lvtkhdf5-9.0 \
-lvtkhdf5_hl-9.0 \
-lvtkjpeg-9.0 \
-lvtkjsoncpp-9.0 \
-lvtklibharu-9.0 \
-lvtklibproj-9.0 \
-lvtklibxml2-9.0 \
-lvtkloguru-9.0 \
-lvtklz4-9.0 \
-lvtklzma-9.0 \
-lvtkmetaio-9.0 \
-lvtknetcdf-9.0 \
-lvtkogg-9.0 \
-lvtkpng-9.0 \
-lvtkpugixml-9.0 \
-lvtksqlite-9.0 \
-lvtksys-9.0 \
-lvtktheora-9.0 \
-lvtktiff-9.0 \
-lvtkverdict-9.0 \
-lvtkzlib-9.0
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
(2) 测试代码:
#include <iostream>
#include <string>
#include <pcl/common/io.h>
#include <pcl/io/pcd_io.h>
#include <pcl/kdtree/kdtree_flann.h>
#include <pcl/features/normal_3d_omp.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <boost/thread/thread.hpp>
int main(int argc, char *argv[])
{
std::string path = "D:\\Code\\complete.pcd";
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>());
if(pcl::io::loadPCDFile<pcl::PointXYZ>(path,*cloud) == -1){
PCL_ERROR("could not load pcd file");
return -1;
}
pcl::NormalEstimationOMP<pcl::PointXYZ,pcl::Normal> np;
pcl::PointCloud<pcl::Normal>::Ptr normals(new pcl::PointCloud<pcl::Normal>);
pcl::search::KdTree<pcl::PointXYZ>::Ptr kdtree(new pcl::search::KdTree<pcl::PointXYZ>);
np.setNumberOfThreads(4);
np.setInputCloud(cloud);
np.setSearchMethod(kdtree);
np.setKSearch(10);
np.compute(*normals);
pcl::visualization::PCLVisualizer viewer("3d viewer");
viewer.setWindowName("36d viewer");
viewer.setBackgroundColor(0.3,0.3,0.3);
viewer.addText("normals",10,50,255,0,0,"text");
viewer.addCoordinateSystem(0.1);
pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ> color(cloud,0,255,0);
viewer.addPointCloud<pcl::PointXYZ>(cloud,color,"input");
viewer.addPointCloudNormals<pcl::PointXYZ,pcl::Normal>(cloud,normals,10,1.0,"normals");
viewer.setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE,1,"input");
while(!viewer.wasStopped()){
viewer.spinOnce(10);
}
return 0;
}
(3)测试结果:
|