如何生成vfh特征值pcd文件

该博客介绍了如何通过参考特定代码和教程来生成VHF特征值的PCD文件,提供了相关链接和一个名为'pcd_vfh.cpp'的完整代码示例,同时提及了可能遇到的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

       参考代码见http://www.pclcn.org/study/shownews.php?lang=cn&id=95http://www.pcl-users.org/vfh-problem-td4021827.htmlhttp://pointclouds.org/documentation/tutorials/pfh_estimation.php中的代码进行修改而来

全部代码: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及以上即可(在自己安装版本号的范围内)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值