文章目录
- 0.引言
- 1.准备PCL点云库
- 2.VisualStudio相关设置
- 3.配置PCL点云库
- 4.测试PCL
0.引言
因笔者课题涉及点云处理,需要通过PCL进行点云数据分析处理,查阅现有网络资料,实现了VisualStudio2015(x86)配置PCL1.8.1点云库,本文记录实现配置的过程。
1.准备PCL点云库
(1)下载PCL
下载地址: https://github.com/PointCloudLibrary/pcl/releases/tag/pcl-1.8.1
笔者的VS软件为32位的VS2015,下载以下文件(各学者根据自己VS情况下载对应的pcl文件)。
(2)安装PCL
①双击下载的.exe文件进行安装
②将.zip解压,并将里面的所有.pdb文件复制到PCL安装路径下的bin文件中
(3)配置PCL
快捷键Win+Q,搜索“系统环境变量”,打开系统属性对话框,进入“环境变量”进行设置。
%PCL_ROOT%3rdPartyVTKbin
%PCL_ROOT%3rdPartyFLANNbin
%OPENNI2_INCLUDE%
%OPENNI2_LIB%
%OPENNI2_REDIST%
注:设置完环境变量后,一般需要重启电脑,使环境变量生效。
2.VisualStudio相关设置
(1)新建控制台应用
(2)解决方案配置选择Release,平台选择x86
3.配置PCL点云库
(1)在属性管理器中建立项目属性表
(2)打开项目属性表
(3)设置VC++目录下的“包含目录”
$(PCL_ROOT)include
$(PCL_ROOT)3rdPartyBoostincludeboost-1_64
$(PCL_ROOT)3rdPartyEigeneigen3
$(PCL_ROOT)3rdPartyFLANNinclude
$(PCL_ROOT)3rdPartyOpenNI2Include
$(PCL_ROOT)3rdPartyQhullinclude
$(PCL_ROOT)3rdPartyVTKincludevtk-8.0
(4)设置VC++目录下的“库目录”
$(PCL_ROOT)lib
$(PCL_ROOT)3rdPartyBoostlib
$(PCL_ROOT)3rdPartyFLANNlib
$(PCL_ROOT)3rdPartyOpenNI2Lib
$(PCL_ROOT)3rdPartyQhulllib
$(PCL_ROOT)3rdPartyVTKlib
(5)设置C/C++下预处理器的“预处理定义”
BOOST_USE_WINDOWS_H
NOMINMAX
_CRT_SECURE_NO_DEPRECATE
(6)设置链接器下输入的“附加依赖项”
pcl_common_release.lib
pcl_features_release.lib
pcl_filters_release.lib
pcl_io_release.lib
pcl_io_ply_release.lib
pcl_kdtree_release.lib
pcl_keypoints_release.lib
pcl_ml_release.lib
pcl_octree_release.lib
pcl_outofcore_release.lib
pcl_people_release.lib
pcl_recognition_release.lib
pcl_registration_release.lib
pcl_sample_consensus_release.lib
pcl_search_release.lib
pcl_segmentation_release.lib
pcl_stereo_release.lib
pcl_surface_release.lib
pcl_tracking_release.lib
pcl_visualization_release.lib
libboost_atomic-vc140-mt-1_64.lib
libboost_chrono-vc140-mt-1_64.lib
libboost_container-vc140-mt-1_64.lib
libboost_context-vc140-mt-1_64.lib
libboost_coroutine-vc140-mt-1_64.lib
libboost_date_time-vc140-mt-1_64.lib
libboost_exception-vc140-mt-1_64.lib
libboost_filesystem-vc140-mt-1_64.lib
libboost_graph-vc140-mt-1_64.lib
libboost_iostreams-vc140-mt-1_64.lib
libboost_locale-vc140-mt-1_64.lib
libboost_log-vc140-mt-1_64.lib
libboost_log_setup-vc140-mt-1_64.lib
libboost_math_c99-vc140-mt-1_64.lib
libboost_math_c99f-vc140-mt-1_64.lib
libboost_math_c99l-vc140-mt-1_64.lib
libboost_math_tr1-vc140-mt-1_64.lib
libboost_math_tr1f-vc140-mt-1_64.lib
libboost_math_tr1l-vc140-mt-1_64.lib
libboost_mpi-vc140-mt-1_64.lib
libboost_prg_exec_monitor-vc140-mt-1_64.lib
libboost_program_options-vc140-mt-1_64.lib
libboost_random-vc140-mt-1_64.lib
libboost_regex-vc140-mt-1_64.lib
libboost_serialization-vc140-mt-1_64.lib
libboost_signals-vc140-mt-1_64.lib
libboost_system-vc140-mt-1_64.lib
libboost_test_exec_monitor-vc140-mt-1_64.lib
libboost_thread-vc140-mt-1_64.lib
libboost_timer-vc140-mt-1_64.lib
libboost_unit_test_framework-vc140-mt-1_64.lib
libboost_wave-vc140-mt-1_64.lib
libboost_wserialization-vc140-mt-1_64.lib
vtkalglib-8.0.lib
vtkChartsCore-8.0.lib
vtkCommonColor-8.0.lib
vtkCommonComputationalGeometry-8.0.lib
vtkCommonCore-8.0.lib
vtkCommonDataModel-8.0.lib
vtkCommonExecutionModel-8.0.lib
vtkCommonMath-8.0.lib
vtkCommonMisc-8.0.lib
vtkCommonSystem-8.0.lib
vtkCommonTransforms-8.0.lib
vtkDICOMParser-8.0.lib
vtkDomainsChemistry-8.0.lib
vtkexoIIc-8.0.lib
vtkexpat-8.0.lib
vtkFiltersAMR-8.0.lib
vtkFiltersCore-8.0.lib
vtkFiltersExtraction-8.0.lib
vtkFiltersFlowPaths-8.0.lib
vtkFiltersGeneral-8.0.lib
vtkFiltersGeneric-8.0.lib
vtkFiltersGeometry-8.0.lib
vtkFiltersHybrid-8.0.lib
vtkFiltersHyperTree-8.0.lib
vtkFiltersImaging-8.0.lib
vtkFiltersModeling-8.0.lib
vtkFiltersParallel-8.0.lib
vtkFiltersParallelImaging-8.0.lib
vtkFiltersPoints-8.0.lib
vtkFiltersProgrammable-8.0.lib
vtkFiltersSelection-8.0.lib
vtkFiltersSMP-8.0.lib
vtkFiltersSources-8.0.lib
vtkFiltersStatistics-8.0.lib
vtkFiltersTexture-8.0.lib
vtkFiltersTopology-8.0.lib
vtkFiltersVerdict-8.0.lib
vtkfreetype-8.0.lib
vtkGeovisCore-8.0.lib
vtkgl2ps-8.0.lib
vtkhdf5-8.0.lib
vtkhdf5_hl-8.0.lib
vtkImagingColor-8.0.lib
vtkImagingCore-8.0.lib
vtkImagingFourier-8.0.lib
vtkImagingGeneral-8.0.lib
vtkImagingHybrid-8.0.lib
vtkImagingMath-8.0.lib
vtkImagingMorphological-8.0.lib
vtkImagingSources-8.0.lib
vtkImagingStatistics-8.0.lib
vtkImagingStencil-8.0.lib
vtkInfovisCore-8.0.lib
vtkInfovisLayout-8.0.lib
vtkInteractionImage-8.0.lib
vtkInteractionStyle-8.0.lib
vtkInteractionWidgets-8.0.lib
vtkIOAMR-8.0.lib
vtkIOCore-8.0.lib
vtkIOEnSight-8.0.lib
vtkIOExodus-8.0.lib
vtkIOExport-8.0.lib
vtkIOExportOpenGL-8.0.lib
vtkIOGeometry-8.0.lib
vtkIOImage-8.0.lib
vtkIOImport-8.0.lib
vtkIOInfovis-8.0.lib
vtkIOLegacy-8.0.lib
vtkIOLSDyna-8.0.lib
vtkIOMINC-8.0.lib
vtkIOMovie-8.0.lib
vtkIONetCDF-8.0.lib
vtkIOParallel-8.0.lib
vtkIOParallelXML-8.0.lib
vtkIOPLY-8.0.lib
vtkIOSQL-8.0.lib
vtkIOTecplotTable-8.0.lib
vtkIOVideo-8.0.lib
vtkIOXML-8.0.lib
vtkIOXMLParser-8.0.lib
vtkjpeg-8.0.lib
vtkjsoncpp-8.0.lib
vtklibharu-8.0.lib
vtklibxml2-8.0.lib
vtklz4-8.0.lib
vtkmetaio-8.0.lib
vtkNetCDF-8.0.lib
vtknetcdf_c++.lib
vtkoggtheora-8.0.lib
vtkParallelCore-8.0.lib
vtkpng-8.0.lib
vtkproj4-8.0.lib
vtkRenderingAnnotation-8.0.lib
vtkRenderingContext2D-8.0.lib
vtkRenderingContextOpenGL-8.0.lib
vtkRenderingCore-8.0.lib
vtkRenderingFreeType-8.0.lib
vtkRenderingGL2PS-8.0.lib
vtkRenderingImage-8.0.lib
vtkRenderingLabel-8.0.lib
vtkRenderingLIC-8.0.lib
vtkRenderingLOD-8.0.lib
vtkRenderingOpenGL-8.0.lib
vtkRenderingVolume-8.0.lib
vtkRenderingVolumeOpenGL-8.0.lib
vtksqlite-8.0.lib
vtksys-8.0.lib
vtktiff-8.0.lib
vtkverdict-8.0.lib
vtkViewsContext2D-8.0.lib
vtkViewsCore-8.0.lib
vtkViewsInfovis-8.0.lib
vtkzlib-8.0.lib
flann.lib
flann_cpp.lib
flann_cpp_s.lib
flann_s.lib
qhullcpp_d.lib
qhullstatic.lib
qhullstatic_r.lib
qhull.lib
qhull_p.lib
qhull_r.lib
OpenNI2.lib
kernel32.lib
user32.lib
gdi32.lib
winspool.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
comdlg32.lib
advapi32.lib
comctl32.lib
wsock32.lib
glu32.lib
opengl32.lib
ws2_32.lib
Psapi.lib
(7)保存属性表
(8)另外的项目使用,直接添加现有属性表即可
注:有时可能会报以下找不到*.dll的错误。
一般将对应的dll文件拷贝到pclText.exe所在目录即可,也可将相应的dll所在目录作为工作目录,减少拷贝量。
$(PCL_ROOT)bin
4.测试PCL
(1)在pclTest.cpp添加以下测试代码
#include "stdafx.h"
#include
#include
#include
#include
#include
#include
#include
using namespace std;
int main(int argc, char** argv)
{
srand((unsigned int)time(NULL));
pcl::PointCloudpcl::PointXYZ>::Ptr cloud(new pcl::PointCloudpcl::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::OctreePointCloudSearchpcl::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);
//半径内近邻搜索
vectorint>pointIdxRadiusSearch;
vectorfloat>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_ptrpcl::visualization::PCLVisualizer>viewer(new pcl::visualization::PCLVisualizer("显示点云"));
viewer->setBackgroundColor(0, 0, 0); //设置背景颜色为黑色
// 对点云着色可视化 (red).
pcl::visualization::PointCloudColorHandlerCustompcl::PointXYZ>target_color(cloud, 255, 0, 0);
viewer->addPointCloudpcl::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);
}
(2)执行结果
参考资料:
[1] _JJW. VS2015配置PCL库(VS2015+PCL1.8.1); 2021-12-29 [accessed 2023-05-14].
[2] 点云侠. Win10 系统下VisualStudio2019 配置点云库 PCL1.11.0; 2022-12-24 [accessed 2023-05-14].
[3] 点云侠. Win10 系统下VisualStudio2019 配置点云库 PCL1.12.0; 2022-12-24 [accessed 2023-05-14].
[4] 点云侠. Win10 系统下VisualStudio2019 配置点云库 PCL1.12.1; 2022-07-22 [accessed 2023-05-14].
[5] 点云侠. Win10 系统下VisualStudio2022 配置点云库 PCL1.13.0; 2023-01-07 [accessed 2023-05-14].
[6] 钢铁男儿. 由于找不动pcl_common_debug.dll,无法继续执行代码; 2020-03-13 [accessed 2023-05-14].
[7] Luo_Xubo. vtk报错“由于找不到**.dll无法继续执行代码“ 解决方案; 2020-11-01 [accessed 2023-05-14].
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
大家好,欢迎来到万猫学社,跟我一起学,你也能成为微服务专家。 软件架构风格 那么到底微服务是个什么东西呢?其实,微服务是一种软件架构风格。那么什么又是软件架构风格呢?可能有的童鞋已经懵圈了。 我们打个比方,好比建造房子,有中式建筑,欧式建筑等。这些不同的建筑风…