Win10 系统下VisualStudio2019 配置点云库 PCL1.12.0

目录

    • 一、下载PCL1.12.0
    • 二、安装PCL1.12.0
    • 三、设置VS2019
    • 四、配置PCL1.12.0
    • 五、测试代码
    • 六、文末寄语

一、下载PCL1.12.0

Github下载地址:PCL 1.12.0
在这里插入图片描述

下载红框内的两个文件

二、安装PCL1.12.0

2.1 安装“PCL-1.12.0-AllInOne-msvc2019-win64.exe”。
(1)选择第二个,自动添加系统变量
Win10 系统下VisualStudio2019 配置点云库 PCL1.12.0_第1张图片

(2)安装路径选择D盘,系统会自动新建PCL 1.12.0文件夹。
Win10 系统下VisualStudio2019 配置点云库 PCL1.12.0_第2张图片

2.2 安装完成之后打开文件夹 D:\PCL 1.12.0\3rdParty\OpenNI2
双击OpenNI-Windows-x64-2.2 选择路径(D:\PCL 1.12.0\3rdParty\OpenNI2)安装即可。

对于一些电脑可能会出现安装OpenNI2时未弹出,默认安装在C盘的情况。此时需要到目标文件夹双击安装程序,先点击REMOVE,将原本安装到c盘的卸载掉,之后重新安装到目标文件夹下。这样操作的目的是:①方便查找库的路径。②节约C盘内存。

下图,①②③④为查找OPENNI路径,⑤为安装完毕之后,该文件夹内的内容。Win10 系统下VisualStudio2019 配置点云库 PCL1.12.0_第3张图片

2.3 全部安装完成后,将pcl-1.12.0-pdb-msvc2019-win64.zip解压后的.pdb文件拷贝到(D:\PCL 1.12.0\bin)中。
2.4 设置环境变量:右击计算机—属性—高级系统设置—高级—环境变量—用户变量—Path—编辑!
Win10 系统下VisualStudio2019 配置点云库 PCL1.12.0_第4张图片
在这里直接给出,防止出现错误(依次添加):

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

到此,环境变量的配置完成。配置完成后重启电脑。

三、设置VS2019

3.1 新建空项目
Win10 系统下VisualStudio2019 配置点云库 PCL1.12.0_第5张图片
解决方案配置选择Debug,解决方案平台选择x64。(如果配置Release模式,则解决方案配置选择Release,解决方案平台选择x64
Win10 系统下VisualStudio2019 配置点云库 PCL1.12.0_第6张图片
3.2 新建一个C++源文件
Win10 系统下VisualStudio2019 配置点云库 PCL1.12.0_第7张图片
3.3 右击新建的项目—属性:打开属性表
Win10 系统下VisualStudio2019 配置点云库 PCL1.12.0_第8张图片

3.4 配置属性—调试—环境—添加:
Win10 系统下VisualStudio2019 配置点云库 PCL1.12.0_第9张图片

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

3.5 C/C++—常规—SDL检查:否
Win10 系统下VisualStudio2019 配置点云库 PCL1.12.0_第10张图片
3.6 C/C++—语言—符合模式:否
Win10 系统下VisualStudio2019 配置点云库 PCL1.12.0_第11张图片

四、配置PCL1.12.0

4.1 VC++目录—包含目录,添加7个include路径
Win10 系统下VisualStudio2019 配置点云库 PCL1.12.0_第12张图片

具体添加的include路径如下:

D:\PCL 1.12.0\include\pcl-1.12
D:\PCL 1.12.0\3rdParty\Boost\include\boost-1_76
D:\PCL 1.12.0\3rdParty\Eigen\eigen3
D:\PCL 1.12.0\3rdParty\FLANN\include
D:\PCL 1.12.0\3rdParty\OpenNI2\Include
D:\PCL 1.12.0\3rdParty\Qhull\include
D:\PCL 1.12.0\3rdParty\VTK\include\vtk-9.0

4.2 VC++目录—库目录,添加6个lib路径
Win10 系统下VisualStudio2019 配置点云库 PCL1.12.0_第13张图片

具体添加的lib路径如下:

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

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

BOOST_USE_WINDOWS_H
NOMINMAX
_CRT_SECURE_NO_DEPRECATE

Win10 系统下VisualStudio2019 配置点云库 PCL1.12.0_第14张图片

4.4 链接器—输入—附加依赖项——添加PCL和VTK的相关lib文件。
Win10 系统下VisualStudio2019 配置点云库 PCL1.12.0_第15张图片

具体添加的附加依赖项内容如下:
Debug模式

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-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

Release模式

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
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

注意:一般情况下,Debug模式和Release模式只需配置一种即可。做实验的情况下使用Debug模式较好,产品开发基本都是Release模式。

五、测试代码

#include 
#include 
#include 
#include 
#include 
#include 
#include 
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("显示点云"));
	viewer->setBackgroundColor(0, 0, 0);  //设置背景颜色为黑色
	// 对点云着色可视化 (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);
}

输出下图(数字可能不同),则表示安装成功!
在这里插入图片描述

六、文末寄语

  PCL1.12.0的cloud类的索引可以同时支持int_16t和uint64_t,点索引扩大到2的64次方,这个特性对于大规模场景的点云很友好,避免了索引越界,这意味着可以加载更大的点云数据。另一方面改进了VTK(已更新为VTK9.0),进一步支持CUDA,这可能意味着在未来的版本中PCL就可以做点云的深度学习。
  目前PCL中的Feature、滤波、配准、分割等模块已支持GPU的加速,算法的效率将会有质的提高。后续的博文中将会更新GPU版本的PCL配套代码使用方法。
Win10 系统下VisualStudio2019 配置点云库 PCL1.12.0_第16张图片

你可能感兴趣的:(配库教程,matlab点云工具箱,c++,visual,studio)