目录
1、准备
1、vs2019安装可参考:
https://blog.csdn.net/qq_36556893/article/details/88603729#%E4%B8%80%E3%80%81%E5%AE%98%E7%BD%91%E4%B8%8B%E8%BD%BD
或者关注公众号“软件安装管家”,里面有安装教程(不是打广告,觉得好用单纯推荐)
2、pcl1.10.0下载:https://github.com/PointCloudLibrary/pcl/releases/tag/pcl-1.10.0
或:https://blog.csdn.net/qq_41102371/article/details/125646840
要下载的文件有:
安装包PCL-1.10.0-AllInOne-msvc2019-win64.exe
后期单步调试要用到的PDB文件:
pcl-1.10.0-pdb-msvc2019-win64.zip
2、开始配置
1、安装pcl
安装包是PCL-1.10.0-AllInOne-msvc2019-win64.exe
添加pcl的系统环境变量选择for all users
选择安装位置,我这里选的D盘
若弹出OpenNI的安装,选择安装到D:\Program Files\PCL 1.10.0\3rdParty\OpenNI2目录;
若未提示,或者误操作,那么等待安装完成后找到D:\Program Files\PCL 1.10.0\3rdParty\OpenNI2目录下,有个OpenNI-Windows-x64-2.2.msi双击安装,安装目录选择D:\Program Files\PCL 1.10.0\3rdParty\OpenNI2。
将pcl-1.10.0-pdb-msvc2019-win64.zip解压,复制里面的全部pdb文件到D:\Program Files\PCL 1.10.0\bin
2、环境变量
此电脑->右键属性->高级系统变量->环境变量->系统变量,可以看到系统已经添加好了系统变量。你们的应该是变量名:PCL_ROOT变量值:D:\Program Files\PCL 1.10.0,不用改它。我这里是因为之前配置过pcl1.8.0,现在想让两版本共存而添加的变量PCL_ROOT_10,路径则是安装1.10.0的路径。环境变量的相关问题在此博客有讲:win10+vs2013配置pcl 1.8.0
3、配置项目属性
1、打开vs2019,新建一个win32控制台应用程序
2、配置管理器
选择x64,然后点击右下角关闭即可
3、属性管理器
视图—>其它窗口—>属性管理器
在debug x64上右键新建属性表
双击新建的属性表进行修改
C/C++ —>预处理器
BOOST_USE_WINDOWS_H
NOMINMAX
_CRT_SECURE_NO_DEPRECATE
VC++目录—>包含目录
添加下列目录
前面的D:\Program Files\PCL 1.10.0是安装pcl1.10.0的位置,后面的都是一样的,注意自己的安装位置是不是和我这一样的,不一样的话把前面改成的安装目录
D:\Program Files\PCL 1.10.0\include\pcl-1.10
D:\Program Files\PCL 1.10.0\3rdParty\Boost\include\boost-1_72
D:\Program Files\PCL 1.10.0\3rdParty\Qhull\include
D:\Program Files\PCL 1.10.0\3rdParty\FLANN\include
D:\Program Files\PCL 1.10.0\3rdParty\VTK\include\vtk-8.2
D:\Program Files\PCL 1.10.0\3rdParty\Eigen\eigen3
D:\Program Files\PCL 1.10.0\3rdParty\OpenNI2\Include
或者可以通过红框中的按钮进行手动定位文件夹
然后是库目录,同理
D:\Program Files\PCL 1.10.0\lib
D:\Program Files\PCL 1.10.0\3rdParty\VTK\lib
D:\Program Files\PCL 1.10.0\3rdParty\FLANN\lib
D:\Program Files\PCL 1.10.0\3rdParty\Qhull\lib
D:\Program Files\PCL 1.10.0\3rdParty\Boost\lib
D:\Program Files\PCL 1.10.0\3rdParty\OpenNI2\Lib
链接器—>输入—>附加依赖项
参考:
win10+vs2019+pcl1.11.0安装教程
VS2017C++读取txt文本文档并按奇偶顺序分别保存到新的文档
有点多哦
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
vtkChartsCore-8.2-gd.lib
vtkChartsCore-8.2.lib
vtkCommonColor-8.2-gd.lib
vtkCommonColor-8.2.lib
vtkCommonComputationalGeometry-8.2-gd.lib
vtkCommonComputationalGeometry-8.2.lib
vtkCommonCore-8.2-gd.lib
vtkCommonCore-8.2.lib
vtkCommonDataModel-8.2-gd.lib
vtkCommonDataModel-8.2.lib
vtkCommonExecutionModel-8.2-gd.lib
vtkCommonExecutionModel-8.2.lib
vtkCommonMath-8.2-gd.lib
vtkCommonMath-8.2.lib
vtkCommonMisc-8.2-gd.lib
vtkCommonMisc-8.2.lib
vtkCommonSystem-8.2-gd.lib
vtkCommonSystem-8.2.lib
vtkCommonTransforms-8.2-gd.lib
vtkCommonTransforms-8.2.lib
vtkDICOMParser-8.2-gd.lib
vtkDICOMParser-8.2.lib
vtkDomainsChemistry-8.2-gd.lib
vtkDomainsChemistry-8.2.lib
vtkDomainsChemistryOpenGL2-8.2-gd.lib
vtkDomainsChemistryOpenGL2-8.2.lib
vtkdoubleconversion-8.2-gd.lib
vtkdoubleconversion-8.2.lib
vtkexodusII-8.2-gd.lib
vtkexodusII-8.2.lib
vtkexpat-8.2-gd.lib
vtkexpat-8.2.lib
vtkFiltersAMR-8.2-gd.lib
vtkFiltersAMR-8.2.lib
vtkFiltersCore-8.2-gd.lib
vtkFiltersCore-8.2.lib
vtkFiltersExtraction-8.2-gd.lib
vtkFiltersExtraction-8.2.lib
vtkFiltersFlowPaths-8.2-gd.lib
vtkFiltersFlowPaths-8.2.lib
vtkFiltersGeneral-8.2-gd.lib
vtkFiltersGeneral-8.2.lib
vtkFiltersGeneric-8.2-gd.lib
vtkFiltersGeneric-8.2.lib
vtkFiltersGeometry-8.2-gd.lib
vtkFiltersGeometry-8.2.lib
vtkFiltersHybrid-8.2-gd.lib
vtkFiltersHybrid-8.2.lib
vtkFiltersHyperTree-8.2-gd.lib
vtkFiltersHyperTree-8.2.lib
vtkFiltersImaging-8.2-gd.lib
vtkFiltersImaging-8.2.lib
vtkFiltersModeling-8.2-gd.lib
vtkFiltersModeling-8.2.lib
vtkFiltersParallel-8.2-gd.lib
vtkFiltersParallel-8.2.lib
vtkFiltersParallelImaging-8.2-gd.lib
vtkFiltersParallelImaging-8.2.lib
vtkFiltersPoints-8.2-gd.lib
vtkFiltersPoints-8.2.lib
vtkFiltersProgrammable-8.2-gd.lib
vtkFiltersProgrammable-8.2.lib
vtkFiltersSelection-8.2-gd.lib
vtkFiltersSelection-8.2.lib
vtkFiltersSMP-8.2-gd.lib
vtkFiltersSMP-8.2.lib
vtkFiltersSources-8.2-gd.lib
vtkFiltersSources-8.2.lib
vtkFiltersStatistics-8.2-gd.lib
vtkFiltersStatistics-8.2.lib
vtkFiltersTexture-8.2-gd.lib
vtkFiltersTexture-8.2.lib
vtkFiltersTopology-8.2-gd.lib
vtkFiltersTopology-8.2.lib
vtkFiltersVerdict-8.2-gd.lib
vtkFiltersVerdict-8.2.lib
vtkfreetype-8.2-gd.lib
vtkfreetype-8.2.lib
vtkGeovisCore-8.2-gd.lib
vtkGeovisCore-8.2.lib
vtkgl2ps-8.2-gd.lib
vtkgl2ps-8.2.lib
vtkglew-8.2-gd.lib
vtkglew-8.2.lib
vtkGUISupportMFC-8.2-gd.lib
vtkGUISupportMFC-8.2.lib
vtkhdf5-8.2-gd.lib
vtkhdf5-8.2.lib
vtkhdf5_hl-8.2-gd.lib
vtkhdf5_hl-8.2.lib
vtkImagingColor-8.2-gd.lib
vtkImagingColor-8.2.lib
vtkImagingCore-8.2-gd.lib
vtkImagingCore-8.2.lib
vtkImagingFourier-8.2-gd.lib
vtkImagingFourier-8.2.lib
vtkImagingGeneral-8.2-gd.lib
vtkImagingGeneral-8.2.lib
vtkImagingHybrid-8.2-gd.lib
vtkImagingHybrid-8.2.lib
vtkImagingMath-8.2-gd.lib
vtkImagingMath-8.2.lib
vtkImagingMorphological-8.2-gd.lib
vtkImagingMorphological-8.2.lib
vtkImagingSources-8.2-gd.lib
vtkImagingSources-8.2.lib
vtkImagingStatistics-8.2-gd.lib
vtkImagingStatistics-8.2.lib
vtkImagingStencil-8.2-gd.lib
vtkImagingStencil-8.2.lib
vtkInfovisCore-8.2-gd.lib
vtkInfovisCore-8.2.lib
vtkInfovisLayout-8.2-gd.lib
vtkInfovisLayout-8.2.lib
vtkInteractionImage-8.2-gd.lib
vtkInteractionImage-8.2.lib
vtkInteractionStyle-8.2-gd.lib
vtkInteractionStyle-8.2.lib
vtkInteractionWidgets-8.2-gd.lib
vtkInteractionWidgets-8.2.lib
vtkIOAMR-8.2-gd.lib
vtkIOAMR-8.2.lib
vtkIOAsynchronous-8.2-gd.lib
vtkIOAsynchronous-8.2.lib
vtkIOCityGML-8.2-gd.lib
vtkIOCityGML-8.2.lib
vtkIOCore-8.2-gd.lib
vtkIOCore-8.2.lib
vtkIOEnSight-8.2-gd.lib
vtkIOEnSight-8.2.lib
vtkIOExodus-8.2-gd.lib
vtkIOExodus-8.2.lib
vtkIOExport-8.2-gd.lib
vtkIOExport-8.2.lib
vtkIOExportOpenGL2-8.2-gd.lib
vtkIOExportOpenGL2-8.2.lib
vtkIOExportPDF-8.2-gd.lib
vtkIOExportPDF-8.2.lib
vtkIOGeometry-8.2-gd.lib
vtkIOGeometry-8.2.lib
vtkIOImage-8.2-gd.lib
vtkIOImage-8.2.lib
vtkIOImport-8.2-gd.lib
vtkIOImport-8.2.lib
vtkIOInfovis-8.2-gd.lib
vtkIOInfovis-8.2.lib
vtkIOLegacy-8.2-gd.lib
vtkIOLegacy-8.2.lib
vtkIOLSDyna-8.2-gd.lib
vtkIOLSDyna-8.2.lib
vtkIOMINC-8.2-gd.lib
vtkIOMINC-8.2.lib
vtkIOMovie-8.2-gd.lib
vtkIOMovie-8.2.lib
vtkIONetCDF-8.2-gd.lib
vtkIONetCDF-8.2.lib
vtkIOParallel-8.2-gd.lib
vtkIOParallel-8.2.lib
vtkIOParallelXML-8.2-gd.lib
vtkIOParallelXML-8.2.lib
vtkIOPLY-8.2-gd.lib
vtkIOPLY-8.2.lib
vtkIOSegY-8.2-gd.lib
vtkIOSegY-8.2.lib
vtkIOSQL-8.2-gd.lib
vtkIOSQL-8.2.lib
vtkIOTecplotTable-8.2-gd.lib
vtkIOTecplotTable-8.2.lib
vtkIOVeraOut-8.2-gd.lib
vtkIOVeraOut-8.2.lib
vtkIOVideo-8.2-gd.lib
vtkIOVideo-8.2.lib
vtkIOXML-8.2-gd.lib
vtkIOXML-8.2.lib
vtkIOXMLParser-8.2-gd.lib
vtkIOXMLParser-8.2.lib
vtkjpeg-8.2-gd.lib
vtkjpeg-8.2.lib
vtkjsoncpp-8.2-gd.lib
vtkjsoncpp-8.2.lib
vtklibharu-8.2-gd.lib
vtklibharu-8.2.lib
vtklibxml2-8.2-gd.lib
vtklibxml2-8.2.lib
vtklz4-8.2-gd.lib
vtklz4-8.2.lib
vtklzma-8.2-gd.lib
vtklzma-8.2.lib
vtkmetaio-8.2-gd.lib
vtkmetaio-8.2.lib
vtkNetCDF-8.2-gd.lib
vtkNetCDF-8.2.lib
vtkogg-8.2-gd.lib
vtkogg-8.2.lib
vtkParallelCore-8.2-gd.lib
vtkParallelCore-8.2.lib
vtkpng-8.2-gd.lib
vtkpng-8.2.lib
vtkproj-8.2-gd.lib
vtkproj-8.2.lib
vtkpugixml-8.2-gd.lib
vtkpugixml-8.2.lib
vtkRenderingAnnotation-8.2-gd.lib
vtkRenderingAnnotation-8.2.lib
vtkRenderingContext2D-8.2-gd.lib
vtkRenderingContext2D-8.2.lib
vtkRenderingContextOpenGL2-8.2-gd.lib
vtkRenderingContextOpenGL2-8.2.lib
vtkRenderingCore-8.2-gd.lib
vtkRenderingCore-8.2.lib
vtkRenderingExternal-8.2-gd.lib
vtkRenderingExternal-8.2.lib
vtkRenderingFreeType-8.2-gd.lib
vtkRenderingFreeType-8.2.lib
vtkRenderingGL2PSOpenGL2-8.2-gd.lib
vtkRenderingGL2PSOpenGL2-8.2.lib
vtkRenderingImage-8.2-gd.lib
vtkRenderingImage-8.2.lib
vtkRenderingLabel-8.2-gd.lib
vtkRenderingLabel-8.2.lib
vtkRenderingLOD-8.2-gd.lib
vtkRenderingLOD-8.2.lib
vtkRenderingOpenGL2-8.2-gd.lib
vtkRenderingOpenGL2-8.2.lib
vtkRenderingVolume-8.2-gd.lib
vtkRenderingVolume-8.2.lib
vtkRenderingVolumeOpenGL2-8.2-gd.lib
vtkRenderingVolumeOpenGL2-8.2.lib
vtksqlite-8.2-gd.lib
vtksqlite-8.2.lib
vtksys-8.2-gd.lib
vtksys-8.2.lib
vtktheora-8.2-gd.lib
vtktheora-8.2.lib
vtktiff-8.2-gd.lib
vtktiff-8.2.lib
vtkverdict-8.2-gd.lib
vtkverdict-8.2.lib
vtkViewsContext2D-8.2-gd.lib
vtkViewsContext2D-8.2.lib
vtkViewsCore-8.2-gd.lib
vtkViewsCore-8.2.lib
vtkViewsInfovis-8.2-gd.lib
vtkViewsInfovis-8.2.lib
vtkzlib-8.2-gd.lib
vtkzlib-8.2.lib
通用属性—>C/C++ —>所有选项—>SDL检查—>否
4、解决方案
属性
配置属性—>调试—>环境
注意我这里是PCL_ROOT_10,你们的应该是下面的第二个PCL_ROOT。PCL_ROOT就是前面系统环境变量里面那个。目的就是把目录前面的一串给替换成PCL_ROOT,用的时候直接在PCL_ROOT后面添加子目录,系统就能找到指定的文件了
PATH=$(PCL_ROOT_10)\bin;$(PCL_ROOT_10)\3rdParty\FLANN\bin;$(PCL_ROOT_10)\3rdParty\VTK\bin;$(PCL_ROOT_10)\Qhull\bin;$(PCL_ROOT_10)\3rdParty\OpenNI2\Tools;$(PATH)
PATH=$(PCL_ROOT)\bin;$(PCL_ROOT)\3rdParty\FLANN\bin;$(PCL_ROOT)\3rdParty\VTK\bin;$(PCL_ROOT)\Qhull\bin;$(PCL_ROOT)\3rdParty\OpenNI2\Tools;$(PATH)
这里还要设置SDL检查,选择否或者从父级继承;父级继承的前提是之前的属性表里面已经将SDL检查设置成了否
3、代码检验是否配置成功
将下面的代码复制进去,编译
#include <pcl/point_types.h>
#include <pcl/visualization/cloud_viewer.h>
#include <iostream>
#include <pcl/io/io.h>
#include <pcl/io/pcd_io.h>
int user_data;
void viewerOneOff(pcl::visualization::PCLVisualizer& viewer)
{
viewer.setBackgroundColor(1.0, 0.5, 1.0);
pcl::PointXYZ o;
o.x = 1.0;
o.y = 0;
o.z = 0;
viewer.addSphere(o, 0.25, "sphere", 0);
std::cout << "i only run once" << std::endl;
}
void viewerPsycho(pcl::visualization::PCLVisualizer& viewer)
{
static unsigned count = 0;
std::stringstream ss;
ss << "Once per viewer loop: " << count++;
viewer.removeShape("text", 0);
viewer.addText(ss.str(), 200, 300, "text", 0);
//FIXME: possible race condition here:
user_data++;
}
int
main(int argc,char**argv)
{
pcl::PointCloud<pcl::PointXYZ> cloud;
// 创建点云
cloud.width=100000;
cloud.height=1;
cloud.is_dense=false;
cloud.points.resize(cloud.width*cloud.height);
for(size_t i=0;i<cloud.points.size();++i)
{
球体
//float r = 100.0;
//cloud.points[i].x = 2*r * rand() / (RAND_MAX + 1.0f)-r;
//cloud.points[i].y = sqrt(r*r - cloud.points[i].x*cloud.points[i].x)* rand() / (RAND_MAX + 1.0f) * ( (2 * rand() / (RAND_MAX + 1.0f) - 1)>0 ? 1:-1 );
//cloud.points[i].z = sqrt(r*r - cloud.points[i].x*cloud.points[i].x - cloud.points[i].y*cloud.points[i].y)* rand() / (RAND_MAX + 1.0f) * ((2 * rand() / (RAND_MAX + 1.0f) - 1)>0 ? 1 : -1);
//正方体
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);
}
pcl::io::savePCDFileASCII("test_pcd_write.pcd",cloud);
std::cerr<<"Saved "<<cloud.points.size()<<" data points to test_pcd.pcd."<<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;
pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud1(new pcl::PointCloud<pcl::PointXYZRGBA>);
pcl::io::loadPCDFile("test_pcd_write.pcd", *cloud1);
pcl::visualization::CloudViewer viewer("Cloud Viewer");
//blocks until the cloud is actually rendered
viewer.showCloud(cloud1);
//use the following functions to get access to the underlying more advanced/powerful
//PCLVisualizer
//This will only get called once
viewer.runOnVisualizationThreadOnce(viewerOneOff);
//This will get called once per visualization iteration
viewer.runOnVisualizationThread(viewerPsycho);
while (!viewer.wasStopped())
{
//you can also do cool processing here
//FIXME: Note that this is running in a separate thread from viewerPsycho
//and you should guard against race conditions yourself...
user_data++;
}
system("pause");
return(0);
}
如果成功生成一个正方体点云,那么配置成功
完整项目在此:share_noel/PCL/pcl1.10.0-vs2019.zip
https://blog.csdn.net/qq_41102371/article/details/125646840
参考及感谢:
文中已列出
完
边学边用,如有错漏,敬请指正
--------------------------------------------------------------------------------------------诺有缸的高飞鸟202007