如何生成vfh特征值pcd文件
2015-08-08 11:17
225 查看
参考代码见http://www.pclcn.org/study/shownews.php?lang=cn&id=95和http://www.pcl-users.org/vfh-problem-td4021827.html和http://pointclouds.org/documentation/tutorials/pfh_estimation.php中的代码进行修改而来
全部代码:pcd_vfh.cpp
可能出现的问题:
全部代码:pcd_vfh.cpp
#include <pcl/point_types.h> #include <pcl/features/vfh.h> #include <pcl/features/normal_3d.h> #include <boost/thread/thread.hpp> #include <pcl/common/common_headers.h> #include <pcl/io/pcd_io.h> #include <pcl/console/parse.h> #include <pcl/visualization/pcl_visualizer.h> #include <pcl/features/vfh.h> int main(int argc, char** argv) { //--Simple cloud creation pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>); //--load pcd from h.d.d pcl::io::loadPCDFile ("E:/test9.pcd", *cloud); cloud->width = (int) cloud->points.size (); cloud->height = 1; // Create the normal estimation class, and pass the input dataset to it pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> ne; ne.setInputCloud (cloud); pcl::search::KdTree<pcl::PointXYZ>::Ptr tree_normal (new pcl::search::KdTree<pcl::PointXYZ> ()); ne.setSearchMethod (tree_normal); pcl::PointCloud<pcl::Normal>::Ptr cloud_normals (new pcl::PointCloud<pcl::Normal>); ne.setRadiusSearch (0.03); ne.compute (*cloud_normals); // Create the VFH estimation class, and pass the input dataset+normals to it pcl::VFHEstimation<pcl::PointXYZ, pcl::Normal, pcl::VFHSignature308> vfh; vfh.setInputCloud (cloud); vfh.setInputNormals (cloud_normals); // alternatively, if cloud is of tpe PointNormal, do vfh.setInputNormals (cloud); // Create an empty kdtree representation, and pass it to the FPFH estimation object. // Its content will be filled inside the object, based on the given input dataset (as no other search surface is given). <span class="n">pcl</span><span class="o">::</span><span class="n">search</span><span class="o">::</span><span class="n">KdTree</span><span class="o"><</span><span class="n">pcl</span><span class="o">::</span><span class="n">PointXYZ</span><span class="o">>::</span><span class="n">Ptr</span> <span class="n">tree</span> <span class="p">(</span><span class="k">new</span> <span class="n">pcl</span><span class="o">::</span><span class="n">search</span><span class="o">::</span><span class="n">KdTree</span><span class="o"><</span><span class="n">pcl</span><span class="o">::</span><span class="n">PointXYZ</span><span class="o">></span> <span class="p">());</span> <span class="c1">//pcl::KdTreeFLANN<pcl::PointXYZ>::Ptr tree (new pcl::KdTreeFLANN<pcl::PointXYZ> ()); -- older call for PCL 1.5-</span> vfh.setSearchMethod(tree_); // Output datasets pcl::PointCloud<pcl::VFHSignature308>::Ptr vfhs (new pcl::PointCloud<pcl::VFHSignature308> ()); // Compute the features vfh.compute (*vfhs); pcl::io::savePCDFileASCII("test_vfh.pcd",*vfhs); return 0; }CmakeLists.txt
cmake_minimum_required(VERSION 2.8 FATAL_ERROR) project(pcd_vfh) find_package(PCL 1.2 REQUIRED) include_directories(${PCL_INCLUDE_DIRS}) link_directories(${PCL_LIBRARY_DIRS}) add_definitions(${PCL_DEFINITIONS}) add_executable (pcd_vfh vfh.cpp) target_link_libraries (pcd_vfh ${PCL_LIBRARIES})
可能出现的问题:
上面代码中pcl::KdTreeFLANN<pcl::PointXYZ>::Ptr tree (new pcl::KdTreeFLANN<pcl::PointXYZ> ());只能在pcl版本在1.5级以上时使用,需将CmakeLists.txt中的PCL版本 号改在1.5及以上即可(在自己安装版本号的范围内)
相关文章推荐
- 理解Linux的硬连接与软连接
- 南邮 OJ 2097 2_A+B(II)
- shell中截取cut所不能做好的字符串的方法
- Java中字符串为什么不以\0结尾
- Python安装.whl包的一系列问题
- LAMP开发环境的搭建
- leetcode 84: Largest Rectangle in Histogram
- 分数相加减的代码(c++)
- Objective-C 基础一:面向对象过程基础知识
- 微信本地调试、ngrok、tunnel
- 站长工具权重评定标准
- Tcl学习之--流程控制|过程
- 2015年北京大学软件工程学科优秀大学生夏令营上机考试---A:整数序列的元素最大跨度值
- Android之——屏幕适配px转dip
- 南邮 OJ 2096 1_A+B(I)
- 剑指offer刷题之java实现的二维数组中的查找
- spring4集成quartz2.2.1(maven)
- POJ 1861 Network (MST)
- office2013 激活码 亲测有效
- HDU 1312 BFS裸题