一、随便扯扯的概述(当故事看。。。。纯属话多)
经过短暂的但又痛苦而煎熬的大三阶段,参加了大大小小各种比赛,拿了各种奖项和著作权,终于保研到本校,结果让人有开心又不甘,但是我一向都既来之则安之。研究生阶段的导师比较年轻,要求严格,已经让我从现在开始跟着他做项目了,但我对计算机图形学方向一无所知,看了好几周的论文只看了两篇,都还没完全看懂,然后开始让我实现代码,所以我就开始了为期三天的环境配置,真的让人头大,不过也是学到了很多东西。
二、环境配置
先说明一下,我在配置环境的过程中反反复复下载了2个版本的QT,2个版本的visual studio和不知道多少版本的PCL。最后经过各种错误,几乎翻遍了网上所有的教程,终于弄成功了。
这里介绍的是QT 5.9.3+vs2013+PCL 1.8.0版本的。这里重点注意一下!!!vc的版本和PCL的版本还有QT的版本一定要一致,另外32位和64位也要一致,否则最后弄了一大堆之后会出现很多问题。这个QT5.9.3中有QT msvc2013 64位的,vs2013有vc12运行库(可能有其他方法直接安装vc12的运行库,不用整个下载vs吧,我为了方便直接下载了个vs2013),PCL1.8.0选的是64位(这里尽量选择1.8.0版本的吧,别的版本我安装了好几个,发现里面没有OpenNI2这个构件)。
1、 首先下载安装vs2013,这个直接百度“vs2013安装教程”就可以了,很简单,但是安装的时间可能有点长,我装了大概两个小时吧,慢慢等,不要急。
2、 下载qt-opensource-windows-x86-5.9.3.exe,这个去 https://download.qt.io/archive/qt/ 下载,下载完成后双击安装,一路默认安装就好。安装完成后打开,选择 工具——>选项——>构建和运行——>编译器 就可以发现系统自动检测到了msvc12版本的编译器,如图:
3、下载PCL-1.8.0-AllInOne-msvc2013-win64.exe,下载地址链接:https://pan.baidu.com/s/1FXsjzRuQlRD4xoZYBlS5ZA
提取码:mkwj ,安装的时候注意 选择添加路径到系统环境变量(英文好像是 add path to .... for all users,记不太清了。。。),安装路径里需要把C:\**\PCL 1.8.0这里的空格删掉,据说是QT识别不出空格路径。在安装的过程中,先会提示 path too long,路径添加失败,不用管,点确认,然后会弹出OpenNI2 SDK的安装窗口,选择路径为C:\**\PCL1.8.0\3rdParty\OpenNI2,点击安装,等待安装完成。安装好之后记得要添加环境变量,如图:
添加完环境变量之后需要重启计算机。
4、 打开QT,新建简单控制台程序,在.pro文件里添加以下内容(注意路径需要根据自己的情况改变)
INCLUDEPATH += C:/Tool/PCL1.8.0/include/pcl-1.8\
INCLUDEPATH += C:/Tool/PCL1.8.0/include/pcl-1.8/pcl\
INCLUDEPATH += C:/Tool/PCL1.8.0/3rdParty/Boost/include/boost-1_59\
INCLUDEPATH += C:/Tool/PCL1.8.0/3rdParty/Eigen/eigen3\
INCLUDEPATH += C:/Tool/PCL1.8.0/3rdParty/FLANN/include\
INCLUDEPATH += C:/Tool/PCL1.8.0/3rdParty/FLANN/include/flann\
INCLUDEPATH += C:/Tool/PCL1.8.0/3rdParty/OpenNI2/Include\
INCLUDEPATH += C:/Tool/PCL1.8.0/3rdParty/Qhull/include\
INCLUDEPATH += C:/Tool/PCL1.8.0/3rdParty/VTK/include/vtk-7.0\
CONFIG(debug,debug|release){
LIBS += -LC:/Tool/PCL1.8.0/lib\
# -lpcl_apps_debug\
-lpcl_common_debug\
-lpcl_features_debug\
-lpcl_filters_debug\
-lpcl_io_debug\
-lpcl_io_ply_debug\
-lpcl_kdtree_debug\
-lpcl_keypoints_debug\
-lpcl_ml_debug\
-lpcl_octree_debug\
-lpcl_outofcore_debug\
-lpcl_people_debug\
-lpcl_recognition_debug\
-lpcl_registration_debug\
-lpcl_sample_consensus_debug\
-lpcl_search_debug\
-lpcl_segmentation_debug\
# -lpcl_simulation_debug\
-lpcl_stereo_debug\
-lpcl_surface_debug\
-lpcl_tracking_debug\
-lpcl_visualization_debug\
LIBS += -LC:/Tool/PCL1.8.0/3rdParty/Boost/lib\
-llibboost_atomic-vc120-mt-gd-1_59\
-llibboost_chrono-vc120-mt-gd-1_59\
-llibboost_container-vc120-mt-gd-1_59\
-llibboost_context-vc120-mt-gd-1_59\
-llibboost_coroutine-vc120-mt-gd-1_59\
-llibboost_date_time-vc120-mt-gd-1_59\
-llibboost_exception-vc120-mt-gd-1_59\
-llibboost_filesystem-vc120-mt-gd-1_59\
-llibboost_graph-vc120-mt-gd-1_59\
-llibboost_iostreams-vc120-mt-gd-1_59\
-llibboost_locale-vc120-mt-gd-1_59\
-llibboost_log-vc120-mt-gd-1_59\
-llibboost_log_setup-vc120-mt-gd-1_59\
-llibboost_math_c99-vc120-mt-gd-1_59\
-llibboost_math_c99f-vc120-mt-gd-1_59\
-llibboost_math_c99l-vc120-mt-gd-1_59\
-llibboost_math_tr1-vc120-mt-gd-1_59\
-llibboost_math_tr1f-vc120-mt-gd-1_59\
-llibboost_math_tr1l-vc120-mt-gd-1_59\
-llibboost_mpi-vc120-mt-gd-1_59\
-llibboost_prg_exec_monitor-vc120-mt-gd-1_59\
-llibboost_program_options-vc120-mt-gd-1_59\
-llibboost_random-vc120-mt-gd-1_59\
-llibboost_regex-vc120-mt-gd-1_59\
-llibboost_serialization-vc120-mt-gd-1_59\
-llibboost_signals-vc120-mt-gd-1_59\
-llibboost_system-vc120-mt-gd-1_59\
-llibboost_test_exec_monitor-vc120-mt-gd-1_59\
-llibboost_thread-vc120-mt-gd-1_59\
-llibboost_timer-vc120-mt-gd-1_59\
-llibboost_unit_test_framework-vc120-mt-gd-1_59\
-llibboost_wave-vc120-mt-gd-1_59\
-llibboost_wserialization-vc120-mt-gd-1_59
LIBS += -LC:/Tool/PCL1.8.0/3rdParty/FLANN/lib\
-lflann-gd\
-lflann_cpp_s-gd\
-lflann_s-gd
LIBS += -LC:/Tool/PCL1.8.0/3rdParty/OpenNI2/Lib\
-lOpenNI2
LIBS += -LC:/Tool/PCL1.8.0/3rdParty/Qhull/lib\
-lqhull-gd\
-lqhullcpp-gd\
-lqhullstatic-gd\
-lqhullstatic_r-gd\
-lqhull_p-gd\
-lqhull_r-gd
LIBS += -LC:\Tool\PCL1.8.0\3rdParty\VTK\lib\
-lvtkalglib-7.0-gd\
-lvtkChartsCore-7.0-gd\
-lvtkCommonColor-7.0-gd\
-lvtkCommonComputationalGeometry-7.0-gd\
-lvtkCommonCore-7.0-gd\
-lvtkCommonDataModel-7.0-gd\
-lvtkCommonExecutionModel-7.0-gd\
-lvtkCommonMath-7.0-gd\
-lvtkCommonMisc-7.0-gd\
-lvtkCommonSystem-7.0-gd\
-lvtkCommonTransforms-7.0-gd\
-lvtkDICOMParser-7.0-gd\
-lvtkDomainsChemistry-7.0-gd\
-lvtkDomainsChemistryOpenGL2-7.0-gd\
-lvtkexoIIc-7.0-gd\
-lvtkexpat-7.0-gd\
-lvtkFiltersAMR-7.0-gd\
-lvtkFiltersCore-7.0-gd\
-lvtkFiltersExtraction-7.0-gd\
-lvtkFiltersFlowPaths-7.0-gd\
-lvtkFiltersGeneral-7.0-gd\
-lvtkFiltersGeneric-7.0-gd\
-lvtkFiltersGeometry-7.0-gd\
-lvtkFiltersHybrid-7.0-gd\
-lvtkFiltersHyperTree-7.0-gd\
-lvtkFiltersImaging-7.0-gd\
-lvtkFiltersModeling-7.0-gd\
-lvtkFiltersParallel-7.0-gd\
-lvtkFiltersParallelImaging-7.0-gd\
-lvtkFiltersProgrammable-7.0-gd\
-lvtkFiltersSelection-7.0-gd\
-lvtkFiltersSMP-7.0-gd\
-lvtkFiltersSources-7.0-gd\
-lvtkFiltersStatistics-7.0-gd\
-lvtkFiltersTexture-7.0-gd\
-lvtkFiltersVerdict-7.0-gd\
-lvtkfreetype-7.0-gd\
-lvtkGeovisCore-7.0-gd\
-lvtkglew-7.0-gd\
-lvtkGUISupportQt-7.0-gd\
-lvtkGUISupportQtSQL-7.0-gd\
-lvtkhdf5-7.0-gd\
-lvtkhdf5_hl-7.0-gd\
-lvtkImagingColor-7.0-gd\
-lvtkImagingCore-7.0-gd\
-lvtkImagingFourier-7.0-gd\
-lvtkImagingGeneral-7.0-gd\
-lvtkImagingHybrid-7.0-gd\
-lvtkImagingMath-7.0-gd\
-lvtkImagingMorphological-7.0-gd\
-lvtkImagingSources-7.0-gd\
-lvtkImagingStatistics-7.0-gd\
-lvtkImagingStencil-7.0-gd\
-lvtkInfovisCore-7.0-gd\
-lvtkInfovisLayout-7.0-gd\
-lvtkInteractionImage-7.0-gd\
-lvtkInteractionStyle-7.0-gd\
-lvtkInteractionWidgets-7.0-gd\
-lvtkIOAMR-7.0-gd\
-lvtkIOCore-7.0-gd\
-lvtkIOEnSight-7.0-gd\
-lvtkIOExodus-7.0-gd\
-lvtkIOExport-7.0-gd\
-lvtkIOGeometry-7.0-gd\
-lvtkIOImage-7.0-gd\
-lvtkIOImport-7.0-gd\
-lvtkIOInfovis-7.0-gd\
-lvtkIOLegacy-7.0-gd\
-lvtkIOLSDyna-7.0-gd\
-lvtkIOMINC-7.0-gd\
-lvtkIOMovie-7.0-gd\
-lvtkIONetCDF-7.0-gd\
-lvtkIOParallel-7.0-gd\
-lvtkIOParallelXML-7.0-gd\
-lvtkIOPLY-7.0-gd\
-lvtkIOSQL-7.0-gd\
-lvtkIOVideo-7.0-gd\
-lvtkIOXML-7.0-gd\
-lvtkIOXMLParser-7.0-gd\
-lvtkjpeg-7.0-gd\
-lvtkjsoncpp-7.0-gd\
-lvtklibxml2-7.0-gd\
-lvtkmetaio-7.0-gd\
-lvtkNetCDF-7.0-gd\
-lvtkNetCDF_cxx-7.0-gd\
-lvtkoggtheora-7.0-gd\
-lvtkParallelCore-7.0-gd\
-lvtkpng-7.0-gd\
-lvtkproj4-7.0-gd\
-lvtkRenderingAnnotation-7.0-gd\
-lvtkRenderingContext2D-7.0-gd\
-lvtkRenderingContextOpenGL2-7.0-gd\
-lvtkRenderingCore-7.0-gd\
-lvtkRenderingFreeType-7.0-gd\
-lvtkRenderingImage-7.0-gd\
-lvtkRenderingLabel-7.0-gd\
-lvtkRenderingLOD-7.0-gd\
-lvtkRenderingOpenGL2-7.0-gd\
-lvtkRenderingQt-7.0-gd\
-lvtkRenderingVolume-7.0-gd\
-lvtkRenderingVolumeOpenGL2-7.0-gd\
-lvtksqlite-7.0-gd\
-lvtksys-7.0-gd\
-lvtktiff-7.0-gd\
-lvtkverdict-7.0-gd\
-lvtkViewsContext2D-7.0-gd\
-lvtkViewsCore-7.0-gd\
-lvtkViewsInfovis-7.0-gd\
-lvtkViewsQt-7.0-gd\
-lvtkzlib-7.0-gd
} else {
LIBS += -LC:/Tool/PCL1.8.0/lib\
-lpcl_apps_release\
-lpcl_common_release\
-lpcl_features_release\
-lpcl_filters_release\
-lpcl_io_release\
-lpcl_io_ply_release\
-lpcl_kdtree_release\
-lpcl_keypoints_release\
-lpcl_ml_release\
-lpcl_octree_release\
-lpcl_outofcore_release\
-lpcl_people_release\
-lpcl_recognition_release\
-lpcl_registration_release\
-lpcl_sample_consensus_release\
-lpcl_search_release\
-lpcl_segmentation_release\
-lpcl_simulation_release\
-lpcl_stereo_release\
-lpcl_surface_release\
-lpcl_tracking_release\
-lpcl_visualization_release\
LIBS += -LC:/Tool/PCL1.8.0/3rdParty/Boost/lib\
-llibboost_atomic-vc120-mt-1_59\
-llibboost_chrono-vc120-mt-1_59\
-llibboost_container-vc120-mt-1_59\
-llibboost_context-vc120-mt-1_59\
-llibboost_coroutine-vc120-mt-1_59\
-llibboost_date_time-vc120-mt-1_59\
-llibboost_exception-vc120-mt-1_59\
-llibboost_filesystem-vc120-mt-1_59\
-llibboost_graph-vc120-mt-1_59\
-llibboost_iostreams-vc120-mt-1_59\
-llibboost_locale-vc120-mt-1_59\
-llibboost_log-vc120-mt-1_59\
-llibboost_log_setup-vc120-mt-1_59\
-llibboost_math_c99-vc120-mt-1_59\
-llibboost_math_c99f-vc120-mt-1_59\
-llibboost_math_c99l-vc120-mt-1_59\
-llibboost_math_tr1-vc120-mt-1_59\
-llibboost_math_tr1f-vc120-mt-1_59\
-llibboost_math_tr1l-vc120-mt-1_59\
-llibboost_mpi-vc120-mt-1_59\
-llibboost_prg_exec_monitor-vc120-mt-1_59\
-llibboost_program_options-vc120-mt-1_59\
-llibboost_random-vc120-mt-1_59\
-llibboost_regex-vc120-mt-1_59\
-llibboost_serialization-vc120-mt-1_59\
-llibboost_signals-vc120-mt-1_59\
-llibboost_system-vc120-mt-1_59\
-llibboost_test_exec_monitor-vc120-mt-1_59\
-llibboost_thread-vc120-mt-1_59\
-llibboost_timer-vc120-mt-1_59\
-llibboost_unit_test_framework-vc120-mt-1_59\
-llibboost_wave-vc120-mt-1_59\
-llibboost_wserialization-vc120-mt-1_59
LIBS += -LC:/Tool/PCL1.8.0/3rdParty/FLANN/lib\
-lflann\
-lflann_cpp_s\
-lflann_s
LIBS += -LC:/Tool/PCL1.8.0/3rdParty/OpenNI2/Lib\
-lOpenNI2
LIBS += -LC:/Tool/PCL1.8.0/3rdParty/Qhull/lib\
-lqhull\
-lqhullcpp\
-lqhullstatic\
-lqhullstatic_r\
-lqhull_p\
-lqhull_r
LIBS += -LC:\Tool\PCL1.8.0\3rdParty\VTK\lib\
-lvtkalglib-7.0\
-lvtkChartsCore-7.0\
-lvtkCommonColor-7.0\
-lvtkCommonComputationalGeometry-7.0\
-lvtkCommonCore-7.0\
-lvtkCommonDataModel-7.0\
-lvtkCommonExecutionModel-7.0\
-lvtkCommonMath-7.0\
-lvtkCommonMisc-7.0\
-lvtkCommonSystem-7.0\
-lvtkCommonTransforms-7.0\
-lvtkDICOMParser-7.0\
-lvtkDomainsChemistry-7.0\
-lvtkDomainsChemistryOpenGL2-7.0\
-lvtkexoIIc-7.0\
-lvtkexpat-7.0\
-lvtkFiltersAMR-7.0\
-lvtkFiltersCore-7.0\
-lvtkFiltersExtraction-7.0\
-lvtkFiltersFlowPaths-7.0\
-lvtkFiltersGeneral-7.0\
-lvtkFiltersGeneric-7.0\
-lvtkFiltersGeometry-7.0\
-lvtkFiltersHybrid-7.0\
-lvtkFiltersHyperTree-7.0\
-lvtkFiltersImaging-7.0\
-lvtkFiltersModeling-7.0\
-lvtkFiltersParallel-7.0\
-lvtkFiltersParallelImaging-7.0\
-lvtkFiltersProgrammable-7.0\
-lvtkFiltersSelection-7.0\
-lvtkFiltersSMP-7.0\
-lvtkFiltersSources-7.0\
-lvtkFiltersStatistics-7.0\
-lvtkFiltersTexture-7.0\
-lvtkFiltersVerdict-7.0\
-lvtkfreetype-7.0\
-lvtkGeovisCore-7.0\
-lvtkglew-7.0\
-lvtkGUISupportQt-7.0\
-lvtkGUISupportQtSQL-7.0\
-lvtkhdf5-7.0\
-lvtkhdf5_hl-7.0\
-lvtkImagingColor-7.0\
-lvtkImagingCore-7.0\
-lvtkImagingFourier-7.0\
-lvtkImagingGeneral-7.0\
-lvtkImagingHybrid-7.0\
-lvtkImagingMath-7.0\
-lvtkImagingMorphological-7.0\
-lvtkImagingSources-7.0\
-lvtkImagingStatistics-7.0\
-lvtkImagingStencil-7.0\
-lvtkInfovisCore-7.0\
-lvtkInfovisLayout-7.0\
-lvtkInteractionImage-7.0\
-lvtkInteractionStyle-7.0\
-lvtkInteractionWidgets-7.0\
-lvtkIOAMR-7.0\
-lvtkIOCore-7.0\
-lvtkIOEnSight-7.0\
-lvtkIOExodus-7.0\
-lvtkIOExport-7.0\
-lvtkIOGeometry-7.0\
-lvtkIOImage-7.0\
-lvtkIOImport-7.0\
-lvtkIOInfovis-7.0\
-lvtkIOLegacy-7.0\
-lvtkIOLSDyna-7.0\
-lvtkIOMINC-7.0\
-lvtkIOMovie-7.0\
-lvtkIONetCDF-7.0\
-lvtkIOParallel-7.0\
-lvtkIOParallelXML-7.0\
-lvtkIOPLY-7.0\
-lvtkIOSQL-7.0\
-lvtkIOVideo-7.0\
-lvtkIOXML-7.0\
-lvtkIOXMLParser-7.0\
-lvtkjpeg-7.0\
-lvtkjsoncpp-7.0\
-lvtklibxml2-7.0\
-lvtkmetaio-7.0\
-lvtkNetCDF-7.0\
-lvtkNetCDF_cxx-7.0\
-lvtkoggtheora-7.0\
-lvtkParallelCore-7.0\
-lvtkpng-7.0\
-lvtkproj4-7.0\
-lvtkRenderingAnnotation-7.0\
-lvtkRenderingContext2D-7.0\
-lvtkRenderingContextOpenGL2-7.0\
-lvtkRenderingCore-7.0\
-lvtkRenderingFreeType-7.0\
-lvtkRenderingImage-7.0\
-lvtkRenderingLabel-7.0\
-lvtkRenderingLOD-7.0\
-lvtkRenderingOpenGL2-7.0\
-lvtkRenderingQt-7.0\
-lvtkRenderingVolume-7.0\
-lvtkRenderingVolumeOpenGL2-7.0\
-lvtksqlite-7.0\
-lvtksys-7.0\
-lvtktiff-7.0\
-lvtkverdict-7.0\
-lvtkViewsContext2D-7.0\
-lvtkViewsCore-7.0\
-lvtkViewsInfovis-7.0\
-lvtkViewsQt-7.0\
-lvtkzlib-7.0
}
对了,我下载的是64位的PCL,里面没有pcl_apps_debug.lib和pcl_simulation_debug.lib这两个文件,所以我注释掉了,别的版本可能有,就加上。这里有个小技巧,在更换路径的时候,可以直接ctrl+F,然后replace all就可以了,因为PCL1.*.*里的文件路径一样,只需要改上级目录。
接下来就是进行测试的代码了,可以自己找一个点云文件,我这也有,链接:https://pan.baidu.com/s/1z5fuyGjWDSiYNUldQuXiqA 提取码:6bdy ,代码如下:
#include
#include
#include
#include
#include
#include
#include
using namespace std;
int main()
{
pcl::PointCloud::Ptr cloud(new pcl::PointCloud);
if (pcl::io::loadPLYFile("bunny.ply", *cloud) == -1) //* load the file
{
PCL_ERROR("Couldn't read file test_pcd.pcd \n");
system("PAUSE");
return (-1);
}
pcl::visualization::CloudViewer viewer("Viewer");
viewer.showCloud(cloud);
system("PAUSE");
return (0);
}
注意一下,这里把bunny.ply文件放到工程文件夹下。
接下来又是一个重点,不能直接点编译运行,需要先配置构建套件。选择 工具——>选项——>构建和运行——>构建套件 如图
可以自己手动添加,选择添加,然后命名,选择对应的编译器和QT版本,我这里都是msvc2013的。
注意(又来个注意)!!!这里调试器可能有的人没有windows的Debugger\x64\cdb.exe,所以需要去下载,下载地址:https://developer.microsoft.com/en-us/windows/downloads/sdk-archive,我是win10的系统,所以下载的是Fall Creators Update这个版本,根据需要自行选择。
默认安装好之后,QT里可以自动检测出来,如果没有检测出来,可以手动添加,选择目录下的cdb.exe就好。
到这里构建套件设置好之后,点击QT右侧 项目 选项,选择刚刚配置好的构建套件进行构建,就可以了。如图:
运行效果如下
因为看的教程太多了,也不知道具体感谢哪些,就都感谢一下吧。这里代码来源:https://blog.csdn.net/eric_e/article/details/80686978,非常感谢。