0、绪论与摘要
因为现在的工作更多做得是三维方面的东西了,在三维上做检测,所以PCL
库必不可少,至于为什么是在windows
下面用vs2019
,那就是我的工作环境确实就是windows
下面啊,我现在对于cmake
也不是很熟,在windows
下面我还驾驭不了,所以先用着vs2019
呗,不得不吐槽,在这个环境下配置PCL
真的好麻烦。
0.1 主要参考网页
PCL安装与配置(Windows10+VS2017 )
PCL安装及配置教程,其他的安装教程也基本大同小异。
在vs中配置pcl报错:C2116和C2733,针对按照上文所述的方法安装完成后调试出现错误的问题。
本文直接引用了上述网页中的部分图片。
1、下载与安装
1.1 下载
日语官网
英语官网
百度云1.8版本链接,提取码:qyyg,来源于PCL安装与配置(Windows10+VS2017 )所提供。
1.2 安装
除了图中所示部分外,建议一路next
:
注意!注意!注意!
安装过程中,会弹出OpenNI
的安装程序,更改OpenNI
的安装路径为你安装的PCL
路径下的3rdParty
文件夹下的OpenNI2
文件夹中。
2、配置
2.1 环境变量中的的系统变量
如果你的图1部分选的是下面两项,则你的系统变量当中会添加如下内容,由于一些操作上的原因,我的值可能有所不同。
然后,我们双击系统变量中的Path
,再将以下的目录添加到Path
中(注意最后一个OpenNI2的路径,要和自己刚刚安装的路径一样才行):
%PCL_ROOT%\bin
%PCL_ROOT%\3rdParty\VTK\bin
%PCL_ROOT%\3rdParty\FLANN\bin
%OPENNI2_REDIST64%
%PCL_ROOT%\3rdParty\Qhull\bin
%PCL_ROOT%\3rdParty\OpenNI2\Tools
2.2 vs2019中环境配置
创建项目,选择位数和模式
2.2.1 包含目录
根据自己的实际安装路径进行修改,比如我的就有所不同。
C:\Program Files\PCL_1_8_1\3rdParty\OpenNI2\Include
C:\Program Files\PCL_1_8_1\include\pcl-1.8
C:\Program Files\PCL_1_8_1\3rdParty\VTK\include\vtk-8.0
C:\Program Files\PCL_1_8_1\3rdParty\QHull\include
C:\Program Files\PCL_1_8_1\3rdParty\FLANN\include
C:\Program Files\PCL_1_8_1\3rdParty\Eigen\eigen3
C:\Program Files\PCL_1_8_1\3rdParty\Boost\include\boost-1_64
2.2.2 lib目录
根据自己的实际安装路径进行修改,比如我的就有所不同。
C:\Program Files\PCL_1_8_1\3rdParty\OpenNI2\Lib
C:\Program Files\PCL_1_8_1\3rdParty\VTK\lib
C:\Program Files\PCL_1_8_1\3rdParty\Qhull\lib
C:\Program Files\PCL_1_8_1\3rdParty\FLANN\lib
C:\Program Files\PCL_1_8_1\3rdParty\Boost\lib
C:\Program Files\PCL_1_8_1\lib
2.2.3 debug版本的附加依赖项
就是把安装目录下的所有没有release
的lib
都扔进去。
vtknetcdf_c++-gd.lib
pcl_common_debug.lib
pcl_features_debug.lib
pcl_filters_debug.lib
pcl_io_ply_debug.lib
pcl_io_debug.lib
pcl_kdtree_debug.lib
pcl_keypoints_debug.lib
pcl_ml_debug.lib
pcl_octree_debug.lib
pcl_outofcore_debug.lib
pcl_people_debug.lib
pcl_recognition_debug.lib
pcl_registration_debug.lib
pcl_sample_consensus_debug.lib
pcl_search_debug.lib
pcl_segmentation_debug.lib
pcl_stereo_debug.lib
pcl_surface_debug.lib
pcl_tracking_debug.lib
pcl_visualization_debug.lib
libboost_atomic-vc141-mt-gd-1_64.lib
libboost_bzip2-vc141-mt-gd-1_64.lib
libboost_chrono-vc141-mt-gd-1_64.lib
libboost_container-vc141-mt-gd-1_64.lib
libboost_context-vc141-mt-gd-1_64.lib
libboost_coroutine-vc141-mt-gd-1_64.lib
libboost_date_time-vc141-mt-gd-1_64.lib
libboost_exception-vc141-mt-gd-1_64.lib
libboost_fiber-vc141-mt-gd-1_64.lib
libboost_filesystem-vc141-mt-gd-1_64.lib
libboost_graph-vc141-mt-gd-1_64.lib
libboost_graph_parallel-vc141-mt-gd-1_64.lib
libboost_iostreams-vc141-mt-gd-1_64.lib
libboost_locale-vc141-mt-gd-1_64.lib
libboost_log-vc141-mt-gd-1_64.lib
libboost_log_setup-vc141-mt-gd-1_64.lib
libboost_math_c99-vc141-mt-gd-1_64.lib
libboost_math_c99f-vc141-mt-gd-1_64.lib
libboost_math_c99l-vc141-mt-gd-1_64.lib
libboost_math_tr1-vc141-mt-gd-1_64.lib
libboost_math_tr1f-vc141-mt-gd-1_64.lib
libboost_math_tr1l-vc141-mt-gd-1_64.lib
libboost_mpi-vc141-mt-gd-1_64.lib
libboost_numpy3-vc141-mt-gd-1_64.lib
libboost_numpy-vc141-mt-gd-1_64.lib
libboost_prg_exec_monitor-vc141-mt-gd-1_64.lib
libboost_program_options-vc141-mt-gd-1_64.lib
libboost_python3-vc141-mt-gd-1_64.lib
libboost_python-vc141-mt-gd-1_64.lib
libboost_random-vc141-mt-gd-1_64.lib
libboost_regex-vc141-mt-gd-1_64.lib
libboost_serialization-vc141-mt-gd-1_64.lib
libboost_signals-vc141-mt-gd-1_64.lib
libboost_system-vc141-mt-gd-1_64.lib
libboost_test_exec_monitor-vc141-mt-gd-1_64.lib
libboost_thread-vc141-mt-gd-1_64.lib
libboost_timer-vc141-mt-gd-1_64.lib
libboost_type_erasure-vc141-mt-gd-1_64.lib
libboost_unit_test_framework-vc141-mt-gd-1_64.lib
libboost_wave-vc141-mt-gd-1_64.lib
libboost_wserialization-vc141-mt-gd-1_64.lib
libboost_zlib-vc141-mt-gd-1_64.lib
flann-gd.lib
flann_cpp-gd.lib
flann_cpp_s-gd.lib
flann_s-gd.lib
qhull_d.lib
qhullcpp_d.lib
qhullstatic_d.lib
qhullstatic_r_d.lib
qhull_p_d.lib
qhull_r_d.lib
vtkalglib-8.0-gd.lib
vtkChartsCore-8.0-gd.lib
vtkCommonColor-8.0-gd.lib
vtkCommonComputationalGeometry-8.0-gd.lib
vtkCommonCore-8.0-gd.lib
vtkCommonDataModel-8.0-gd.lib
vtkCommonExecutionModel-8.0-gd.lib
vtkCommonMath-8.0-gd.lib
vtkCommonMisc-8.0-gd.lib
vtkCommonSystem-8.0-gd.lib
vtkCommonTransforms-8.0-gd.lib
vtkDICOMParser-8.0-gd.lib
vtkDomainsChemistry-8.0-gd.lib
vtkexoIIc-8.0-gd.lib
vtkexpat-8.0-gd.lib
vtkFiltersAMR-8.0-gd.lib
vtkFiltersCore-8.0-gd.lib
vtkFiltersExtraction-8.0-gd.lib
vtkFiltersFlowPaths-8.0-gd.lib
vtkFiltersGeneral-8.0-gd.lib
vtkFiltersGeneric-8.0-gd.lib
vtkFiltersGeometry-8.0-gd.lib
vtkFiltersHybrid-8.0-gd.lib
vtkFiltersHyperTree-8.0-gd.lib
vtkFiltersImaging-8.0-gd.lib
vtkFiltersModeling-8.0-gd.lib
vtkFiltersParallel-8.0-gd.lib
vtkFiltersParallelImaging-8.0-gd.lib
vtkFiltersPoints-8.0-gd.lib
vtkFiltersProgrammable-8.0-gd.lib
vtkFiltersSelection-8.0-gd.lib
vtkFiltersSMP-8.0-gd.lib
vtkFiltersSources-8.0-gd.lib
vtkFiltersStatistics-8.0-gd.lib
vtkFiltersTexture-8.0-gd.lib
vtkFiltersTopology-8.0-gd.lib
vtkFiltersVerdict-8.0-gd.lib
vtkfreetype-8.0-gd.lib
vtkGeovisCore-8.0-gd.lib
vtkgl2ps-8.0-gd.lib
vtkhdf5-8.0-gd.lib
vtkhdf5_hl-8.0-gd.lib
vtkImagingColor-8.0-gd.lib
vtkImagingCore-8.0-gd.lib
vtkImagingFourier-8.0-gd.lib
vtkImagingGeneral-8.0-gd.lib
vtkImagingHybrid-8.0-gd.lib
vtkImagingMath-8.0-gd.lib
vtkImagingMorphological-8.0-gd.lib
vtkImagingSources-8.0-gd.lib
vtkImagingStatistics-8.0-gd.lib
vtkImagingStencil-8.0-gd.lib
vtkInfovisCore-8.0-gd.lib
vtkInfovisLayout-8.0-gd.lib
vtkInteractionImage-8.0-gd.lib
vtkInteractionStyle-8.0-gd.lib
vtkInteractionWidgets-8.0-gd.lib
vtkIOAMR-8.0-gd.lib
vtkIOCore-8.0-gd.lib
vtkIOEnSight-8.0-gd.lib
vtkIOExodus-8.0-gd.lib
vtkIOExport-8.0-gd.lib
vtkIOExportOpenGL-8.0-gd.lib
vtkIOGeometry-8.0-gd.lib
vtkIOImage-8.0-gd.lib
vtkIOImport-8.0-gd.lib
vtkIOInfovis-8.0-gd.lib
vtkIOLegacy-8.0-gd.lib
vtkIOLSDyna-8.0-gd.lib
vtkIOMINC-8.0-gd.lib
vtkIOMovie-8.0-gd.lib
vtkIONetCDF-8.0-gd.lib
vtkIOParallel-8.0-gd.lib
vtkIOParallelXML-8.0-gd.lib
vtkIOPLY-8.0-gd.lib
vtkIOSQL-8.0-gd.lib
vtkIOTecplotTable-8.0-gd.lib
vtkIOVideo-8.0-gd.lib
vtkIOXML-8.0-gd.lib
vtkIOXMLParser-8.0-gd.lib
vtkjpeg-8.0-gd.lib
vtkjsoncpp-8.0-gd.lib
vtklibharu-8.0-gd.lib
vtklibxml2-8.0-gd.lib
vtklz4-8.0-gd.lib
vtkmetaio-8.0-gd.lib
vtkNetCDF-8.0-gd.lib
vtkoggtheora-8.0-gd.lib
vtkParallelCore-8.0-gd.lib
vtkpng-8.0-gd.lib
vtkproj4-8.0-gd.lib
vtkRenderingAnnotation-8.0-gd.lib
vtkRenderingContext2D-8.0-gd.lib
vtkRenderingContextOpenGL-8.0-gd.lib
vtkRenderingCore-8.0-gd.lib
vtkRenderingFreeType-8.0-gd.lib
vtkRenderingGL2PS-8.0-gd.lib
vtkRenderingImage-8.0-gd.lib
vtkRenderingLabel-8.0-gd.lib
vtkRenderingLIC-8.0-gd.lib
vtkRenderingLOD-8.0-gd.lib
vtkRenderingOpenGL-8.0-gd.lib
vtkRenderingVolume-8.0-gd.lib
vtkRenderingVolumeOpenGL-8.0-gd.lib
vtksqlite-8.0-gd.lib
vtksys-8.0-gd.lib
vtktiff-8.0-gd.lib
vtkverdict-8.0-gd.lib
vtkViewsContext2D-8.0-gd.lib
vtkViewsCore-8.0-gd.lib
vtkViewsInfovis-8.0-gd.lib
vtkzlib-8.0-gd.lib
opengl32.lib
2.2.4 release版本的附加依赖项
就是把安装目录下的所有没有debug
的lib
都扔进去。
pcl_common_release.lib
pcl_features_release.lib
pcl_filters_release.lib
pcl_io_release.lib
pcl_io_ply_release.lib
pcl_kdtree_release.lib
pcl_keypoints_release.lib
pcl_ml_release.lib
pcl_octree_release.lib
pcl_outofcore_release.lib
pcl_people_release.lib
pcl_recognition_release.lib
pcl_registration_release.lib
pcl_sample_consensus_release.lib
pcl_search_release.lib
pcl_segmentation_release.lib
pcl_stereo_release.lib
pcl_surface_release.lib
pcl_tracking_release.lib
pcl_visualization_release.lib
libboost_atomic-vc141-mt-1_64.lib
libboost_chrono-vc141-mt-1_64.lib
libboost_container-vc141-mt-1_64.lib
libboost_context-vc141-mt-1_64.lib
libboost_coroutine-vc141-mt-1_64.lib
libboost_date_time-vc141-mt-1_64.lib
libboost_exception-vc141-mt-1_64.lib
libboost_filesystem-vc141-mt-1_64.lib
libboost_graph-vc141-mt-1_64.lib
libboost_iostreams-vc141-mt-1_64.lib
libboost_locale-vc141-mt-1_64.lib
libboost_log-vc141-mt-1_64.lib
libboost_log_setup-vc141-mt-1_64.lib
libboost_math_c99-vc141-mt-1_64.lib
libboost_math_c99f-vc141-mt-1_64.lib
libboost_math_c99l-vc141-mt-1_64.lib
libboost_math_tr1-vc141-mt-1_64.lib
libboost_math_tr1f-vc141-mt-1_64.lib
libboost_math_tr1l-vc141-mt-1_64.lib
libboost_mpi-vc141-mt-1_64.lib
libboost_prg_exec_monitor-vc141-mt-1_64.lib
libboost_program_options-vc141-mt-1_64.lib
libboost_random-vc141-mt-1_64.lib
libboost_regex-vc141-mt-1_64.lib
libboost_serialization-vc141-mt-1_64.lib
libboost_signals-vc141-mt-1_64.lib
libboost_system-vc141-mt-1_64.lib
libboost_test_exec_monitor-vc141-mt-1_64.lib
libboost_thread-vc141-mt-1_64.lib
libboost_timer-vc141-mt-1_64.lib
libboost_unit_test_framework-vc141-mt-1_64.lib
libboost_wave-vc141-mt-1_64.lib
libboost_wserialization-vc141-mt-1_64.lib
vtkalglib-8.0.lib
vtkChartsCore-8.0.lib
vtkCommonColor-8.0.lib
vtkCommonComputationalGeometry-8.0.lib
vtkCommonCore-8.0.lib
vtkCommonDataModel-8.0.lib
vtkCommonExecutionModel-8.0.lib
vtkCommonMath-8.0.lib
vtkCommonMisc-8.0.lib
vtkCommonSystem-8.0.lib
vtkCommonTransforms-8.0.lib
vtkDICOMParser-8.0.lib
vtkDomainsChemistry-8.0.lib
vtkexoIIc-8.0.lib
vtkexpat-8.0.lib
vtkFiltersAMR-8.0.lib
vtkFiltersCore-8.0.lib
vtkFiltersExtraction-8.0.lib
vtkFiltersFlowPaths-8.0.lib
vtkFiltersGeneral-8.0.lib
vtkFiltersGeneric-8.0.lib
vtkFiltersGeometry-8.0.lib
vtkFiltersHybrid-8.0.lib
vtkFiltersHyperTree-8.0.lib
vtkFiltersImaging-8.0.lib
vtkFiltersModeling-8.0.lib
vtkFiltersParallel-8.0.lib
vtkFiltersParallelImaging-8.0.lib
vtkFiltersPoints-8.0.lib
vtkFiltersProgrammable-8.0.lib
vtkFiltersSelection-8.0.lib
vtkFiltersSMP-8.0.lib
vtkFiltersSources-8.0.lib
vtkFiltersStatistics-8.0.lib
vtkFiltersTexture-8.0.lib
vtkFiltersTopology-8.0.lib
vtkFiltersVerdict-8.0.lib
vtkfreetype-8.0.lib
vtkGeovisCore-8.0.lib
vtkgl2ps-8.0.lib
vtkhdf5-8.0.lib
vtkhdf5_hl-8.0.lib
vtkImagingColor-8.0.lib
vtkImagingCore-8.0.lib
vtkImagingFourier-8.0.lib
vtkImagingGeneral-8.0.lib
vtkImagingHybrid-8.0.lib
vtkImagingMath-8.0.lib
vtkImagingMorphological-8.0.lib
vtkImagingSources-8.0.lib
vtkImagingStatistics-8.0.lib
vtkImagingStencil-8.0.lib
vtkInfovisCore-8.0.lib
vtkInfovisLayout-8.0.lib
vtkInteractionImage-8.0.lib
vtkInteractionStyle-8.0.lib
vtkInteractionWidgets-8.0.lib
vtkIOAMR-8.0.lib
vtkIOCore-8.0.lib
vtkIOEnSight-8.0.lib
vtkIOExodus-8.0.lib
vtkIOExport-8.0.lib
vtkIOExportOpenGL-8.0.lib
vtkIOGeometry-8.0.lib
vtkIOImage-8.0.lib
vtkIOImport-8.0.lib
vtkIOInfovis-8.0.lib
vtkIOLegacy-8.0.lib
vtkIOLSDyna-8.0.lib
vtkIOMINC-8.0.lib
vtkIOMovie-8.0.lib
vtkIONetCDF-8.0.lib
vtkIOParallel-8.0.lib
vtkIOParallelXML-8.0.lib
vtkIOPLY-8.0.lib
vtkIOSQL-8.0.lib
vtkIOTecplotTable-8.0.lib
vtkIOVideo-8.0.lib
vtkIOXML-8.0.lib
vtkIOXMLParser-8.0.lib
vtkjpeg-8.0.lib
vtkjsoncpp-8.0.lib
vtklibharu-8.0.lib
vtklibxml2-8.0.lib
vtklz4-8.0.lib
vtkmetaio-8.0.lib
vtkNetCDF-8.0.lib
vtknetcdf_c++.lib
vtkoggtheora-8.0.lib
vtkParallelCore-8.0.lib
vtkpng-8.0.lib
vtkproj4-8.0.lib
vtkRenderingAnnotation-8.0.lib
vtkRenderingContext2D-8.0.lib
vtkRenderingContextOpenGL-8.0.lib
vtkRenderingCore-8.0.lib
vtkRenderingFreeType-8.0.lib
vtkRenderingGL2PS-8.0.lib
vtkRenderingImage-8.0.lib
vtkRenderingLabel-8.0.lib
vtkRenderingLIC-8.0.lib
vtkRenderingLOD-8.0.lib
vtkRenderingOpenGL-8.0.lib
vtkRenderingVolume-8.0.lib
vtkRenderingVolumeOpenGL-8.0.lib
vtksqlite-8.0.lib
vtksys-8.0.lib
vtktiff-8.0.lib
vtkverdict-8.0.lib
vtkViewsContext2D-8.0.lib
vtkViewsCore-8.0.lib
vtkViewsInfovis-8.0.lib
vtkzlib-8.0.lib
flann.lib
flann_cpp.lib
flann_cpp_s.lib
flann_s.lib
qhullcpp_d.lib
qhullstatic.lib
qhullstatic_r.lib
qhull.lib
qhull_p.lib
qhull_r.lib
OpenNI2.lib
kernel32.lib
user32.lib
gdi32.lib
winspool.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
comdlg32.lib
advapi32.lib
comctl32.lib
wsock32.lib
glu32.lib
opengl32.lib
ws2_32.lib
Psapi.lib
此处没图。
3测试
测试代码,自行吧对应的pcd
文件换成对应的路径。
#include<pcl/visualization/cloud_viewer.h>
#include<iostream>//标准C++库中的输入输出类相关头文件。
#include<pcl/io/io.h>
#include<pcl/io/pcd_io.h>//pcd 读写类相关的头文件。
#include<pcl/io/ply_io.h>
#include<pcl/point_types.h> //PCL中支持的点类型头文件。
int user_data;
using std::cout;
void viewerOneOff(pcl::visualization::PCLVisualizer& viewer) {
viewer.setBackgroundColor(1.0, 0.5, 1.0); //设置背景颜色
}
int main() {
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
char strfilepath[256] = "rabbit.pcd";
if (-1 == pcl::io::loadPCDFile(strfilepath, *cloud)) {
cout << "error input!" << endl;
return -1;
}
cout << cloud->points.size() << endl;
pcl::visualization::CloudViewer viewer("Cloud Viewer"); //创建viewer对象
viewer.showCloud(cloud);
viewer.runOnVisualizationThreadOnce(viewerOneOff);
system("pause");
return 0;
}
如果没有pcd
可以用这个下面这个
测试用pcd百度云链接,提取码:r0pv ,由PCL安装与配置(Windows10+VS2017 )所提供的。
如果正常则如下图,不正常请看下节,当然一般不会正常的。
问题及处理
在vs中配置pcl报错:C2116和C2733,主要是这个报错,原因可以进原文看。
在预处理当中加入宏
_CRT_SECURE_NO_WARNINGS
_SCL_SECURE_NO_WARNINGS
_SILENCE_FPOS_SEEKPOS_DEPRECATION_WARNING
NOMINMAX
BOOST_USE_WINDOWS_H
总结
这么写东西好累啊。我还没看代码含义呢。