我正在尝试使用法线估计来找到云中点的法线,以便将其传递给FPFH关键点检测器。这是我的代码:-
#include <pcl/io/pcd_io.h>
#include <pcl/features/normal_3d.h>
#include <pcl/features/fpfh.h>
int
main(int argc, char** argv)
{
// Object for storing the point cloud.
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
// Object for storing the normals.
pcl::PointCloud<pcl::Normal>::Ptr normals(new pcl::PointCloud<pcl::Normal>);
// Object for storing the FPFH descriptors for each point.
pcl::PointCloud<pcl::FPFHSignature33>::Ptr descriptors(new pcl::PointCloud<pcl::FPFHSignature33>());
// Read a PCD file from disk.
if (pcl::io::loadPCDFile<pcl::PointXYZ> ("/home/ashwin/pcl/test/table_scene_mug_stereo_textured.pcd", *cloud) == -1)
{
PCL_ERROR ("Couldn't read file p1.pcd \n");
return (-1);
}
std::cout << "Loaded " << cloud->width <<"x"<< cloud->height <<"="<< cloud->width*cloud->height << std::endl;
// Estimate the normals.
pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> normalEstimation;
normalEstimation.setInputCloud(cloud);
normalEstimation.setRadiusSearch(15);
pcl::search::KdTree<pcl::PointXYZ>::Ptr kdtree(new pcl::search::KdTree<pcl::PointXYZ>);
normalEstimation.setSearchMethod(kdtree);
normalEstimation.compute(*normals);
std::cout<< "Normal size: " << normals->size() << std::endl;
}
我得到以下输出:-
已加载640x480 = 307200[pcl :: KdTreeFLANN :: setInputCloud]无法使用空的输入云创建KDTree!正常大小:0
您可以看到输入云具有307200点。我无法理解为什么会收到“空输入云”错误?
这是我的CMakerLists.txt:-
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(registration_api)
find_package(PCL 1.8 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable (fpfh_descriptor_trial fpfh_descriptor_trial.cpp)
target_link_libraries (fpfh_descriptor_trial ${PCL_LIBRARIES})
我找不到导致此问题的原因,但是我通过将代码传输到另一个文件夹来运行代码。我仍然想知道它如何解决我的问题,但是确实可以。