1.PCL12的下载和安装
- 下载地址:https://github.com/PointCloudLibrary/pcl/releases
- 下载完成后安装
- 这里选择添加环境变量
-
安装完成以后环境变量中就有这几个
-
且在C盘的 C:\Program Files 下,会有OpenNI2这个文件夹。
2.环境变量配置
- 在环境变量中添加如下路径。(按照自己的安装路径来)
3.配置VS2022
-
新建一个空项目,并且在空项目里新建一个CPP文件。
-
右击PCL12,点击属性
-
配置:所有配置 平台:所有平台 , 然后点击 VC++目录
-
VC++ 目录 --> 包含目录 配置如下
-
VC++ 目录 --> 库目录 配置如下
-
SDL检查 – > 否
-
点击确认 先保存
-
将VTK 和 PCL 的 LIB 分开放
-
打开VTK lib 文件 F:\Program Files\PCL 1.12.0\3rdParty\VTK\lib
-
将里面的带d 和 不带d 的文件 区分开
-
带d的 放到debug环境下
-
不带d的 放到release下
-
打开cmd 进入到VTK的 lib 目录
-
共260个文件
-
在cmd 输入 dir *d.lib /B
-
得到所有带d的文件lib,放到debug下
vtkChartsCore-9.0d.lib
vtkCommonColor-9.0d.lib
vtkCommonComputationalGeometry-9.0d.lib
vtkCommonCore-9.0d.lib
vtkCommonDataModel-9.0d.lib
vtkCommonExecutionModel-9.0d.lib
vtkCommonMath-9.0d.lib
vtkCommonMisc-9.0d.lib
vtkCommonSystem-9.0d.lib
vtkCommonTransforms-9.0d.lib
vtkDICOMParser-9.0d.lib
vtkDomainsChemistry-9.0d.lib
vtkDomainsChemistryOpenGL2-9.0d.lib
vtkdoubleconversion-9.0d.lib
vtkexodusII-9.0d.lib
vtkexpat-9.0d.lib
vtkFiltersAMR-9.0d.lib
vtkFiltersCore-9.0d.lib
vtkFiltersExtraction-9.0d.lib
vtkFiltersFlowPaths-9.0d.lib
vtkFiltersGeneral-9.0d.lib
vtkFiltersGeneric-9.0d.lib
vtkFiltersGeometry-9.0d.lib
vtkFiltersHybrid-9.0d.lib
vtkFiltersHyperTree-9.0d.lib
vtkFiltersImaging-9.0d.lib
vtkFiltersModeling-9.0d.lib
vtkFiltersParallel-9.0d.lib
vtkFiltersParallelImaging-9.0d.lib
vtkFiltersPoints-9.0d.lib
vtkFiltersProgrammable-9.0d.lib
vtkFiltersSelection-9.0d.lib
vtkFiltersSMP-9.0d.lib
vtkFiltersSources-9.0d.lib
vtkFiltersStatistics-9.0d.lib
vtkFiltersTexture-9.0d.lib
vtkFiltersTopology-9.0d.lib
vtkFiltersVerdict-9.0d.lib
vtkfreetype-9.0d.lib
vtkGeovisCore-9.0d.lib
vtkgl2ps-9.0d.lib
vtkglew-9.0d.lib
vtkhdf5-9.0d.lib
vtkhdf5_hl-9.0d.lib
vtkImagingColor-9.0d.lib
vtkImagingCore-9.0d.lib
vtkImagingFourier-9.0d.lib
vtkImagingGeneral-9.0d.lib
vtkImagingHybrid-9.0d.lib
vtkImagingMath-9.0d.lib
vtkImagingMorphological-9.0d.lib
vtkImagingSources-9.0d.lib
vtkImagingStatistics-9.0d.lib
vtkImagingStencil-9.0d.lib
vtkInfovisCore-9.0d.lib
vtkInfovisLayout-9.0d.lib
vtkInteractionImage-9.0d.lib
vtkInteractionStyle-9.0d.lib
vtkInteractionWidgets-9.0d.lib
vtkIOAMR-9.0d.lib
vtkIOAsynchronous-9.0d.lib
vtkIOCityGML-9.0d.lib
vtkIOCore-9.0d.lib
vtkIOEnSight-9.0d.lib
vtkIOExodus-9.0d.lib
vtkIOExport-9.0d.lib
vtkIOExportGL2PS-9.0d.lib
vtkIOExportPDF-9.0d.lib
vtkIOGeometry-9.0d.lib
vtkIOImage-9.0d.lib
vtkIOImport-9.0d.lib
vtkIOInfovis-9.0d.lib
vtkIOLegacy-9.0d.lib
vtkIOLSDyna-9.0d.lib
vtkIOMINC-9.0d.lib
vtkIOMotionFX-9.0d.lib
vtkIOMovie-9.0d.lib
vtkIONetCDF-9.0d.lib
vtkIOOggTheora-9.0d.lib
vtkIOParallel-9.0d.lib
vtkIOParallelXML-9.0d.lib
vtkIOPLY-9.0d.lib
vtkIOSegY-9.0d.lib
vtkIOSQL-9.0d.lib
vtkIOTecplotTable-9.0d.lib
vtkIOVeraOut-9.0d.lib
vtkIOVideo-9.0d.lib
vtkIOXML-9.0d.lib
vtkIOXMLParser-9.0d.lib
vtkjpeg-9.0d.lib
vtkjsoncpp-9.0d.lib
vtklibharu-9.0d.lib
vtklibproj-9.0d.lib
vtklibxml2-9.0d.lib
vtkloguru-9.0d.lib
vtklz4-9.0d.lib
vtklzma-9.0d.lib
vtkmetaio-9.0d.lib
vtknetcdf-9.0d.lib
vtkogg-9.0d.lib
vtkParallelCore-9.0d.lib
vtkParallelDIY-9.0d.lib
vtkpng-9.0d.lib
vtkpugixml-9.0d.lib
vtkRenderingAnnotation-9.0d.lib
vtkRenderingContext2D-9.0d.lib
vtkRenderingContextOpenGL2-9.0d.lib
vtkRenderingCore-9.0d.lib
vtkRenderingFreeType-9.0d.lib
vtkRenderingGL2PSOpenGL2-9.0d.lib
vtkRenderingImage-9.0d.lib
vtkRenderingLabel-9.0d.lib
vtkRenderingLOD-9.0d.lib
vtkRenderingOpenGL2-9.0d.lib
vtkRenderingSceneGraph-9.0d.lib
vtkRenderingUI-9.0d.lib
vtkRenderingVolume-9.0d.lib
vtkRenderingVolumeOpenGL2-9.0d.lib
vtkRenderingVtkJS-9.0d.lib
vtksqlite-9.0d.lib
vtksys-9.0d.lib
vtkTestingRendering-9.0d.lib
vtktheora-9.0d.lib
vtktiff-9.0d.lib
vtkverdict-9.0d.lib
vtkViewsContext2D-9.0d.lib
vtkViewsCore-9.0d.lib
vtkViewsInfovis-9.0d.lib
vtkWrappingTools-9.0d.lib
vtkzlib-9.0d.lib
- 同理,去PCL LIB下 找到所有带d的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
- 至此debug环境下配置完成
- 现在配置release下
- 去PCL LIB文件下 取出所有不带d的
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
- 去VTK LIB下 取出不带d的
vtkChartsCore-9.0.lib
vtkCommonColor-9.0.lib
vtkCommonComputationalGeometry-9.0.lib
vtkCommonCore-9.0.lib
vtkCommonDataModel-9.0.lib
vtkCommonExecutionModel-9.0.lib
vtkCommonMath-9.0.lib
vtkCommonMisc-9.0.lib
vtkCommonSystem-9.0.lib
vtkCommonTransforms-9.0.lib
vtkDICOMParser-9.0.lib
vtkDomainsChemistry-9.0.lib
vtkDomainsChemistryOpenGL2-9.0.lib
vtkdoubleconversion-9.0.lib
vtkexodusII-9.0.lib
vtkexpat-9.0.lib
vtkFiltersAMR-9.0.lib
vtkFiltersCore-9.0.lib
vtkFiltersExtraction-9.0.lib
vtkFiltersFlowPaths-9.0.lib
vtkFiltersGeneral-9.0.lib
vtkFiltersGeneric-9.0.lib
vtkFiltersGeometry-9.0.lib
vtkFiltersHybrid-9.0.lib
vtkFiltersHyperTree-9.0.lib
vtkFiltersImaging-9.0.lib
vtkFiltersModeling-9.0.lib
vtkFiltersParallel-9.0.lib
vtkFiltersParallelImaging-9.0.lib
vtkFiltersPoints-9.0.lib
vtkFiltersProgrammable-9.0.lib
vtkFiltersSelection-9.0.lib
vtkFiltersSMP-9.0.lib
vtkFiltersSources-9.0.lib
vtkFiltersStatistics-9.0.lib
vtkFiltersTexture-9.0.lib
vtkFiltersTopology-9.0.lib
vtkFiltersVerdict-9.0.lib
vtkfreetype-9.0.lib
vtkGeovisCore-9.0.lib
vtkgl2ps-9.0.lib
vtkglew-9.0.lib
vtkhdf5-9.0.lib
vtkhdf5_hl-9.0.lib
vtkImagingColor-9.0.lib
vtkImagingCore-9.0.lib
vtkImagingFourier-9.0.lib
vtkImagingGeneral-9.0.lib
vtkImagingHybrid-9.0.lib
vtkImagingMath-9.0.lib
vtkImagingMorphological-9.0.lib
vtkImagingSources-9.0.lib
vtkImagingStatistics-9.0.lib
vtkImagingStencil-9.0.lib
vtkInfovisCore-9.0.lib
vtkInfovisLayout-9.0.lib
vtkInteractionImage-9.0.lib
vtkInteractionStyle-9.0.lib
vtkInteractionWidgets-9.0.lib
vtkIOAMR-9.0.lib
vtkIOAsynchronous-9.0.lib
vtkIOCityGML-9.0.lib
vtkIOCore-9.0.lib
vtkIOEnSight-9.0.lib
vtkIOExodus-9.0.lib
vtkIOExport-9.0.lib
vtkIOExportGL2PS-9.0.lib
vtkIOExportPDF-9.0.lib
vtkIOGeometry-9.0.lib
vtkIOImage-9.0.lib
vtkIOImport-9.0.lib
vtkIOInfovis-9.0.lib
vtkIOLegacy-9.0.lib
vtkIOLSDyna-9.0.lib
vtkIOMINC-9.0.lib
vtkIOMotionFX-9.0.lib
vtkIOMovie-9.0.lib
vtkIONetCDF-9.0.lib
vtkIOOggTheora-9.0.lib
vtkIOParallel-9.0.lib
vtkIOParallelXML-9.0.lib
vtkIOPLY-9.0.lib
vtkIOSegY-9.0.lib
vtkIOSQL-9.0.lib
vtkIOTecplotTable-9.0.lib
vtkIOVeraOut-9.0.lib
vtkIOVideo-9.0.lib
vtkIOXML-9.0.lib
vtkIOXMLParser-9.0.lib
vtkjpeg-9.0.lib
vtkjsoncpp-9.0.lib
vtklibharu-9.0.lib
vtklibproj-9.0.lib
vtklibxml2-9.0.lib
vtkloguru-9.0.lib
vtklz4-9.0.lib
vtklzma-9.0.lib
vtkmetaio-9.0.lib
vtknetcdf-9.0.lib
vtkogg-9.0.lib
vtkParallelCore-9.0.lib
vtkParallelDIY-9.0.lib
vtkpng-9.0.lib
vtkpugixml-9.0.lib
vtkRenderingAnnotation-9.0.lib
vtkRenderingContext2D-9.0.lib
vtkRenderingContextOpenGL2-9.0.lib
vtkRenderingCore-9.0.lib
vtkRenderingFreeType-9.0.lib
vtkRenderingGL2PSOpenGL2-9.0.lib
vtkRenderingImage-9.0.lib
vtkRenderingLabel-9.0.lib
vtkRenderingLOD-9.0.lib
vtkRenderingOpenGL2-9.0.lib
vtkRenderingSceneGraph-9.0.lib
vtkRenderingUI-9.0.lib
vtkRenderingVolume-9.0.lib
vtkRenderingVolumeOpenGL2-9.0.lib
vtkRenderingVtkJS-9.0.lib
vtksqlite-9.0.lib
vtksys-9.0.lib
vtkTestingRendering-9.0.lib
vtktheora-9.0.lib
vtktiff-9.0.lib
vtkverdict-9.0.lib
vtkViewsContext2D-9.0.lib
vtkViewsCore-9.0.lib
vtkViewsInfovis-9.0.lib
vtkWrappingTools-9.0.lib
vtkzlib-9.0.lib
- 最后还有几个预处理
重启电脑!不然会出现找不到pcl_commond.DLL
#include<iostream>
#include<pcl/io/pcd_io.h>
#include<pcl/io/ply_io.h>
#include<pcl/visualization/cloud_viewer.h>
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;
}
感谢知乎上某大哥的讲解
https://zhuanlan.zhihu.com/p/142955614