Win10 系统下VisualStudio2019 配置点云库PCL 1.12.0

网友投稿 953 2022-09-12

Win10 系统下VisualStudio2019 配置点云库PCL 1.12.0

Win10 系统下VisualStudio2019 配置点云库PCL 1.12.0

Win10 系统下VisualStudio2019 配置点云库PCL 1.12.0

注:下面教程的截图为点云库PCL 1.11.0,步骤都是相同的,只有最后一步修改属性表有些不同。

<–start–>

一、-PCL1.11.0

Github-:安装“PCL-1.11.0-AllInOne-msvc2019-win64.exe”

(1)选择第二个,自动添加系统变量

(2)安装路径选择D盘,系统会自动新建PCL 1.11.0文件夹。

2.2 安装完成之后打开文件夹 D:\PCL 1.11.0\3rdParty\OpenNI2

双击OpenNI-Windows-x64-2.2 选择路径(D:\PCL 1.11.0\3rdParty\OpenNI2)安装即可。

2.3 全部安装完成后,将pcl-1.11.0-pdb-msvc2019-win64.zip解压后的.pdb文件拷贝到(D:\PCL 1.11.0\bin)中。

2.4 设置环境变量:右击计算机—属性—高级系统设置—高级—环境变量—用户变量—Path—编辑!

如下图所示,设置完成后重启电脑。

在这里直接给出,防止出现错误(依次添加):

%PCL_ROOT%\3rdParty\FLANN\bin%PCL_ROOT%\3rdParty\VTK\bin%OPENNI2_REDIST64%%OPENNI2_LIB64%%OPENNI2_INCLUDE64%

到此,环境变量的配置完成。

三、VS2019相关设置

3.1 新建空项目

解决方案配置选择Debug,解决方案平台选择x64。

3.2 新建一个C++源文件

3.3 右击新建的项目—属性:打开属性表

3.4 配置属性—调试—环境—添加:

PATH=D:\PCL 1.11.0\\bin;D:\PCL 1.11.0\\3rdParty\FLANN\bin;D:\PCL 1.11.0\\3rdParty\VTK\bin;D:\PCL 1.11.0\\3rdParty\OpenNI2\Tools

3.5 C/C++—语言—符合模式:否

3.6 C/C++—常规—SDL检查:否

四、配置PCL1.11.0

为了使用方便,这里使用添加属性表的形式。注意:添加属性表的方式,需要再次将属性表内的SDL检测设置为:否。否则将报如下错误:

4.1 视图—其他窗口—属性管理器

4.2 打开属性管理器之后,选择Debug|X64—单击Debug|X64左侧倒三角—右击选择 添加新项目属性表

4.3 项目属性表命名

4.4 双击新添加的属性表—VC++目录—包含目录,添加7个include路径

具体添加的include路径如下:

D:\PCL 1.11.0\include\pcl-1.11D:\PCL 1.11.0\3rdParty\Boost\include\boost-1_73D:\PCL 1.11.0\3rdParty\Eigen\eigen3D:\PCL 1.11.0\3rdParty\FLANN\includeD:\PCL 1.11.0\3rdParty\Qhull\includeD:\PCL 1.11.0\3rdParty\VTK\include\vtk-8.2D:\PCL 1.11.0\3rdParty\OpenNI2\Include

4.5 VC++目录—库目录,添加6个lib路径

具体添加的lib路径如下:

D:\PCL 1.11.0\libD:\PCL 1.11.0\3rdParty\Boost\libD:\PCL 1.11.0\3rdParty\FLANN\libD:\PCL 1.11.0\3rdParty\Qhull\libD:\PCL 1.11.0\3rdParty\OpenNI2\LibD:\PCL 1.11.0\3rdParty\VTK\lib

4.6 C/C++—预处理器—预处理器定义—添加:

BOOST_USE_WINDOWS_HNOMINMAX_CRT_SECURE_NO_DEPRECATE

4.7 链接器—输入—附加依赖项——添加PCL和VTK的相关lib文件。我用的Debug版本。<此处lib文件获取方法见章6>

4.8保存属性表

下一次需要创建新项目的时候,只需进行第三步 VS2019相关设置 的操作,然后打开属性管理器,添加现有属性表,找到之前保存的属性表添加进去即可。

五、测试代码

#include #include #include #include #include #include #include using namespace std;intmain(int argc, char** argv){ srand((unsigned int)time(NULL)); pcl::PointCloud::Ptr cloud(new pcl::PointCloud); // 创建点云数据 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 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); //半径内近邻搜索 vectorpointIdxRadiusSearch; vectorpointRadiusSquaredDistance; 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_ptrviewer(new pcl::visualization::PCLVisualizer("显示点云")); viewer->setBackgroundColor(0, 0, 0); //设置背景颜色为黑色 // 对点云着色可视化 (red). pcl::visualization::PointCloudColorHandlerCustomtarget_color(cloud, 255, 0, 0); viewer->addPointCloud(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);}

输出下图(数字可能不同),则表示安装成功!

<–END–>

六、获取自己的链接库列表

获取pcl文件夹下的lib文件和VTK文件夹中的lib文件

首先:按下快捷键WIN+R打开运行对话框。然后:输入cmd,回车,打开命令提示符窗口。然后:输入cd /d D:\Program Files\PCL1.11.1\lib(其中D:\Program Files\PCL1.11.1\lib是我的路径地址,你找你的)。然后:输入:dir /b *.lib*>0.txt。输入命令后,会自动获取文件夹下所有后缀名为.lib结尾的文件名字,并保存在0.txt文档中。最后:利用下面代码,分离debug和release版本的.lib文件名。

#include #include #include #include using namespace std;int main(){ ifstream txtfile;//打开读取的文件 ofstream txt01;//保存的文件 ofstream txt02;//保存的文件 string temp; int index = 0;//用于判断奇偶 txtfile.open("0.txt", ios::in); while (!txtfile.eof()) // 若未到文件结束一直循环 { getline(txtfile, temp);//一行一行读取 if (index%2==0)//判断除以2的余数,即为奇偶的判断 { txt01.open("1.txt", ios::app); txt01 << temp; txt01 << endl; txt01.close(); } else { txt02.open("2.txt", ios::app); txt02 << temp; txt02 << endl; txt02.close(); } index++; } txtfile.close(); //关闭文件 txtfile.close(); txt01.close(); txt02.close(); return 0;}

附带1.20.0点云库的lib文件,直接拿来用即可。

pcl_commond.libpcl_featuresd.libpcl_filtersd.libpcl_iod.libpcl_io_plyd.libpcl_kdtreed.libpcl_keypointsd.libpcl_mld.libpcl_octreed.libpcl_outofcored.libpcl_peopled.libpcl_recognitiond.libpcl_registrationd.libpcl_sample_consensusd.libpcl_searchd.libpcl_segmentationd.libpcl_stereod.libpcl_surfaced.libpcl_trackingd.libpcl_visualizationd.libvtkChartsCore-9.0d.libvtkCommonColor-9.0d.libvtkCommonComputationalGeometry-9.0d.libvtkCommonCore-9.0d.libvtkCommonDataModel-9.0d.libvtkCommonExecutionModel-9.0d.libvtkCommonMath-9.0d.libvtkCommonMisc-9.0d.libvtkCommonSystem-9.0d.libvtkCommonTransforms-9.0d.libvtkDICOMParser-9.0d.libvtkDomainsChemistry-9.0d.libvtkDomainsChemistryOpenGL2-9.0d.libvtkdoubleconversion-9.0d.libvtkexodusII-9.0d.libvtkexpat-9.0d.libvtkFiltersAMR-9.0d.libvtkFiltersCore-9.0d.libvtkFiltersExtraction-9.0d.libvtkFiltersFlowPaths-9.0d.libvtkFiltersGeneral-9.0d.libvtkFiltersGeneric-9.0d.libvtkFiltersGeometry-9.0d.libvtkFiltersHybrid-9.0d.libvtkFiltersHyperTree-9.0d.libvtkFiltersImaging-9.0d.libvtkFiltersModeling-9.0d.libvtkFiltersParallel-9.0d.libvtkFiltersParallelImaging-9.0d.libvtkFiltersPoints-9.0d.libvtkFiltersProgrammable-9.0d.libvtkFiltersSelection-9.0d.libvtkFiltersSMP-9.0d.libvtkFiltersSources-9.0d.libvtkFiltersStatistics-9.0d.libvtkFiltersTexture-9.0d.libvtkFiltersTopology-9.0d.libvtkFiltersVerdict-9.0d.libvtkfreetype-9.0d.libvtkGeovisCore-9.0d.libvtkgl2ps-9.0d.libvtkglew-9.0d.libvtkhdf5-9.0d.libvtkhdf5_hl-9.0d.libvtkImagingColor-9.0d.libvtkImagingCore-9.0d.libvtkImagingFourier-9.0d.libvtkImagingGeneral-9.0d.libvtkImagingHybrid-9.0d.libvtkImagingMath-9.0d.libvtkImagingMorphological-9.0d.libvtkImagingSources-9.0d.libvtkImagingStatistics-9.0d.libvtkImagingStencil-9.0d.libvtkInfovisCore-9.0d.libvtkInfovisLayout-9.0d.libvtkInteractionImage-9.0d.libvtkInteractionStyle-9.0d.libvtkInteractionWidgets-9.0d.libvtkIOAMR-9.0d.libvtkIOAsynchronous-9.0d.libvtkIOCityGML-9.0d.libvtkIOCore-9.0d.libvtkIOEnSight-9.0d.libvtkIOExodus-9.0d.libvtkIOExport-9.0d.libvtkIOExportGL2PS-9.0d.libvtkIOExportPDF-9.0d.libvtkIOGeometry-9.0d.libvtkIOImage-9.0d.libvtkIOImport-9.0d.libvtkIOInfovis-9.0d.libvtkIOLegacy-9.0d.libvtkIOLSDyna-9.0d.libvtkIOMINC-9.0d.libvtkIOMotionFX-9.0d.libvtkIOMovie-9.0d.libvtkIONetCDF-9.0d.libvtkIOOggTheora-9.0d.libvtkIOParallel-9.0d.libvtkIOParallelXML-9.0d.libvtkIOPLY-9.0d.libvtkIOSegY-9.0d.libvtkIOSQL-9.0d.libvtkIOTecplotTable-9.0d.libvtkIOVeraOut-9.0d.libvtkIOVideo-9.0d.libvtkIOXML-9.0d.libvtkIOXMLParser-9.0d.libvtkjpeg-9.0d.libvtkjsoncpp-9.0d.libvtklibharu-9.0d.libvtklibproj-9.0d.libvtklibxml2-9.0d.libvtkloguru-9.0d.libvtklz4-9.0d.libvtklzma-9.0d.libvtkmetaio-9.0d.libvtknetcdf-9.0d.libvtkogg-9.0d.libvtkParallelCore-9.0d.libvtkParallelDIY-9.0d.libvtkpng-9.0d.libvtkpugixml-9.0d.libvtkRenderingAnnotation-9.0d.libvtkRenderingContext2D-9.0d.libvtkRenderingContextOpenGL2-9.0d.libvtkRenderingCore-9.0d.libvtkRenderingFreeType-9.0d.libvtkRenderingGL2PSOpenGL2-9.0d.libvtkRenderingImage-9.0d.libvtkRenderingLabel-9.0d.libvtkRenderingLOD-9.0d.libvtkRenderingOpenGL2-9.0d.libvtkRenderingSceneGraph-9.0d.libvtkRenderingUI-9.0d.libvtkRenderingVolume-9.0d.libvtkRenderingVolumeOpenGL2-9.0d.libvtkRenderingVtkJS-9.0d.libvtksqlite-9.0d.libvtksys-9.0d.libvtkTestingRendering-9.0d.libvtktheora-9.0d.libvtktiff-9.0d.libvtkverdict-9.0d.libvtkViewsContext2D-9.0d.libvtkViewsCore-9.0d.libvtkViewsInfovis-9.0d.libvtkWrappingTools-9.0d.libvtkzlib-9.0d.lib

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:画一个心送给心爱的小姐姐,Python绘图库Turtle
下一篇:致远SPM之金蝶K3集成解决方案
相关文章

 发表评论

暂时没有评论,来抢沙发吧~