美文网首页
VS2017配置PCL1.9.1 for win10(超详细)

VS2017配置PCL1.9.1 for win10(超详细)

作者: codehory | 来源:发表于2019-07-27 20:40 被阅读0次

    作者经历了从PCL1.7-PCL1.9,VS2013-VS2017的反复配置,其过程是坎坷与辛酸,踩过各种坑,现在配置起来真的是炉火纯青了。现在又来台新电脑了,没错,再来配置一次吧。此次配置VS2017+PCL1.9.1


    准备工作

    • VS2017 自行下载
    • PCL1.9.1
      点击链接跳转Github下载,根据自己的环境选择 win64win32,作者下载的是:PCL-1.9.1-AllInOne-msvc2017-win64.exe
      pcl-1.9.1-pdb-msvc2017-win64.zip

    安装PCL

    双击点开PCL-1.9.1-AllInOne-msvc2017-win64.exe,选择Add PCL to the system PATH for all users,


    更改安装路径,E:\Program Files\PCL 1.9.1,

    选择第三方库,这里作者全选,开始安装,

    中途跳出OpenNI安装,选择路径./3rdParty/OpenNI2/,安装,

    安装完毕。

    解压pcl-1.9.1-pdb-msvc2017-win64.zip,将PDB文件拷贝到PCL安装路径下的bin文件夹中。


    环境配置

    • 系统环境配置
      计算机->属性->高级系统变量->环境变量,双击Path

    添加如下路径(路径根据自己的安装目录添加)



    添加完毕后,电脑注销后生效。

    • VS开发环境配置
    1. 打开VS2017,新建空项目

    2.菜单栏点击视图->其他窗口->属性管理器,选择releaseordebug,win32orx64,这里以release|x64为例,右键新建添加新项目属性表,取名config,添加,


    3.双击新建的属性表
    VC++ 目录->包含目录->添加头文件:(根据自己pcl的路径添加)
    E:\Program Files\PCL 1.9.1\include\pcl-1.9
    E:\Program Files\PCL 1.9.1\3rdParty\Boost\include\boost-1_68
    E:\Program Files\PCL 1.9.1\3rdParty\Eigen\eigen3
    E:\Program Files\PCL 1.9.1\3rdParty\FLANN\include
    E:\Program Files\PCL 1.9.1\3rdParty\OpenNI2\Include
    E:\Program Files\PCL 1.9.1\3rdParty\Qhull\include
    E:\Program Files\PCL 1.9.1\3rdParty\VTK\include\vtk-8.1
    

    VC++ 目录->库目录->添加库文件:(根据自己pcl的路径添加)

    E:\Program Files\PCL 1.9.1\lib
    E:\Program Files\PCL 1.9.1\3rdParty\Boost\lib
    E:\Program Files\PCL 1.9.1\3rdParty\FLANN\lib
    E:\Program Files\PCL 1.9.1\3rdParty\OpenNI2\Lib
    E:\Program Files\PCL 1.9.1\3rdParty\Qhull\lib
    E:\Program Files\PCL 1.9.1\3rdParty\VTK\lib
    

    链接器->输入->附加依赖项添加lib文件:(这里是release版本),如果你上面选择的是debug win32 or debug x64,则添加debug版本的lib文件,请看下面的Tips,教你如何获取lib目录。

    pcl_common_release.lib
    pcl_features_release.lib
    pcl_filters_release.lib
    pcl_io_ply_release.lib
    pcl_io_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-x64-1_68.lib
    libboost_bzip2-vc141-mt-x64-1_68.lib
    libboost_chrono-vc141-mt-x64-1_68.lib
    libboost_container-vc141-mt-x64-1_68.lib
    libboost_context-vc141-mt-x64-1_68.lib
    libboost_contract-vc141-mt-x64-1_68.lib
    libboost_coroutine-vc141-mt-x64-1_68.lib
    libboost_date_time-vc141-mt-x64-1_68.lib
    libboost_exception-vc141-mt-x64-1_68.lib
    libboost_fiber-vc141-mt-x64-1_68.lib
    libboost_filesystem-vc141-mt-x64-1_68.lib
    libboost_graph-vc141-mt-x64-1_68.lib
    libboost_graph_parallel-vc141-mt-x64-1_68.lib
    libboost_iostreams-vc141-mt-x64-1_68.lib
    libboost_locale-vc141-mt-x64-1_68.lib
    libboost_log-vc141-mt-x64-1_68.lib
    libboost_log_setup-vc141-mt-x64-1_68.lib
    libboost_math_c99-vc141-mt-x64-1_68.lib
    libboost_math_c99f-vc141-mt-x64-1_68.lib
    libboost_math_c99l-vc141-mt-x64-1_68.lib
    libboost_math_tr1-vc141-mt-x64-1_68.lib
    libboost_math_tr1f-vc141-mt-x64-1_68.lib
    libboost_math_tr1l-vc141-mt-x64-1_68.lib
    libboost_mpi-vc141-mt-x64-1_68.lib
    libboost_numpy27-vc141-mt-x64-1_68.lib
    libboost_numpy37-vc141-mt-x64-1_68.lib
    libboost_prg_exec_monitor-vc141-mt-x64-1_68.lib
    libboost_program_options-vc141-mt-x64-1_68.lib
    libboost_python27-vc141-mt-x64-1_68.lib
    libboost_python37-vc141-mt-x64-1_68.lib
    libboost_random-vc141-mt-x64-1_68.lib
    libboost_regex-vc141-mt-x64-1_68.lib
    libboost_serialization-vc141-mt-x64-1_68.lib
    libboost_signals-vc141-mt-x64-1_68.lib
    libboost_stacktrace_noop-vc141-mt-x64-1_68.lib
    libboost_stacktrace_windbg-vc141-mt-x64-1_68.lib
    libboost_stacktrace_windbg_cached-vc141-mt-x64-1_68.lib
    libboost_system-vc141-mt-x64-1_68.lib
    libboost_test_exec_monitor-vc141-mt-x64-1_68.lib
    libboost_thread-vc141-mt-x64-1_68.lib
    libboost_timer-vc141-mt-x64-1_68.lib
    libboost_type_erasure-vc141-mt-x64-1_68.lib
    libboost_unit_test_framework-vc141-mt-x64-1_68.lib
    libboost_wave-vc141-mt-x64-1_68.lib
    libboost_wserialization-vc141-mt-x64-1_68.lib
    libboost_zlib-vc141-mt-x64-1_68.lib
    OpenNI2.lib
    flann.lib
    flann_cpp.lib
    flann_cpp_s.lib
    flann_s.lib
    qhull.lib
    qhullcpp.lib
    qhullstatic.lib
    qhullstatic_r.lib
    qhull_p.lib
    qhull_r.lib
    vtkalglib-8.1.lib
    vtkChartsCore-8.1.lib
    vtkCommonColor-8.1.lib
    vtkCommonComputationalGeometry-8.1.lib
    vtkCommonCore-8.1.lib
    vtkCommonDataModel-8.1.lib
    vtkCommonExecutionModel-8.1.lib
    vtkCommonMath-8.1.lib
    vtkCommonMisc-8.1.lib
    vtkCommonSystem-8.1.lib
    vtkCommonTransforms-8.1.lib
    vtkDICOMParser-8.1.lib
    vtkDomainsChemistry-8.1.lib
    vtkexoIIc-8.1.lib
    vtkexpat-8.1.lib
    vtkFiltersAMR-8.1.lib
    vtkFiltersCore-8.1.lib
    vtkFiltersExtraction-8.1.lib
    vtkFiltersFlowPaths-8.1.lib
    vtkFiltersGeneral-8.1.lib
    vtkFiltersGeneric-8.1.lib
    vtkFiltersGeometry-8.1.lib
    vtkFiltersHybrid-8.1.lib
    vtkFiltersHyperTree-8.1.lib
    vtkFiltersImaging-8.1.lib
    vtkFiltersModeling-8.1.lib
    vtkFiltersParallel-8.1.lib
    vtkFiltersParallelImaging-8.1.lib
    vtkFiltersPoints-8.1.lib
    vtkFiltersProgrammable-8.1.lib
    vtkFiltersSelection-8.1.lib
    vtkFiltersSMP-8.1.lib
    vtkFiltersSources-8.1.lib
    vtkFiltersStatistics-8.1.lib
    vtkFiltersTexture-8.1.lib
    vtkFiltersTopology-8.1.lib
    vtkFiltersVerdict-8.1.lib
    vtkfreetype-8.1.lib
    vtkGeovisCore-8.1.lib
    vtkgl2ps-8.1.lib
    vtkhdf5-8.1.lib
    vtkhdf5_hl-8.1.lib
    vtkImagingColor-8.1.lib
    vtkImagingCore-8.1.lib
    vtkImagingFourier-8.1.lib
    vtkImagingGeneral-8.1.lib
    vtkImagingHybrid-8.1.lib
    vtkImagingMath-8.1.lib
    vtkImagingMorphological-8.1.lib
    vtkImagingSources-8.1.lib
    vtkImagingStatistics-8.1.lib
    vtkImagingStencil-8.1.lib
    vtkInfovisCore-8.1.lib
    vtkInfovisLayout-8.1.lib
    vtkInteractionImage-8.1.lib
    vtkInteractionStyle-8.1.lib
    vtkInteractionWidgets-8.1.lib
    vtkIOAMR-8.1.lib
    vtkIOCore-8.1.lib
    vtkIOEnSight-8.1.lib
    vtkIOExodus-8.1.lib
    vtkIOExport-8.1.lib
    vtkIOExportOpenGL-8.1.lib
    vtkIOGeometry-8.1.lib
    vtkIOImage-8.1.lib
    vtkIOImport-8.1.lib
    vtkIOInfovis-8.1.lib
    vtkIOLegacy-8.1.lib
    vtkIOLSDyna-8.1.lib
    vtkIOMINC-8.1.lib
    vtkIOMovie-8.1.lib
    vtkIONetCDF-8.1.lib
    vtkIOParallel-8.1.lib
    vtkIOParallelXML-8.1.lib
    vtkIOPLY-8.1.lib
    vtkIOSQL-8.1.lib
    vtkIOTecplotTable-8.1.lib
    vtkIOVideo-8.1.lib
    vtkIOXML-8.1.lib
    vtkIOXMLParser-8.1.lib
    vtkjpeg-8.1.lib
    vtkjsoncpp-8.1.lib
    vtklibharu-8.1.lib
    vtklibxml2-8.1.lib
    vtklz4-8.1.lib
    vtkmetaio-8.1.lib
    vtkNetCDF-8.1.lib
    vtknetcdfcpp-8.1.lib
    vtkoggtheora-8.1.lib
    vtkParallelCore-8.1.lib
    vtkpng-8.1.lib
    vtkproj4-8.1.lib
    vtkRenderingAnnotation-8.1.lib
    vtkRenderingContext2D-8.1.lib
    vtkRenderingContextOpenGL-8.1.lib
    vtkRenderingCore-8.1.lib
    vtkRenderingFreeType-8.1.lib
    vtkRenderingGL2PS-8.1.lib
    vtkRenderingImage-8.1.lib
    vtkRenderingLabel-8.1.lib
    vtkRenderingLIC-8.1.lib
    vtkRenderingLOD-8.1.lib
    vtkRenderingOpenGL-8.1.lib
    vtkRenderingVolume-8.1.lib
    vtkRenderingVolumeOpenGL-8.1.lib
    vtksqlite-8.1.lib
    vtksys-8.1.lib
    vtktiff-8.1.lib
    vtkverdict-8.1.lib
    vtkViewsContext2D-8.1.lib
    vtkViewsCore-8.1.lib
    vtkViewsInfovis-8.1.lib
    vtkzlib-8.1.lib
    

    Tips:如何获得lib目录?
    举个例子:我们要获得.\PCL 1.9.1\lib目录下的lib目录,在此文件夹下新建一个.txt文本,在文本中写入下列代码,保存。

    dir /b *debug.lib>1.txt 
    

    将文本后缀名.txt改为.bat,运行脚本,


    在目录下会生成1.txt,打开即为lib目录(这里提取的是debug目录,如需release,只需修改代码,dir /b *release.lib>1.txt)。

    至此,配置完成!

    程序测试

    #include <iostream>
    #include <pcl/io/pcd_io.h>
    #include <pcl/point_types.h>
    #include <pcl/ModelCoefficients.h>
    #include <pcl/filters/project_inliers.h>
     
    int main(int argc, char** argv)
    {
        pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
        pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_projected(new pcl::PointCloud<pcl::PointXYZ>);
     
        // Fill in the cloud data
        cloud->width = 5;
        cloud->height = 1;
        cloud->points.resize(cloud->width * cloud->height);
     
        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);
        }
     
        std::cerr << "Cloud before projection: " << std::endl;
        for (size_t i = 0; i < cloud->points.size(); ++i)
            std::cerr << "    " << cloud->points[i].x << " "
            << cloud->points[i].y << " "
            << cloud->points[i].z << std::endl;
     
        // Create a set of planar coefficients with X=Y=0,Z=1
        pcl::ModelCoefficients::Ptr coefficients(new pcl::ModelCoefficients());
        coefficients->values.resize(4);
        coefficients->values[0] = coefficients->values[1] = 0;
        coefficients->values[2] = 1.0;
        coefficients->values[3] = 0;
     
        // Create the filtering object
        pcl::ProjectInliers<pcl::PointXYZ> proj;
        proj.setModelType(pcl::SACMODEL_PLANE);
        proj.setInputCloud(cloud);
        proj.setModelCoefficients(coefficients);
        proj.filter(*cloud_projected);
     
        std::cerr << "Cloud after projection: " << std::endl;
        for (size_t i = 0; i < cloud_projected->points.size(); ++i)
            std::cerr << "    " << cloud_projected->points[i].x << " "
            << cloud_projected->points[i].y << " "
            << cloud_projected->points[i].z << std::endl;
     
        system("pause");
        return (0);
    }
    

    如果生成成功,并能运行得到结果,表明配置成功!


    相关问题

    如果出现如下报错,


    解决方法:
    双击自己建的属性表,C/C++ -> 预处理器 -> 预处理器定义添加
    _CRT_SECURE_NO_WARNINGS
    _SCL_SECURE_NO_WARNINGS
    _SILENCE_FPOS_SEEKPOS_DEPRECATION_WARNING
    

    结语

    至此,相信你也和我一样,已经配置成功了。
    如有任何问题或是书写纰漏,请给我留言,我会帮你们耐心解决。
    感谢观看,希望对你们有所帮助!

    相关文章

      网友评论

          本文标题:VS2017配置PCL1.9.1 for win10(超详细)

          本文链接:https://www.haomeiwen.com/subject/kwihrctx.html