资源简介
本例子是自己捣鼓了两天半才搞定的资源,最后使用Cmake的编译,才最终成功。代码上可能有些是绝对路径,下载的朋友只需要将路径改为自己安装PCL的路径即可,另外,建议初学者在安装PCL的时候不做路径的修改,直接安装到默认的文件夹即可,本人就是因为修改路径,导致多次出错。
代码片段和文件信息
#include
#include
#include
#include
#include
int main(int argc char** argv)
{
srand(time(NULL)); //用系统时间初始化随机种子
pcl::PointCloud::Ptr cloud(new pcl::PointCloud);
// Generate pointcloud data 随机点云生成
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::KdTreeFLANN kdtree; //创建kd-tree
kdtree.setInputCloud(cloud); //设置搜索空间
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);
// K nearest neighbor search k 近邻搜索
int K = 10;
std::vector pointIdxNKNSearch(K);
std::vector pointNKNSquaredDistance(K);
std::cout << “K nearest neighbor search at (“ << searchPoint.x
<< “ “ << searchPoint.y
<< “ “ << searchPoint.z
<< “) with K=“ << K << std::endl;
if (kdtree.nearestKSearch(searchPoint K pointIdxNKNSearch pointNKNSquaredDistance) > 0) //执行k近邻搜索
{
for (size_t i = 0; i < pointIdxNKNSearch.size(); ++i)
std::cout << “ “ << cloud->points[pointIdxNKNSearch[i]].x
<< “ “ << cloud->points[pointIdxNKNSearch[i]].y
<< “ “ << cloud->points[pointIdxNKNSearch[i]].z
<< “ (squared distance: “ << pointNKNSquaredDistance[i] << “)“ << std::endl;
}
// Neighbors within radius search 半径r内近邻搜索方式
std::vector pointIdxRadiusSearch; //存储近邻索引
std::vector pointRadiusSquaredDistance; //存储近邻对应的距离平方
float radius = 256.0f * rand() / (RAND_MAX + 1.0f);
std::cout << “Neighbors within radius search at (“ << searchPoint.x
<< “ “ << searchPoint.y
<< “ “ << searchPoint.z
<< “) with radius=“ << radius << std::endl;
if (kdtree.radiusSearch(searchPoint radius pointIdxRadiusSearch pointRadiusSquaredDistance) > 0)
{
for (size_t i = 0; i < pointIdxRadiusSearch.size(); ++i)
std::cout << “ “ << cloud->points[pointIdxRadiusSearch[i]].x
<< “ “ << cloud->points[pointIdxRadiusSearch[i]].y
<< “ “ << cloud->points[pointIdxRadiusSearch[i]].z
<< “ (squared distance: “ << pointRadiusSquaredDistance[i] << “)“ << std::endl;
}
system(“pause“);
return 0;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-12-02 17:43 Project1\
目录 0 2019-12-02 17:43 Project1\.vs\
目录 0 2019-12-02 17:43 Project1\.vs\Project1\
目录 0 2019-12-02 17:43 Project1\.vs\Project1\v15\
文件 24576 2019-12-02 16:36 Project1\.vs\Project1\v15\.suo
文件 5464064 2019-12-02 16:36 Project1\.vs\Project1\v15\Browse.VC.db
目录 0 2019-12-02 17:43 Project1\.vs\Project1\v15\ipch\
目录 0 2019-12-02 17:43 Project1\.vs\Project1\v15\ipch\AutoPCH\
目录 0 2019-12-02 17:43 Project1\.vs\Project1\v15\ipch\AutoPCH\8e3285934654fb92\
文件 33357824 2019-12-01 21:21 Project1\.vs\Project1\v15\ipch\AutoPCH\8e3285934654fb92\KD_TREE.ipch
目录 0 2019-12-02 17:43 Project1\.vs\Project1\v15\ipch\AutoPCH\e096050e3b828a1\
文件 33947648 2019-12-02 16:36 Project1\.vs\Project1\v15\ipch\AutoPCH\e096050e3b828a1\KD_TREE.ipch
文件 303 2019-12-02 16:35 Project1\CMakeLists
文件 303 2019-12-02 13:30 Project1\CMakeLists.txt
目录 0 2019-12-02 17:43 Project1\cmake_bin\
目录 0 2019-12-02 17:43 Project1\cmake_bin\.vs\
目录 0 2019-12-02 17:43 Project1\cmake_bin\.vs\Kd_tree\
目录 0 2019-12-02 17:43 Project1\cmake_bin\.vs\Kd_tree\v15\
文件 34304 2019-12-02 16:39 Project1\cmake_bin\.vs\Kd_tree\v15\.suo
文件 72372224 2019-12-02 16:34 Project1\cmake_bin\.vs\Kd_tree\v15\Browse.VC.db
文件 58 2019-12-02 16:37 Project1\cmake_bin\.vs\Kd_tree\v15\Browse.VC.opendb
目录 0 2019-12-02 17:43 Project1\cmake_bin\.vs\Kd_tree\v15\ipch\
目录 0 2019-12-02 17:43 Project1\cmake_bin\.vs\Kd_tree\v15\ipch\AutoPCH\
目录 0 2019-12-02 17:43 Project1\cmake_bin\.vs\Kd_tree\v15\ipch\AutoPCH\7f42d19b7186464c\
文件 186646528 2019-12-02 16:38 Project1\cmake_bin\.vs\Kd_tree\v15\ipch\AutoPCH\7f42d19b7186464c\KD_TREE.ipch
文件 790528 2019-12-02 13:38 Project1\cmake_bin\.vs\Kd_tree\v15\Solution.VC.db
文件 32768 2019-12-02 16:37 Project1\cmake_bin\.vs\Kd_tree\v15\Solution.VC.db-shm
文件 12392 2019-12-02 16:37 Project1\cmake_bin\.vs\Kd_tree\v15\Solution.VC.db-wal
文件 60904 2019-12-02 13:32 Project1\cmake_bin\ALL_BUILD.vcxproj
文件 291 2019-12-02 13:32 Project1\cmake_bin\ALL_BUILD.vcxproj.filters
文件 165 2019-12-02 13:34 Project1\cmake_bin\ALL_BUILD.vcxproj.user
............此处省略108个文件信息
相关资源
- 超级场景清理器(SPCleaner)v1.0免费版
- VisualSVN 6.0.4 破解版(支持VS2017)
- Visual Studio 2017企业版 Enterprise,专业版
- VS2017_Professional_15.5.7+密钥
- Microsoft Visual Studio 2017 Installer Project
- httpclient4.3工具类
- 一种机载LiDAR和车载LiDAR点云的自动配
- SfM稀疏三维点云重建--完整工程文件
- 全面的点云库PCL学习教程
- 彩色图片和深度图片生成点云文件
- ICP+NDT点云配准
- CPCL查看器.rar
- log4cxx Windows vs已配置好的工程
- vs2017community
- 1种新的散乱点云快速去噪算法
- Linux ntpclient代码
- 点云库PCL学习教程 完整版
- .las格式点云文件
- VisualStudio 2008-2017系统注释中文包,解
- icp三维点云配准文件
- VS2017+opencv写的火焰检测带检测视频哦
- 中英文PCL5语言参考手册_11086676.zip
- 视频火焰检测vs2017源码
- 地形点云.pcd
- stm32f4+w5500+tcpclient/server源码
- PC-lint 9 + 中文手册
- VS2017环境集成百度语音识别API工程
- openGL实现三维点云显示
- GA+ICP代码
- 建筑物的地面扫描点云数据
评论
共有 条评论