vs2022配置pcl1.13.1

1、下载

打开GitHub网站,搜索pcl,选择第一个结果打开,按照下图步骤操作

下载PCL预编译安装程序PCL-1.13.1-AllInOne-msvc2022-win64.exe

和要安装的PCL组件(例如pcl-1.13.1-pdb-msvc2022-win64.zip

2、安装

双击 PCL-1.13.1-AllInOne-msvc2022-win64.exe进行安装。到图1的步骤时,选择第二项。

网上找的图
图1

下一步, 安装路径可以自行修改(我的安装路径D:\PCL 1.13.1),之后点击安装即可。

一段时间之后,会弹出来一个OpenNI2的安装窗口,此时将OpenNI2放在3rdparty文件夹里,即D:\PCL 1.13.1\3rdParty\OpenNI2。由于点云在安装的过程中会把所有的第三方库全部安装在点云安装目录下的3rdparty文件夹里。因此,为了保持文件夹的整洁,把OpenNI2放在3rdparty文件夹里。

 如果3rdParty文件夹下的OpenNI2内容为空,可以将其移除:在PCL安装路径下的3rdParty/OpenNI2文件夹内可以看到安装包OpenNI-Windows-x64-2.2.msi,双击运行,选择Remove移除安装再重新安装即可。

配置PDB文件

将下载得到的压缩包pcl-1.13.1-pdb-msvc2022-win64.zip解压缩后将里面的文件复制到PCL安装目录下bin文件夹

至此点云库安装完成,安装目录和3rdparty文件夹如下表所示:

 3、配置环境变量

首先确认OpenNI2的环境变量是否设置正确

 然后打开Path,添加如下

%OPENNI2_REDIST64%
%OPENNI2_LIB64%
%OPENNI2_INCLUDE64%

4、VS 环境配置

4.1 创建项目

新建一个控制台应用(目录可以放在pcl的安装路径下),建立一个项目属性表(目的:以后新建一个PCL项目文件直接调用配置好的属性表,一劳永逸)

 

debug和release配置大体相同,不同的地方后面会提及。 

之后新建项目时就可以加载配置好的属性表。

 打开vs建立了一个pcl项目的前提下,再次新建项目并导入.props文件,运行该pcl项目可能会失败。可以重启vs。

 4.2 配置包含目录

打开属性表,配置VC++目录中的包含目录。在配置 PCL 包含目录路径时,连接符应该使用分号(;),注意路径之间不要有空格,并且最后一个路径不需要加分号。

D:\PCL 1.13.1\3rdParty\Boost\include\boost-1_82;D:\PCL 1.13.1\3rdParty\Eigen\eigen3;D:\PCL 1.13.1\3rdParty\FLANN\include;D:\PCL 1.13.1\3rdParty\OpenNI2\Include;D:\PCL 1.13.1\3rdParty\Qhull\include;D:\PCL 1.13.1\3rdParty\VTK\include\vtk-9.2;D:\PCL 1.13.1\include\pcl-1.13

 4.3 配置库目录

D:\PCL 1.13.1\3rdParty\Boost\lib;D:\PCL 1.13.1\3rdParty\FLANN\lib;D:\PCL 1.13.1\3rdParty\OpenNI2\Lib;D:\PCL 1.13.1\3rdParty\Qhull\lib;D:\PCL 1.13.1\3rdParty\VTK\lib;D:\PCL 1.13.1\lib

 4.4 配置预处理器

debug模式可以如下配置,release模式只添加后面三项即可

_DEBUG
_CONSOLE
_CRT_SECURE_NO_WARNINGS
BOOST_USE_WINDOWS_H
NOMINMAX
_CRT_SECURE_NO_DEPRECATE
debug模式release模式

 4.5 附加依赖项配置

需要对Boost(92)、VTK(284)、PCL(40)几个文件夹内lib文件夹内的.lib文件进行提取。Debug是 **d.lib 类型,Release是 *.lib 类型。

提取Boost和VTK中的.lib文件可以用下面的代码(修改对应的路径、保存的文件名即可)

import os

# 设置 Boost lib 文件夹路径和要输出的文本文件名
gd_output_file = "Boost_debug_libs.txt"
non_gd_output_file = "Boost_release_libs.txt"


def Extract_lib(boost_lib_path):
    # 获取 Boost lib 文件夹下的所有 .lib 文件名
    all_lib_files = [file for file in os.listdir(boost_lib_path) if file.endswith('.lib')]

    # 分别筛选包含和不包含 "-gd" 的文件名,并输出到不同的文本文件中
    gd_lib_files = [file for file in all_lib_files if '-gd' in file]
    with open(os.path.join(boost_lib_path, gd_output_file), 'w') as outfile:
        for gd_file in gd_lib_files:
            outfile.write(gd_file + '\n')

    non_gd_lib_files = [file for file in all_lib_files if '-gd' not in file]
    with open(os.path.join(boost_lib_path, non_gd_output_file), 'w') as outfile:
        for non_gd_file in non_gd_lib_files:
            outfile.write(non_gd_file + '\n')


if __name__ == '__main__':
    path = r"D:\PCL 1.13.1\3rdParty\Boost\lib"
    Extract_lib(path)
import os

# 设置 Boost lib 文件夹路径和要输出的文本文件名
gd_output_file = "VTK_debug_libs.txt"
non_gd_output_file = "VTK_release_libs.txt"


def Extract_lib(boost_lib_path):
    # 获取 Boost lib 文件夹下的所有 .lib 文件名
    all_lib_files = [file for file in os.listdir(boost_lib_path) if file.endswith('.lib')]

    # 分别筛选包含和不包含 "-gd" 的文件名,并输出到不同的文本文件中
    gd_lib_files = [file for file in all_lib_files if '-gd' in file]
    with open(os.path.join(boost_lib_path, gd_output_file), 'w') as outfile:
        for gd_file in gd_lib_files:
            outfile.write(gd_file + '\n')

    non_gd_lib_files = [file for file in all_lib_files if '-gd' not in file]
    with open(os.path.join(boost_lib_path, non_gd_output_file), 'w') as outfile:
        for non_gd_file in non_gd_lib_files:
            outfile.write(non_gd_file + '\n')


if __name__ == '__main__':
    path = r"D:\PCL 1.13.1\3rdParty\VTK\lib"
    Extract_lib(path)

 提取pcl安装路径下lib文件夹内的.lib文件

import os

# 设置 Boost lib 文件夹路径和要输出的文本文件名
gd_output_file = "pcl_debug_libs.txt"
non_gd_output_file = "pcl_release_libs.txt"


def Extract_lib(boost_lib_path):
    # 获取 Boost lib 文件夹下的所有 .lib 文件名
    all_lib_files = [file for file in os.listdir(boost_lib_path) if file.endswith('.lib')]

    # 分别筛选包含和不包含 "-gd" 的文件名,并输出到不同的文本文件中
    gd_lib_files = [file for file in all_lib_files if 'd.lib' in file]
    with open(os.path.join(boost_lib_path, gd_output_file), 'w') as outfile:
        for gd_file in gd_lib_files:
            outfile.write(gd_file + '\n')

    non_gd_lib_files = [file for file in all_lib_files if 'd.lib' not in file]
    with open(os.path.join(boost_lib_path, non_gd_output_file), 'w') as outfile:
        for non_gd_file in non_gd_lib_files:
            outfile.write(non_gd_file + '\n')


if __name__ == '__main__':
    path = r"D:\PCL 1.13.1\lib"
    Extract_lib(path)

提取FLANN(8)和Qhull(8)

import os

# 设置 Boost lib 文件夹路径和要输出的文本文件名
gd_output_file = "FLANN_debug_libs.txt"
non_gd_output_file = "FLANN_release_libs.txt"


def Extract_lib(boost_lib_path):
    # 获取 Boost lib 文件夹下的所有 .lib 文件名
    all_lib_files = [file for file in os.listdir(boost_lib_path) if file.endswith('.lib')]

    # 分别筛选包含和不包含 "-gd" 的文件名,并输出到不同的文本文件中
    gd_lib_files = [file for file in all_lib_files if '-gd' in file]
    with open(os.path.join(boost_lib_path, gd_output_file), 'w') as outfile:
        for gd_file in gd_lib_files:
            outfile.write(gd_file + '\n')

    non_gd_lib_files = [file for file in all_lib_files if '-gd' not in file]
    with open(os.path.join(boost_lib_path, non_gd_output_file), 'w') as outfile:
        for non_gd_file in non_gd_lib_files:
            outfile.write(non_gd_file + '\n')


if __name__ == '__main__':
    path = r"D:\PCL 1.13.1\3rdParty\FLANN\lib"
    Extract_lib(path)
import os

# 设置 Boost lib 文件夹路径和要输出的文本文件名
gd_output_file = "Qhull_debug_libs.txt"
non_gd_output_file = "Qhull_release_libs.txt"


def Extract_lib(boost_lib_path):
    # 获取 Boost lib 文件夹下的所有 .lib 文件名
    all_lib_files = [file for file in os.listdir(boost_lib_path) if file.endswith('.lib')]

    # 分别筛选包含和不包含 "-gd" 的文件名,并输出到不同的文本文件中
    gd_lib_files = [file for file in all_lib_files if 'd.lib' in file]
    with open(os.path.join(boost_lib_path, gd_output_file), 'w') as outfile:
        for gd_file in gd_lib_files:
            outfile.write(gd_file + '\n')

    non_gd_lib_files = [file for file in all_lib_files if 'd.lib' not in file]
    with open(os.path.join(boost_lib_path, non_gd_output_file), 'w') as outfile:
        for non_gd_file in non_gd_lib_files:
            outfile.write(non_gd_file + '\n')


if __name__ == '__main__':
    path = r"D:\PCL 1.13.1\3rdParty\Qhull\lib"
    Extract_lib(path)

4.5.1 debug模式的附加依赖项

libboost_atomic-vc143-mt-gd-x64-1_82.lib
libboost_bzip2-vc143-mt-gd-x64-1_82.lib
libboost_chrono-vc143-mt-gd-x64-1_82.lib
libboost_container-vc143-mt-gd-x64-1_82.lib
libboost_context-vc143-mt-gd-x64-1_82.lib
libboost_contract-vc143-mt-gd-x64-1_82.lib
libboost_coroutine-vc143-mt-gd-x64-1_82.lib
libboost_date_time-vc143-mt-gd-x64-1_82.lib
libboost_exception-vc143-mt-gd-x64-1_82.lib
libboost_fiber-vc143-mt-gd-x64-1_82.lib
libboost_filesystem-vc143-mt-gd-x64-1_82.lib
libboost_graph-vc143-mt-gd-x64-1_82.lib
libboost_graph_parallel-vc143-mt-gd-x64-1_82.lib
libboost_iostreams-vc143-mt-gd-x64-1_82.lib
libboost_json-vc143-mt-gd-x64-1_82.lib
libboost_locale-vc143-mt-gd-x64-1_82.lib
libboost_log-vc143-mt-gd-x64-1_82.lib
libboost_log_setup-vc143-mt-gd-x64-1_82.lib
libboost_math_c99-vc143-mt-gd-x64-1_82.lib
libboost_math_c99f-vc143-mt-gd-x64-1_82.lib
libboost_math_c99l-vc143-mt-gd-x64-1_82.lib
libboost_math_tr1-vc143-mt-gd-x64-1_82.lib
libboost_math_tr1f-vc143-mt-gd-x64-1_82.lib
libboost_math_tr1l-vc143-mt-gd-x64-1_82.lib
libboost_mpi-vc143-mt-gd-x64-1_82.lib
libboost_nowide-vc143-mt-gd-x64-1_82.lib
libboost_numpy310-vc143-mt-gd-x64-1_82.lib
libboost_prg_exec_monitor-vc143-mt-gd-x64-1_82.lib
libboost_program_options-vc143-mt-gd-x64-1_82.lib
libboost_python310-vc143-mt-gd-x64-1_82.lib
libboost_random-vc143-mt-gd-x64-1_82.lib
libboost_regex-vc143-mt-gd-x64-1_82.lib
libboost_serialization-vc143-mt-gd-x64-1_82.lib
libboost_stacktrace_noop-vc143-mt-gd-x64-1_82.lib
libboost_stacktrace_windbg-vc143-mt-gd-x64-1_82.lib
libboost_stacktrace_windbg_cached-vc143-mt-gd-x64-1_82.lib
libboost_system-vc143-mt-gd-x64-1_82.lib
libboost_test_exec_monitor-vc143-mt-gd-x64-1_82.lib
libboost_thread-vc143-mt-gd-x64-1_82.lib
libboost_timer-vc143-mt-gd-x64-1_82.lib
libboost_type_erasure-vc143-mt-gd-x64-1_82.lib
libboost_unit_test_framework-vc143-mt-gd-x64-1_82.lib
libboost_url-vc143-mt-gd-x64-1_82.lib
libboost_wave-vc143-mt-gd-x64-1_82.lib
libboost_wserialization-vc143-mt-gd-x64-1_82.lib
libboost_zlib-vc143-mt-gd-x64-1_82.lib
flann-gd.lib
flann_cpp-gd.lib
flann_cpp_s-gd.lib
flann_s-gd.lib
pcl_commond.lib
pcl_featuresd.lib
pcl_filtersd.lib
pcl_iod.lib
pcl_io_plyd.lib
pcl_kdtreed.lib
pcl_keypointsd.lib
pcl_mld.lib
pcl_octreed.lib
pcl_outofcored.lib
pcl_peopled.lib
pcl_recognitiond.lib
pcl_registrationd.lib
pcl_sample_consensusd.lib
pcl_searchd.lib
pcl_segmentationd.lib
pcl_stereod.lib
pcl_surfaced.lib
pcl_trackingd.lib
pcl_visualizationd.lib
qhullcpp_d.lib
qhullstatic_d.lib
qhullstatic_rd.lib
qhull_rd.lib
vtkcgns-9.2-gd.lib
vtkChartsCore-9.2-gd.lib
vtkCommonColor-9.2-gd.lib
vtkCommonComputationalGeometry-9.2-gd.lib
vtkCommonCore-9.2-gd.lib
vtkCommonDataModel-9.2-gd.lib
vtkCommonExecutionModel-9.2-gd.lib
vtkCommonMath-9.2-gd.lib
vtkCommonMisc-9.2-gd.lib
vtkCommonSystem-9.2-gd.lib
vtkCommonTransforms-9.2-gd.lib
vtkDICOMParser-9.2-gd.lib
vtkDomainsChemistry-9.2-gd.lib
vtkDomainsChemistryOpenGL2-9.2-gd.lib
vtkdoubleconversion-9.2-gd.lib
vtkexodusII-9.2-gd.lib
vtkexpat-9.2-gd.lib
vtkFiltersAMR-9.2-gd.lib
vtkFiltersCore-9.2-gd.lib
vtkFiltersExtraction-9.2-gd.lib
vtkFiltersFlowPaths-9.2-gd.lib
vtkFiltersGeneral-9.2-gd.lib
vtkFiltersGeneric-9.2-gd.lib
vtkFiltersGeometry-9.2-gd.lib
vtkFiltersHybrid-9.2-gd.lib
vtkFiltersHyperTree-9.2-gd.lib
vtkFiltersImaging-9.2-gd.lib
vtkFiltersModeling-9.2-gd.lib
vtkFiltersParallel-9.2-gd.lib
vtkFiltersParallelImaging-9.2-gd.lib
vtkFiltersPoints-9.2-gd.lib
vtkFiltersProgrammable-9.2-gd.lib
vtkFiltersSelection-9.2-gd.lib
vtkFiltersSMP-9.2-gd.lib
vtkFiltersSources-9.2-gd.lib
vtkFiltersStatistics-9.2-gd.lib
vtkFiltersTexture-9.2-gd.lib
vtkFiltersTopology-9.2-gd.lib
vtkFiltersVerdict-9.2-gd.lib
vtkfmt-9.2-gd.lib
vtkfreetype-9.2-gd.lib
vtkGeovisCore-9.2-gd.lib
vtkgl2ps-9.2-gd.lib
vtkglew-9.2-gd.lib
vtkhdf5-9.2-gd.lib
vtkhdf5_hl-9.2-gd.lib
vtkImagingColor-9.2-gd.lib
vtkImagingCore-9.2-gd.lib
vtkImagingFourier-9.2-gd.lib
vtkImagingGeneral-9.2-gd.lib
vtkImagingHybrid-9.2-gd.lib
vtkImagingMath-9.2-gd.lib
vtkImagingMorphological-9.2-gd.lib
vtkImagingSources-9.2-gd.lib
vtkImagingStatistics-9.2-gd.lib
vtkImagingStencil-9.2-gd.lib
vtkInfovisCore-9.2-gd.lib
vtkInfovisLayout-9.2-gd.lib
vtkInteractionImage-9.2-gd.lib
vtkInteractionStyle-9.2-gd.lib
vtkInteractionWidgets-9.2-gd.lib
vtkIOAMR-9.2-gd.lib
vtkIOAsynchronous-9.2-gd.lib
vtkIOCesium3DTiles-9.2-gd.lib
vtkIOCGNSReader-9.2-gd.lib
vtkIOChemistry-9.2-gd.lib
vtkIOCityGML-9.2-gd.lib
vtkIOCONVERGECFD-9.2-gd.lib
vtkIOCore-9.2-gd.lib
vtkIOEnSight-9.2-gd.lib
vtkIOExodus-9.2-gd.lib
vtkIOExport-9.2-gd.lib
vtkIOExportGL2PS-9.2-gd.lib
vtkIOExportPDF-9.2-gd.lib
vtkIOGeometry-9.2-gd.lib
vtkIOHDF-9.2-gd.lib
vtkIOImage-9.2-gd.lib
vtkIOImport-9.2-gd.lib
vtkIOInfovis-9.2-gd.lib
vtkIOIOSS-9.2-gd.lib
vtkIOLegacy-9.2-gd.lib
vtkIOLSDyna-9.2-gd.lib
vtkIOMINC-9.2-gd.lib
vtkIOMotionFX-9.2-gd.lib
vtkIOMovie-9.2-gd.lib
vtkIONetCDF-9.2-gd.lib
vtkIOOggTheora-9.2-gd.lib
vtkIOParallel-9.2-gd.lib
vtkIOParallelXML-9.2-gd.lib
vtkIOPLY-9.2-gd.lib
vtkIOSegY-9.2-gd.lib
vtkIOSQL-9.2-gd.lib
vtkioss-9.2-gd.lib
vtkIOTecplotTable-9.2-gd.lib
vtkIOVeraOut-9.2-gd.lib
vtkIOVideo-9.2-gd.lib
vtkIOXML-9.2-gd.lib
vtkIOXMLParser-9.2-gd.lib
vtkjpeg-9.2-gd.lib
vtkjsoncpp-9.2-gd.lib
vtkkissfft-9.2-gd.lib
vtklibharu-9.2-gd.lib
vtklibproj-9.2-gd.lib
vtklibxml2-9.2-gd.lib
vtkloguru-9.2-gd.lib
vtklz4-9.2-gd.lib
vtklzma-9.2-gd.lib
vtkmetaio-9.2-gd.lib
vtknetcdf-9.2-gd.lib
vtkogg-9.2-gd.lib
vtkParallelCore-9.2-gd.lib
vtkParallelDIY-9.2-gd.lib
vtkpng-9.2-gd.lib
vtkpugixml-9.2-gd.lib
vtkRenderingAnnotation-9.2-gd.lib
vtkRenderingContext2D-9.2-gd.lib
vtkRenderingContextOpenGL2-9.2-gd.lib
vtkRenderingCore-9.2-gd.lib
vtkRenderingFreeType-9.2-gd.lib
vtkRenderingGL2PSOpenGL2-9.2-gd.lib
vtkRenderingHyperTreeGrid-9.2-gd.lib
vtkRenderingImage-9.2-gd.lib
vtkRenderingLabel-9.2-gd.lib
vtkRenderingLICOpenGL2-9.2-gd.lib
vtkRenderingLOD-9.2-gd.lib
vtkRenderingOpenGL2-9.2-gd.lib
vtkRenderingSceneGraph-9.2-gd.lib
vtkRenderingUI-9.2-gd.lib
vtkRenderingVolume-9.2-gd.lib
vtkRenderingVolumeOpenGL2-9.2-gd.lib
vtkRenderingVtkJS-9.2-gd.lib
vtksqlite-9.2-gd.lib
vtksys-9.2-gd.lib
vtkTestingRendering-9.2-gd.lib
vtktheora-9.2-gd.lib
vtktiff-9.2-gd.lib
vtkverdict-9.2-gd.lib
vtkViewsContext2D-9.2-gd.lib
vtkViewsCore-9.2-gd.lib
vtkViewsInfovis-9.2-gd.lib
vtkWrappingTools-9.2-gd.lib
vtkzlib-9.2-gd.lib
OpenNI2.lib

保存属性表 

 之后可以通过添加现有属性表找到保存的属性添加就行

4.5.2 release模式的附加依赖项

libboost_atomic-vc143-mt-x64-1_82.lib
libboost_bzip2-vc143-mt-x64-1_82.lib
libboost_chrono-vc143-mt-x64-1_82.lib
libboost_container-vc143-mt-x64-1_82.lib
libboost_context-vc143-mt-x64-1_82.lib
libboost_contract-vc143-mt-x64-1_82.lib
libboost_coroutine-vc143-mt-x64-1_82.lib
libboost_date_time-vc143-mt-x64-1_82.lib
libboost_exception-vc143-mt-x64-1_82.lib
libboost_fiber-vc143-mt-x64-1_82.lib
libboost_filesystem-vc143-mt-x64-1_82.lib
libboost_graph-vc143-mt-x64-1_82.lib
libboost_graph_parallel-vc143-mt-x64-1_82.lib
libboost_iostreams-vc143-mt-x64-1_82.lib
libboost_json-vc143-mt-x64-1_82.lib
libboost_locale-vc143-mt-x64-1_82.lib
libboost_log-vc143-mt-x64-1_82.lib
libboost_log_setup-vc143-mt-x64-1_82.lib
libboost_math_c99-vc143-mt-x64-1_82.lib
libboost_math_c99f-vc143-mt-x64-1_82.lib
libboost_math_c99l-vc143-mt-x64-1_82.lib
libboost_math_tr1-vc143-mt-x64-1_82.lib
libboost_math_tr1f-vc143-mt-x64-1_82.lib
libboost_math_tr1l-vc143-mt-x64-1_82.lib
libboost_mpi-vc143-mt-x64-1_82.lib
libboost_nowide-vc143-mt-x64-1_82.lib
libboost_numpy310-vc143-mt-x64-1_82.lib
libboost_prg_exec_monitor-vc143-mt-x64-1_82.lib
libboost_program_options-vc143-mt-x64-1_82.lib
libboost_python310-vc143-mt-x64-1_82.lib
libboost_random-vc143-mt-x64-1_82.lib
libboost_regex-vc143-mt-x64-1_82.lib
libboost_serialization-vc143-mt-x64-1_82.lib
libboost_stacktrace_noop-vc143-mt-x64-1_82.lib
libboost_stacktrace_windbg-vc143-mt-x64-1_82.lib
libboost_stacktrace_windbg_cached-vc143-mt-x64-1_82.lib
libboost_system-vc143-mt-x64-1_82.lib
libboost_test_exec_monitor-vc143-mt-x64-1_82.lib
libboost_thread-vc143-mt-x64-1_82.lib
libboost_timer-vc143-mt-x64-1_82.lib
libboost_type_erasure-vc143-mt-x64-1_82.lib
libboost_unit_test_framework-vc143-mt-x64-1_82.lib
libboost_url-vc143-mt-x64-1_82.lib
libboost_wave-vc143-mt-x64-1_82.lib
libboost_wserialization-vc143-mt-x64-1_82.lib
libboost_zlib-vc143-mt-x64-1_82.lib
flann.lib
flann_cpp.lib
flann_cpp_s.lib
flann_s.lib
pcl_common.lib
pcl_features.lib
pcl_filters.lib
pcl_io.lib
pcl_io_ply.lib
pcl_kdtree.lib
pcl_keypoints.lib
pcl_ml.lib
pcl_octree.lib
pcl_outofcore.lib
pcl_people.lib
pcl_recognition.lib
pcl_registration.lib
pcl_sample_consensus.lib
pcl_search.lib
pcl_segmentation.lib
pcl_stereo.lib
pcl_surface.lib
pcl_tracking.lib
pcl_visualization.lib
qhullcpp.lib
qhullstatic.lib
qhullstatic_r.lib
qhull_r.lib
vtkcgns-9.2.lib
vtkChartsCore-9.2.lib
vtkCommonColor-9.2.lib
vtkCommonComputationalGeometry-9.2.lib
vtkCommonCore-9.2.lib
vtkCommonDataModel-9.2.lib
vtkCommonExecutionModel-9.2.lib
vtkCommonMath-9.2.lib
vtkCommonMisc-9.2.lib
vtkCommonSystem-9.2.lib
vtkCommonTransforms-9.2.lib
vtkDICOMParser-9.2.lib
vtkDomainsChemistry-9.2.lib
vtkDomainsChemistryOpenGL2-9.2.lib
vtkdoubleconversion-9.2.lib
vtkexodusII-9.2.lib
vtkexpat-9.2.lib
vtkFiltersAMR-9.2.lib
vtkFiltersCore-9.2.lib
vtkFiltersExtraction-9.2.lib
vtkFiltersFlowPaths-9.2.lib
vtkFiltersGeneral-9.2.lib
vtkFiltersGeneric-9.2.lib
vtkFiltersGeometry-9.2.lib
vtkFiltersHybrid-9.2.lib
vtkFiltersHyperTree-9.2.lib
vtkFiltersImaging-9.2.lib
vtkFiltersModeling-9.2.lib
vtkFiltersParallel-9.2.lib
vtkFiltersParallelImaging-9.2.lib
vtkFiltersPoints-9.2.lib
vtkFiltersProgrammable-9.2.lib
vtkFiltersSelection-9.2.lib
vtkFiltersSMP-9.2.lib
vtkFiltersSources-9.2.lib
vtkFiltersStatistics-9.2.lib
vtkFiltersTexture-9.2.lib
vtkFiltersTopology-9.2.lib
vtkFiltersVerdict-9.2.lib
vtkfmt-9.2.lib
vtkfreetype-9.2.lib
vtkGeovisCore-9.2.lib
vtkgl2ps-9.2.lib
vtkglew-9.2.lib
vtkhdf5-9.2.lib
vtkhdf5_hl-9.2.lib
vtkImagingColor-9.2.lib
vtkImagingCore-9.2.lib
vtkImagingFourier-9.2.lib
vtkImagingGeneral-9.2.lib
vtkImagingHybrid-9.2.lib
vtkImagingMath-9.2.lib
vtkImagingMorphological-9.2.lib
vtkImagingSources-9.2.lib
vtkImagingStatistics-9.2.lib
vtkImagingStencil-9.2.lib
vtkInfovisCore-9.2.lib
vtkInfovisLayout-9.2.lib
vtkInteractionImage-9.2.lib
vtkInteractionStyle-9.2.lib
vtkInteractionWidgets-9.2.lib
vtkIOAMR-9.2.lib
vtkIOAsynchronous-9.2.lib
vtkIOCesium3DTiles-9.2.lib
vtkIOCGNSReader-9.2.lib
vtkIOChemistry-9.2.lib
vtkIOCityGML-9.2.lib
vtkIOCONVERGECFD-9.2.lib
vtkIOCore-9.2.lib
vtkIOEnSight-9.2.lib
vtkIOExodus-9.2.lib
vtkIOExport-9.2.lib
vtkIOExportGL2PS-9.2.lib
vtkIOExportPDF-9.2.lib
vtkIOGeometry-9.2.lib
vtkIOHDF-9.2.lib
vtkIOImage-9.2.lib
vtkIOImport-9.2.lib
vtkIOInfovis-9.2.lib
vtkIOIOSS-9.2.lib
vtkIOLegacy-9.2.lib
vtkIOLSDyna-9.2.lib
vtkIOMINC-9.2.lib
vtkIOMotionFX-9.2.lib
vtkIOMovie-9.2.lib
vtkIONetCDF-9.2.lib
vtkIOOggTheora-9.2.lib
vtkIOParallel-9.2.lib
vtkIOParallelXML-9.2.lib
vtkIOPLY-9.2.lib
vtkIOSegY-9.2.lib
vtkIOSQL-9.2.lib
vtkioss-9.2.lib
vtkIOTecplotTable-9.2.lib
vtkIOVeraOut-9.2.lib
vtkIOVideo-9.2.lib
vtkIOXML-9.2.lib
vtkIOXMLParser-9.2.lib
vtkjpeg-9.2.lib
vtkjsoncpp-9.2.lib
vtkkissfft-9.2.lib
vtklibharu-9.2.lib
vtklibproj-9.2.lib
vtklibxml2-9.2.lib
vtkloguru-9.2.lib
vtklz4-9.2.lib
vtklzma-9.2.lib
vtkmetaio-9.2.lib
vtknetcdf-9.2.lib
vtkogg-9.2.lib
vtkParallelCore-9.2.lib
vtkParallelDIY-9.2.lib
vtkpng-9.2.lib
vtkpugixml-9.2.lib
vtkRenderingAnnotation-9.2.lib
vtkRenderingContext2D-9.2.lib
vtkRenderingContextOpenGL2-9.2.lib
vtkRenderingCore-9.2.lib
vtkRenderingFreeType-9.2.lib
vtkRenderingGL2PSOpenGL2-9.2.lib
vtkRenderingHyperTreeGrid-9.2.lib
vtkRenderingImage-9.2.lib
vtkRenderingLabel-9.2.lib
vtkRenderingLICOpenGL2-9.2.lib
vtkRenderingLOD-9.2.lib
vtkRenderingOpenGL2-9.2.lib
vtkRenderingSceneGraph-9.2.lib
vtkRenderingUI-9.2.lib
vtkRenderingVolume-9.2.lib
vtkRenderingVolumeOpenGL2-9.2.lib
vtkRenderingVtkJS-9.2.lib
vtksqlite-9.2.lib
vtksys-9.2.lib
vtkTestingRendering-9.2.lib
vtktheora-9.2.lib
vtktiff-9.2.lib
vtkverdict-9.2.lib
vtkViewsContext2D-9.2.lib
vtkViewsCore-9.2.lib
vtkViewsInfovis-9.2.lib
vtkWrappingTools-9.2.lib
vtkzlib-9.2.lib
OpenNI2.lib

5、测试

#include <iostream>
#include <vector>
#include <ctime>
#include <pcl/point_cloud.h>
#include <pcl/octree/octree.h>
#include <boost/thread/thread.hpp>
#include <pcl/visualization/pcl_visualizer.h>
using namespace std;


int main(int argc, char** argv)
{
	srand((unsigned int)time(NULL));
	pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
	// 创建点云数据
	cloud->width = 1000;
	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.0f * rand() / (RAND_MAX + 1.0f);
		cloud->points[i].y = 1024.0f * rand() / (RAND_MAX + 1.0f);
		cloud->points[i].z = 1024.0f * rand() / (RAND_MAX + 1.0f);
	}

	pcl::octree::OctreePointCloudSearch<pcl::PointXYZ> octree(0.1);
	octree.setInputCloud(cloud);
	octree.addPointsFromInputCloud();
	pcl::PointXYZ searchPoint;
	searchPoint.x = 1024.0f * rand() / (RAND_MAX + 1.0f);
	searchPoint.y = 1024.0f * rand() / (RAND_MAX + 1.0f);
	searchPoint.z = 1024.0f * rand() / (RAND_MAX + 1.0f);

	//半径内近邻搜索
	vector<int>pointIdxRadiusSearch;
	vector<float>pointRadiusSquaredDistance;
	float radius = 256.0f * rand() / (RAND_MAX + 1.0f);
	cout << "Neighbors within radius search at (" << searchPoint.x
		<< " " << searchPoint.y
		<< " " << searchPoint.z
		<< ") with radius=" << radius << endl;
	if (octree.radiusSearch(searchPoint, radius, pointIdxRadiusSearch, pointRadiusSquaredDistance) > 0)
	{
		for (size_t i = 0; i < pointIdxRadiusSearch.size(); ++i)
			cout << "    " << cloud->points[pointIdxRadiusSearch[i]].x
			<< " " << cloud->points[pointIdxRadiusSearch[i]].y
			<< " " << cloud->points[pointIdxRadiusSearch[i]].z
			<< " (squared distance: " << pointRadiusSquaredDistance[i] << ")" << endl;
	}
	// 初始化点云可视化对象
	boost::shared_ptr<pcl::visualization::PCLVisualizer>viewer(new pcl::visualization::PCLVisualizer("Display Point Cloud"));
	viewer->setBackgroundColor(255, 245, 238);  //设置背景颜色为黑色
	// 对点云着色可视化 (red).
	pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ>target_color(cloud, 255, 0, 0);
	viewer->addPointCloud<pcl::PointXYZ>(cloud, target_color, "target cloud");
	viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "target cloud");

	// 等待直到可视化窗口关闭
	while (!viewer->wasStopped())
	{
		viewer->spinOnce(100);
		boost::this_thread::sleep(boost::posix_time::microseconds(1000));
	}

	return (0);
}

#include <iostream>
#include <pcl/common/common_headers.h>
#include <pcl/io/pcd_io.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/visualization/cloud_viewer.h>
#include <pcl/console/parse.h>


int main(int argc, char** argv) {
    std::cout << "Test PCL !!!" << std::endl;

    pcl::PointCloud<pcl::PointXYZRGB>::Ptr point_cloud_ptr(new pcl::PointCloud<pcl::PointXYZRGB>);
    uint8_t r(255), g(15), b(15);
    for (float z(-1.0); z <= 1.0; z += 0.05)
    {
        for (float angle(0.0); angle <= 360.0; angle += 5.0)
        {
            pcl::PointXYZRGB point;
            point.x = 0.5 * cosf(pcl::deg2rad(angle));
            point.y = sinf(pcl::deg2rad(angle));
            point.z = z;
            uint32_t rgb = (static_cast<uint32_t>(r) << 16 |
                static_cast<uint32_t>(g) << 8 | static_cast<uint32_t>(b));
            point.rgb = *reinterpret_cast<float*>(&rgb);
            point_cloud_ptr->points.push_back(point);
        }
        if (z < 0.0)
        {
            r -= 12;
            g += 12;
        }
        else
        {
            g -= 12;
            b += 12;
        }
    }
    point_cloud_ptr->width = (int)point_cloud_ptr->points.size();
    point_cloud_ptr->height = 1;

    pcl::visualization::CloudViewer viewer("test");
    viewer.showCloud(point_cloud_ptr);
    while (!viewer.wasStopped()) {};
    return 0;
}

#include<iostream>
#include <vector>
#include<pcl/io/pcd_io.h>
#include<pcl/visualization/pcl_visualizer.h>
#include<pcl/point_types.h>
#include<pcl/filters/voxel_grid.h>
#include <pcl/filters/extract_indices.h>
#include<pcl/filters/passthrough.h>
#include <pcl/segmentation/progressive_morphological_filter.h>
using namespace std; //use  namespace "std"
using namespace pcl;  //use namesapce "pcl",引入这个命名空间后可以简化代码

#define  PI 3.141592653
//点云去噪
void pclMyFilter(string path)
{
	//点云指针类型对象,访问方式:cloud->point[i].x
	pcl::PCLPointCloud2::Ptr cloud(new pcl::PCLPointCloud2);//原始点云文件
	pcl::PCLPointCloud2::Ptr cloud_filtered(new pcl::PCLPointCloud2);//去噪后所生成的新的点云文件

	//输入点云数据
	pcl::PCDReader reader;
	reader.read(path, *cloud);
	//去噪之前点云数量统计
	cout << "pointcloud before filtering :" << cloud->width * cloud->height << "data points(" << pcl::getFieldsList(*cloud) << ")." << endl;

	//创建去噪 实例化一个对象  方法采用VoxelGrid
	pcl::VoxelGrid<pcl::PCLPointCloud2> vgd;
	//输入要处理的原始点云数据
	vgd.setInputCloud(cloud);
	//设置叶子大小
	vgd.setLeafSize(2.0f, 2.0f, 2.0f);
	vgd.filter(*cloud_filtered);
	//去噪后的点云数量统计
	cout << "pointcloud after filtering:" << cloud_filtered->width * cloud_filtered->height << "data points(" << pcl::getFieldsList(*cloud_filtered) << ")." << endl;


	//将去噪后的点云写入新的pcd文件中
	pcl::PCDWriter writer;
	writer.write("./data/samp12_quzao.pcd", *cloud_filtered, Eigen::Vector4f::Zero(), Eigen::Quaternionf::Identity(), false);
}

//可视化点云
int pclMyShow(string path)
{
	/*---------------------------加载点云-----------------------------
	* 1、创建点云对象
	* 2、判断并读取点云文件
	* 3、输出点云数量
	*/
	pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZRGB>);  //使用PointXYZRGB类实例化一个对象cloud
	// PointCloud<PointXYZRGB>::Ptr cloud(new PointCloud<PointXYZRGB>);  //简化后的代码
	pcl::PCDReader pcdread;
	if (pcdread.read(path, *cloud) < 0)
	{
		PCL_ERROR("\a->点云文件不存在!\n");
		system("pause");
		return 1;
	}
	cout << "->加载了" << cloud->points.size() << "个数据点" << endl;


	//-------------------------Visualizer 可视化------------------------------
	pcl::visualization::PCLVisualizer::Ptr viewer(new pcl::visualization::PCLVisualizer("3D Point Cloud Viewer"));  //创建视图对象,定义标题栏名称“3D Viewer”
	viewer->addPointCloud<pcl::PointXYZRGB>(cloud, "samp12_cloud"); //将点云添加到视图对象中,并定义一个唯一的ID

	pcl::visualization::PointCloudColorHandlerGenericField<pcl::PointXYZRGB> fildcolor(cloud, "z");//按照z字段进行渲染
	/****************注意此处ID不能与视图对象的ID值相同,否则会报错****************************/
	viewer->addPointCloud<pcl::PointXYZRGB>(cloud, fildcolor, "samp12cloud");


	/*下面的ID值应该与上面两个ID其中一个相同,即与dataset or fildcolor的ID相同,不能重新定义ID
	否则会报错"Could not find any PointCloud datasets with id <Csite2_cloud1>!"*/

	viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 4.5, "samp12cloud");//设置点云大小
	viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_COLOR, 1, 0.5, 0.9, "samp12_cloud");//设置点云显示颜色,rgb颜色范围在0~1之间
	viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_OPACITY, 0.8, "samp12cloud");//设置点云透明度
	viewer->setBackgroundColor(0, 0, 0);//窗口背景色,黑色
	viewer->addText("samp12", 20, 20, "text_1");//在指定位置添加文字

	//必选
	while (!viewer->wasStopped())
	{
		viewer->spinOnce(100);
		//boost::this_thread::sleep(boost::posix_time::microseconds(100000));
	}
}

int main()
{
	//pclMyFilter("./data/samp12.pcd");
	pclMyShow("DKdata2.pcd");
	return 0;
}

 ps:测试用例中的pcd点云数据可以用其他数据代替,比如斯坦福的兔子

参考:Win10 系统下VisualStudio2022 配置点云库 PCL 1.13.0

           Windows11+VS2022+PCL1.13.0 安装配置记录