PCL+VS+Qt+Win10 的综合配置精华

· 前言

本文综合了许多前辈们的文章,取其精华,去其糟粕,精简为一篇讲解详细、内容全面的博客,供后来人能够少走弯路,更快的实现自己的目标。

电脑配置一览:Win10 / i7 7700 / HyperFury 16G 等

软件版本一览:VS2013 / PCL1.8.0(MSVC2013) / Qt5.7.0(MSVC2013) / QVTK7.0 / qt-vsaddin2.0 等


· 软件解读

这里用到的软件较多,博主已打包至百度云,请前往打包下载。软件内容如下(注:该文章以 MSVC2013 和 x64 为主线,所以涉及到有多版本的软件均已该版本为主,读者如果想用更高级的版本,一定要注意软件版本的一致性,否则会出现未知错误。以下内容重要的部分作者已标红):

  • VS2013 - 带破解秘钥1注:VS2013不区分32位、64位,所以读者如已安装则跳过,或者自行去官网下载
  • qt-vsaddin 安装文件2 (注:版本是 qt-vsaddin-msvc2013-2.2.0.vsix, 或者自行去官网下载)
  • Qt-MSVC2013安装软件3 (注:版本是 qt-opensource-windows-x86-msvc2013_64-5.7.0.exe ,或者自行去官网下载)
  • Debugger安装软件4 (注:这里用到的是 winsdksetup.exe,或者自行去官网下载)
  • QVTK插件5 (注:这里是两个文件: QVTKWidgetPlugin.dll 和 QVTKWidgetPlugin.lib ,这个请在云盘资源中获取,如果自行编译,请自行百度--- 微信关注【点云PCL】,有相关文章)
  • PCL安装文件6 (注:这里的PCL版本是 PCL-1.8.0-AllInOne-msvc2013-win64.exe,或者自行去官网下载)
  • VS配置PCL的props文件7 (注:这个只是参考,因个人配制而异)
  • PDB点云文件8 (注:点云测试文件)

注:一定要注意版本的一致性!!!安装需要注意的地方如下:
- Qt 安装默认安装,或者全选勾选框安装
- VS 直接安装即可,务必要安装 C++
- VS 插件 Qt-Addin 安装自动进行
- QVTK 插件下文用到再讲
- Debugger 安装软件用到再讲
- PCL 安装时,软件自动会安装到 ../PCL 1.8.0 位置,我们强制将路径修改为 ../PCL1.8.0 或者其他,核心是要去掉PCL和1.8.0之间空格!!!PCL安装路径不能有空格!!!PCL安装路径不能有空格!!!PCL安装路径不能有空格!!!


· VS + PCL 的配置与调试

目的:在 VS 中显示点云文件 ,这是PCL库最简单的使用方式

方法:请读者参考我的这篇博客,写的很详细


· Qt + PCL 的配置与调试

目的:在 Qt 中编辑并显示点云

方法:

第一步:傻瓜式的安装 Qt
第二步:安装 Windows 下的debugger 调试器
第三步:双击 winsdksetup.exe,只勾选 Debugging tools for Windows 安装

这里写图片描述

第四步:在 Qt -> 工具 -> 选项 中设置如下

这里写图片描述

这里写图片描述

此时会发现调试按钮已处于可用状态

这里写图片描述

第五步:配置 PCL 的环境,在 .pro 文件中添加如下配置

INCLUDEPATH += D:\PCL1.8_MSVC2013\3rdParty\OpenNI2\Include\
INCLUDEPATH += D:\PCL1.8_MSVC2013\include\pcl-1.8\
INCLUDEPATH += D:\PCL1.8_MSVC2013\3rdParty\Boost\include\boost-1_59\
INCLUDEPATH += D:\PCL1.8_MSVC2013\3rdParty\Eigen\eigen3\
INCLUDEPATH += D:\PCL1.8_MSVC2013\3rdParty\FLANN\include\
INCLUDEPATH += D:\PCL1.8_MSVC2013\3rdParty\Qhull\include\
INCLUDEPATH += D:\PCL1.8_MSVC2013\3rdParty\VTK\include\vtk-7.0\

CONFIG(debug,debug | release ){

LIBS += D:\PCL1.8_MSVC2013\lib\pcl_apps_debug.lib\
        D:\PCL1.8_MSVC2013\lib\pcl_common_debug.lib\
        D:\PCL1.8_MSVC2013\lib\pcl_features_debug.lib\
        D:\PCL1.8_MSVC2013\lib\pcl_filters_debug.lib\
        D:\PCL1.8_MSVC2013\lib\pcl_io_debug.lib\
        D:\PCL1.8_MSVC2013\lib\pcl_io_ply_debug.lib\
        D:\PCL1.8_MSVC2013\lib\pcl_kdtree_debug.lib\
        D:\PCL1.8_MSVC2013\lib\pcl_keypoints_debug.lib\
        D:\PCL1.8_MSVC2013\lib\pcl_ml_debug.lib\
        D:\PCL1.8_MSVC2013\lib\pcl_octree_debug.lib\
        D:\PCL1.8_MSVC2013\lib\pcl_outofcore_debug.lib\
        D:\PCL1.8_MSVC2013\lib\pcl_people_debug.lib\
        D:\PCL1.8_MSVC2013\lib\pcl_recognition_debug.lib\
        D:\PCL1.8_MSVC2013\lib\pcl_registration_debug.lib\
        D:\PCL1.8_MSVC2013\lib\pcl_sample_consensus_debug.lib\
        D:\PCL1.8_MSVC2013\lib\pcl_search_debug.lib\
        D:\PCL1.8_MSVC2013\lib\pcl_segmentation_debug.lib\
        D:\PCL1.8_MSVC2013\lib\pcl_simulation_debug.lib\
        D:\PCL1.8_MSVC2013\lib\pcl_stereo_debug.lib\
        D:\PCL1.8_MSVC2013\lib\pcl_surface_debug.lib\
        D:\PCL1.8_MSVC2013\lib\pcl_tracking_debug.lib\
        D:\PCL1.8_MSVC2013\lib\pcl_visualization_debug.lib\

LIBS += D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_atomic-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_chrono-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_container-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_context-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_coroutine-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_date_time-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_exception-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_filesystem-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_graph-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_iostreams-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_locale-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_log_setup-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_log-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_math_c99f-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_math_c99l-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_math_c99-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_math_tr1f-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_math_tr1l-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_math_tr1-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_mpi-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_prg_exec_monitor-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_program_options-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_random-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_regex-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_serialization-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_signals-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_system-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_test_exec_monitor-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_thread-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_timer-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_unit_test_framework-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_wave-vc120-mt-gd-1_59.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Boost\lib\libboost_wserialization-vc120-mt-gd-1_59.lib\
LIBS += D:\PCL1.8_MSVC2013\3rdParty\FLANN\lib\flann_cpp_s-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\FLANN\lib\flann_s-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\FLANN\lib\flann-gd.lib\
LIBS += D:\PCL1.8_MSVC2013\3rdParty\OpenNI2\Lib\OpenNI2.lib\
LIBS += D:\PCL1.8_MSVC2013\3rdParty\Qhull\lib\qhull_p-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Qhull\lib\qhull_r-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Qhull\lib\qhullcpp-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Qhull\lib\qhull-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Qhull\lib\qhullstatic_r-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\Qhull\lib\qhullstatic-gd.lib\
LIBS += D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkalglib-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkChartsCore-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkCommonColor-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkCommonComputationalGeometry-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkCommonCore-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkCommonDataModel-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkCommonExecutionModel-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkCommonMath-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkCommonMisc-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkCommonSystem-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkCommonTransforms-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkDICOMParser-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkDomainsChemistry-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkDomainsChemistryOpenGL2-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkexoIIc-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkexpat-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkFiltersAMR-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkFiltersCore-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkFiltersExtraction-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkFiltersFlowPaths-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkFiltersGeneral-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkFiltersGeneric-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkFiltersGeometry-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkFiltersHybrid-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkFiltersHyperTree-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkFiltersImaging-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkFiltersModeling-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkFiltersParallel-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkFiltersParallelImaging-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkFiltersProgrammable-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkFiltersSelection-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkFiltersSMP-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkFiltersSources-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkFiltersStatistics-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkFiltersTexture-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkFiltersVerdict-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkfreetype-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkGeovisCore-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkglew-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkGUISupportQt-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkGUISupportQtSQL-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkhdf5_hl-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkhdf5-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkImagingColor-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkImagingCore-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkImagingFourier-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkImagingGeneral-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkImagingHybrid-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkImagingMath-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkImagingMorphological-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkImagingSources-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkImagingStatistics-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkImagingStencil-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkInfovisCore-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkInfovisLayout-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkInteractionImage-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkInteractionStyle-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkInteractionWidgets-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkIOAMR-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkIOCore-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkIOEnSight-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkIOExodus-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkIOExport-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkIOGeometry-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkIOImage-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkIOImport-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkIOInfovis-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkIOLegacy-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkIOLSDyna-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkIOMINC-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkIOMovie-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkIONetCDF-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkIOParallel-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkIOParallelXML-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkIOPLY-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkIOSQL-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkIOVideo-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkIOXML-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkIOXMLParser-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkjpeg-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkjsoncpp-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtklibxml2-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkmetaio-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkNetCDF_cxx-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkNetCDF-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkoggtheora-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkParallelCore-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkpng-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkproj4-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkRenderingAnnotation-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkRenderingContext2D-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkRenderingContextOpenGL2-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkRenderingCore-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkRenderingFreeType-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkRenderingImage-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkRenderingLabel-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkRenderingLOD-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkRenderingOpenGL2-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkRenderingQt-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkRenderingVolume-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkRenderingVolumeOpenGL2-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtksqlite-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtksys-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtktiff-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkverdict-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkViewsContext2D-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkViewsCore-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkViewsInfovis-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkViewsQt-7.0-gd.lib\
        D:\PCL1.8_MSVC2013\3rdParty\VTK\lib\vtkzlib-7.0-gd.lib\

}else{

}

注:把上面的 D:\PCL1.8_MSVC2013\ 路径换为自己的安装路径

第六步:右键工程文件,执行 qmake !!!

第七步:测试代码,新建一个纯C++项目(plain C++ Application) ,写如下代码,运行

这里写图片描述

#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.0, 0.5, 1.0);
    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);

    //FIXME: possible race condition here:
    user_data++;
}

int main()
{
    pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZRGBA>);
    pcl::io::loadPCDFile("my_point_cloud.pcd", *cloud);

    pcl::visualization::CloudViewer viewer("Cloud Viewer");



    //blocks until the cloud is actually rendered
    viewer.showCloud(cloud);

    //use the following functions to get access to the underlying more advanced/powerful
    //PCLVisualizer

    //This will only get called once
    viewer.runOnVisualizationThreadOnce(viewerOneOff);

    //This will get called once per visualization iteration
    viewer.runOnVisualizationThread(viewerPsycho);
    while (!viewer.wasStopped())
    {
        //you can also do cool processing here
        //FIXME: Note that this is running in a separate thread from viewerPsycho
        //and you should guard against race conditions yourself...
        user_data++;
    }
    return 0;
}

配置成功,显示如下图:

这里写图片描述


· PCL + VS + Qt 的配置与使用

目的:使用 VS 的编辑器写代码,使用 QT 的界面显示点云

方法:

第一步:安装 qt-vsaddin-msvc2013-2.2.0.vsix ,这个插件的作用是用来调用 QtCreator、建立项目及其他操作,安装完毕后

这里写图片描述

第二步:配置 QT VS TOOLS ,选中 Qt Options

这里写图片描述

第三步:新建一个 Qt GUI Application , 命名为 PCLVisualizer

这里写图片描述

第四步:复制文件,将 QVTKWidgetPlugin.dll 和 QVTKWidgetPlugin.lib 复制到 D:\Qt\5.7\msvc2013_64\plugins\designer 下

这里写图片描述

注:QVTKWidgetPlugin 作用是充当显示点云的控件,QtCreator 本身没有显示点云的控件

第五步:双击 .ui 文件,看看有没有反应

这里写图片描述

注1:如果没有出现,则做以下修改:找到 D:\Qt\5.7\msvc2013_64\bin\Qt5WebEngineWidgets.dll ,修改成 Qt5WebEngineWidgets666.dll ,不知道这是一个什么神奇的bug
注2:如果还没有出现,右键 .ui 文件,选择打开方式,先移除 QtDesigner ,后重新添加 QtDesigner

这里写图片描述

这里写图片描述

第六步:写代码

一共涉及到4个文件,分别是

  • PCLViewer.h
  • PCLViewer.cpp
  • main.cpp
  • PCLViewer.ui

这里写图片描述

源代码的 Github 项目网址

#ifndef PCLVIEWER_H
#define PCLVIEWER_H

#include <iostream>

// Qt
#include <QMainWindow>

// Point Cloud Library
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/visualization/pcl_visualizer.h>

// Visualization Toolkit (VTK)
#include <vtkRenderWindow.h>

typedef pcl::PointXYZRGBA PointT;
typedef pcl::PointCloud<PointT> PointCloudT;

namespace Ui
{
    class PCLViewer;
}

class PCLViewer : public QMainWindow
{
    Q_OBJECT

public:
    explicit PCLViewer(QWidget *parent = 0);
    ~PCLViewer();

public Q_SLOTS:
    void randomButtonPressed();
    void RGBsliderReleased();
    void pSliderValueChanged(int value);
    void redSliderValueChanged(int value);
    void greenSliderValueChanged(int value);
    void blueSliderValueChanged(int value);

protected:
    boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer;
    PointCloudT::Ptr cloud;

    unsigned int red;
    unsigned int green;
    unsigned int blue;

private:
    Ui::PCLViewer *ui;

};

#endif // PCLVIEWER_H
#include "pclviewer.h"
#include "ui_pclviewer.h"

PCLViewer::PCLViewer(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::PCLViewer)
{
    ui->setupUi(this);
    this->setWindowTitle("PCL viewer");

    // Setup the cloud pointer
    cloud.reset(new PointCloudT);
    // The number of points in the cloud
    cloud->points.resize(200);

    // The default color
    red = 128;
    green = 128;
    blue = 128;

    // Fill the cloud with some points
    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);

        cloud->points[i].r = red;
        cloud->points[i].g = green;
        cloud->points[i].b = blue;
    }

    // Set up the QVTK window
    viewer.reset(new pcl::visualization::PCLVisualizer("viewer", false));
    ui->qvtkWidget->SetRenderWindow(viewer->getRenderWindow());
    viewer->setupInteractor(ui->qvtkWidget->GetInteractor(), ui->qvtkWidget->GetRenderWindow());
    ui->qvtkWidget->update();

    // Connect "random" button and the function
    connect(ui->pushButton_random, SIGNAL(clicked()), this, SLOT(randomButtonPressed()));

    // Connect R,G,B sliders and their functions
    connect(ui->horizontalSlider_R, SIGNAL(valueChanged(int)), this, SLOT(redSliderValueChanged(int)));
    connect(ui->horizontalSlider_G, SIGNAL(valueChanged(int)), this, SLOT(greenSliderValueChanged(int)));
    connect(ui->horizontalSlider_B, SIGNAL(valueChanged(int)), this, SLOT(blueSliderValueChanged(int)));
    connect(ui->horizontalSlider_R, SIGNAL(sliderReleased()), this, SLOT(RGBsliderReleased()));
    connect(ui->horizontalSlider_G, SIGNAL(sliderReleased()), this, SLOT(RGBsliderReleased()));
    connect(ui->horizontalSlider_B, SIGNAL(sliderReleased()), this, SLOT(RGBsliderReleased()));

    // Connect point size slider
    connect(ui->horizontalSlider_p, SIGNAL(valueChanged(int)), this, SLOT(pSliderValueChanged(int)));

    viewer->addPointCloud(cloud, "cloud");
    pSliderValueChanged(2);
    viewer->resetCamera();
    ui->qvtkWidget->update();
}

void PCLViewer::randomButtonPressed()
{
    printf("Random button was pressed\n");

    // Set the new color
    for (size_t i = 0; i < cloud->size(); i++)
    {
        cloud->points[i].r = 255 * (1024 * rand() / (RAND_MAX + 1.0f));
        cloud->points[i].g = 255 * (1024 * rand() / (RAND_MAX + 1.0f));
        cloud->points[i].b = 255 * (1024 * rand() / (RAND_MAX + 1.0f));
    }

    viewer->updatePointCloud(cloud, "cloud");
    ui->qvtkWidget->update();
}

void PCLViewer::RGBsliderReleased()
{
    // Set the new color
    for (size_t i = 0; i < cloud->size(); i++)
    {
        cloud->points[i].r = red;
        cloud->points[i].g = green;
        cloud->points[i].b = blue;
    }
    viewer->updatePointCloud(cloud, "cloud");
    ui->qvtkWidget->update();
}

void PCLViewer::pSliderValueChanged(int value)
{
    viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, value, "cloud");
    ui->qvtkWidget->update();
}

void PCLViewer::redSliderValueChanged(int value)
{
    red = value;
    printf("redSliderValueChanged: [%d|%d|%d]\n", red, green, blue);
}

void PCLViewer::greenSliderValueChanged(int value)
{
    green = value;
    printf("greenSliderValueChanged: [%d|%d|%d]\n", red, green, blue);
}

void PCLViewer::blueSliderValueChanged(int value)
{
    blue = value;
    printf("blueSliderValueChanged: [%d|%d|%d]\n", red, green, blue);
}

PCLViewer::~PCLViewer()
{
    delete ui;
}
#include "pclviewer.h"
#include <QApplication>
#include <QMainWindow>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    PCLViewer w;
    w.show();

    return a.exec();
}
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
  <class>PCLViewer</class>
  <widget class="QMainWindow" name="PCLViewer">
    <property name="geometry">
      <rect>
        <x>0</x>
        <y>0</y>
        <width>966</width>
        <height>499</height>
      </rect>
    </property>
    <property name="minimumSize">
      <size>
        <width>0</width>
        <height>0</height>
      </size>
    </property>
    <property name="maximumSize">
      <size>
        <width>5000</width>
        <height>5000</height>
      </size>
    </property>
    <property name="windowTitle">
      <string>PCLViewer</string>
    </property>
    <widget class="QWidget" name="centralwidget">
      <widget class="QVTKWidget" name="qvtkWidget" native="true">
        <property name="geometry">
          <rect>
            <x>300</x>
            <y>10</y>
            <width>640</width>
            <height>480</height>
          </rect>
        </property>
      </widget>
      <widget class="QSlider" name="horizontalSlider_R">
        <property name="geometry">
          <rect>
            <x>30</x>
            <y>60</y>
            <width>160</width>
            <height>29</height>
          </rect>
        </property>
        <property name="maximum">
          <number>255</number>
        </property>
        <property name="value">
          <number>128</number>
        </property>
        <property name="orientation">
          <enum>Qt::Horizontal</enum>
        </property>
      </widget>
      <widget class="QSlider" name="horizontalSlider_G">
        <property name="geometry">
          <rect>
            <x>30</x>
            <y>140</y>
            <width>160</width>
            <height>29</height>
          </rect>
        </property>
        <property name="maximum">
          <number>255</number>
        </property>
        <property name="value">
          <number>128</number>
        </property>
        <property name="orientation">
          <enum>Qt::Horizontal</enum>
        </property>
      </widget>
      <widget class="QSlider" name="horizontalSlider_B">
        <property name="geometry">
          <rect>
            <x>30</x>
            <y>220</y>
            <width>160</width>
            <height>29</height>
          </rect>
        </property>
        <property name="maximum">
          <number>255</number>
        </property>
        <property name="value">
          <number>128</number>
        </property>
        <property name="orientation">
          <enum>Qt::Horizontal</enum>
        </property>
      </widget>
      <widget class="QLCDNumber" name="lcdNumber_R">
        <property name="geometry">
          <rect>
            <x>200</x>
            <y>50</y>
            <width>81</width>
            <height>41</height>
          </rect>
        </property>
        <property name="digitCount">
          <number>3</number>
        </property>
        <property name="segmentStyle">
          <enum>QLCDNumber::Flat</enum>
        </property>
        <property name="intValue" stdset="0">
          <number>128</number>
        </property>
      </widget>
      <widget class="QLCDNumber" name="lcdNumber_G">
        <property name="geometry">
          <rect>
            <x>200</x>
            <y>130</y>
            <width>81</width>
            <height>41</height>
          </rect>
        </property>
        <property name="digitCount">
          <number>3</number>
        </property>
        <property name="segmentStyle">
          <enum>QLCDNumber::Flat</enum>
        </property>
        <property name="intValue" stdset="0">
          <number>128</number>
        </property>
      </widget>
      <widget class="QLCDNumber" name="lcdNumber_B">
        <property name="geometry">
          <rect>
            <x>200</x>
            <y>210</y>
            <width>81</width>
            <height>41</height>
          </rect>
        </property>
        <property name="digitCount">
          <number>3</number>
        </property>
        <property name="segmentStyle">
          <enum>QLCDNumber::Flat</enum>
        </property>
        <property name="intValue" stdset="0">
          <number>128</number>
        </property>
      </widget>
      <widget class="QSlider" name="horizontalSlider_p">
        <property name="geometry">
          <rect>
            <x>30</x>
            <y>320</y>
            <width>160</width>
            <height>29</height>
          </rect>
        </property>
        <property name="minimum">
          <number>1</number>
        </property>
        <property name="maximum">
          <number>6</number>
        </property>
        <property name="value">
          <number>2</number>
        </property>
        <property name="orientation">
          <enum>Qt::Horizontal</enum>
        </property>
      </widget>
      <widget class="QLCDNumber" name="lcdNumber_p">
        <property name="geometry">
          <rect>
            <x>200</x>
            <y>310</y>
            <width>81</width>
            <height>41</height>
          </rect>
        </property>
        <property name="digitCount">
          <number>1</number>
        </property>
        <property name="segmentStyle">
          <enum>QLCDNumber::Flat</enum>
        </property>
        <property name="intValue" stdset="0">
          <number>2</number>
        </property>
      </widget>
      <widget class="QLabel" name="label">
        <property name="geometry">
          <rect>
            <x>30</x>
            <y>20</y>
            <width>191</width>
            <height>31</height>
          </rect>
        </property>
        <property name="font">
          <font>
            <pointsize>16</pointsize>
            <weight>50</weight>
            <italic>false</italic>
            <bold>false</bold>
          </font>
        </property>
        <property name="text">
          <string>Red component</string>
        </property>
      </widget>
      <widget class="QLabel" name="label_2">
        <property name="geometry">
          <rect>
            <x>30</x>
            <y>100</y>
            <width>191</width>
            <height>31</height>
          </rect>
        </property>
        <property name="font">
          <font>
            <pointsize>16</pointsize>
            <weight>50</weight>
            <italic>false</italic>
            <bold>false</bold>
          </font>
        </property>
        <property name="text">
          <string>Green component</string>
        </property>
      </widget>
      <widget class="QLabel" name="label_3">
        <property name="geometry">
          <rect>
            <x>30</x>
            <y>190</y>
            <width>191</width>
            <height>31</height>
          </rect>
        </property>
        <property name="font">
          <font>
            <pointsize>16</pointsize>
            <weight>50</weight>
            <italic>false</italic>
            <bold>false</bold>
          </font>
        </property>
        <property name="text">
          <string>Blue component</string>
        </property>
      </widget>
      <widget class="QLabel" name="label_4">
        <property name="geometry">
          <rect>
            <x>30</x>
            <y>280</y>
            <width>141</width>
            <height>31</height>
          </rect>
        </property>
        <property name="font">
          <font>
            <pointsize>16</pointsize>
            <weight>50</weight>
            <italic>false</italic>
            <bold>false</bold>
          </font>
        </property>
        <property name="text">
          <string>Point size</string>
        </property>
      </widget>
      <widget class="QPushButton" name="pushButton_random">
        <property name="geometry">
          <rect>
            <x>40</x>
            <y>370</y>
            <width>201</width>
            <height>81</height>
          </rect>
        </property>
        <property name="text">
          <string>Random colors</string>
        </property>
      </widget>
    </widget>
  </widget>
  <customwidgets>
    <customwidget>
      <class>QVTKWidget</class>
      <extends>QWidget</extends>
      <header>QVTKWidget.h</header>
    </customwidget>
  </customwidgets>
  <resources/>
  <connections>
    <connection>
      <sender>horizontalSlider_R</sender>
      <signal>sliderMoved(int)</signal>
      <receiver>lcdNumber_R</receiver>
      <slot>display(int)</slot>
      <hints>
        <hint type="sourcelabel">
          <x>136</x>
          <y>111</y>
        </hint>
        <hint type="destinationlabel">
          <x>222</x>
          <y>115</y>
        </hint>
      </hints>
    </connection>
    <connection>
      <sender>horizontalSlider_G</sender>
      <signal>sliderMoved(int)</signal>
      <receiver>lcdNumber_G</receiver>
      <slot>display(int)</slot>
      <hints>
        <hint type="sourcelabel">
          <x>166</x>
          <y>193</y>
        </hint>
        <hint type="destinationlabel">
          <x>235</x>
          <y>195</y>
        </hint>
      </hints>
    </connection>
    <connection>
      <sender>horizontalSlider_B</sender>
      <signal>sliderMoved(int)</signal>
      <receiver>lcdNumber_B</receiver>
      <slot>display(int)</slot>
      <hints>
        <hint type="sourcelabel">
          <x>185</x>
          <y>273</y>
        </hint>
        <hint type="destinationlabel">
          <x>224</x>
          <y>275</y>
        </hint>
      </hints>
    </connection>
    <connection>
      <sender>horizontalSlider_p</sender>
      <signal>sliderMoved(int)</signal>
      <receiver>lcdNumber_p</receiver>
      <slot>display(int)</slot>
      <hints>
        <hint type="sourcelabel">
          <x>136</x>
          <y>352</y>
        </hint>
        <hint type="destinationlabel">
          <x>253</x>
          <y>342</y>
        </hint>
      </hints>
    </connection>
  </connections>
</ui>

源代码的 Github 项目网址
PCLViewer.ui 的打开方式选择见下图

这里写图片描述

最后一步:运行程序,如果出现下图则完美了

这里写图片描述

尽管最终的代码编辑区可能还会报错,但是不影响程序的运行!!!这可能是兼容性不好遗留的问题!!!

这里写图片描述


· 问题大汇总

在这里我仅仅展示我遇到的、我想到的一些可能的出错点,供大家参考,具体请发送问题到我邮箱 [email protected]

  • Qt、VS、QT VS TOOLS 的版本是否一致,是否都是 MSVC2013
  • PCL 的安装路径是否有空格,有没有强制修改路径
  • Qt5WebEngineWidgets.dll 有没有重命名
  • QVTKWidgetPlugin.dll 和 QVTKWidgetPlugin.lib 有没有复制过去
  • 自己 cmake 的 QVTKWidgetPlugin.dll 和 QVTKWidgetPlugin.lib 是否有问题
  • .pro 文件有没有重新 qmake
  • 有没有在新修改环境变量后重启电脑或者是重启软件
  • 有没有忘记添加 .props 配置文件
  • 添加 .props 文件后,有没有在工程属性添加环境:$PATH=...$PATH
  • PCL 是不是用的 ALLINONE + MSVC2013 的版本
  • OCL 的 OPENNI2 有没有正确安装到指定路径
  • PCL 的环境配置有没有错
  • VS 运行程序是否选择的 debug 模式和 x64 模式
  • 代码(类名)是否有错
  • ……

暂且就想到这么多,失败是成功之母,失败后请大家耐心配置


· 参考博客

  1. PCL+Qt+VS可视化点云
  2. PCL1.8.0在VS2013和Qt5.7.1上的配置安装小结
  3. Qt5.7 + VS2015 环境搭建
  4. 解决qt调试时Unknown debugger type “No Engine”
  5. QT之防止程序重复运行方法
  6. Qt5+PCL1.7.2 allinone版本的配置
  7. 等等等

· 联系作者

邮箱:[email protected] , 评论可能不会及时回复

总决赛 G3 勇士目前落后 1 分

最后编辑于 2018-6-7 9:40


  1. VS 宇宙最强IDE,不多说
  2. 安装该插件后,能在 VS 中调用 QtDesigner
  3. Qt ,轻量级带有界面的 IDE
  4. Qt 不自带调试器,安装 Debugger 后可以在 Qt 内调试代码
  5. QVTK 插件,用于显示点云的控件
  6. PCL,开源的点云库
  7. .props PCL配置文件
  8. PDB 点云文件

猜你喜欢

转载自blog.csdn.net/qq_34719188/article/details/80601642
今日推荐