请选择 进入手机版 | 继续访问电脑版

点云技术相关产学研社区

 找回密码
 立即注册加入PCL中国点云技术相关产学研社区

扫一扫,访问微社区

查看: 4297|回复: 0

计算spinimage和shape_context特征时出错,求大神帮忙解答

[复制链接]
发表于 2017-12-13 15:31:11 | 显示全部楼层 |阅读模式
这是pcl特征提取的示例代码,对点云提取spin_image特征
#include <iostream>
#include <vector>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/features/normal_3d.h>
#include <pcl/features/spin_image.h>
int
main(int, char** argv)
{
std::string filename = argv[1];
std::string save_file1 = filename.substr(0, filename.find(".pcd")) + "_spinimage.txt";
std::cout << "Reading " << filename << std::endl;
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
if (pcl::io::loadPCDFile <pcl::PointXYZ>(filename.c_str(), *cloud) == -1)

{
  PCL_ERROR("Couldn't read file");
  return (-1);
}
std::cout << "Loaded " << cloud->points.size() << " points." << std::endl;
// 计算法向量
pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> normal_estimation;
normal_estimation.setInputCloud(cloud);
pcl::search::KdTree<pcl::PointXYZ>::Ptr kdtree(new pcl::search::KdTree<pcl::PointXYZ>);
normal_estimation.setSearchMethod(kdtree);
pcl::PointCloud<pcl::Normal>::Ptr normals(new pcl::PointCloud< pcl::Normal>);
normal_estimation.setRadiusSearch(0.35);
normal_estimation.compute(*normals);
// 计算spin_image特征
pcl::SpinImageEstimation<pcl::PointXYZ, pcl::Normal, pcl::Histogram<153> > spin_image_descriptor(8, 0.5, 16);
spin_image_descriptor.setInputCloud(cloud);
spin_image_descriptor.setInputNormals(normals);
// Use the same KdTree from the normal estimation
spin_image_descriptor.setSearchMethod(kdtree);
pcl::PointCloud<pcl::Histogram<153> >::Ptr spin_images(new pcl::PointCloud<pcl::Histogram<153> >);
spin_image_descriptor.setRadiusSearch(0.6);
// Actually compute the spin images
spin_image_descriptor.compute(*spin_images);
std::cout << "SI output points.size (): " << spin_images->points.size() << std::endl;
// 将特征写入txt文件
std::ofstream ofs1;
ofs1.open(save_file1);
for (size_t i = 0; i != spin_images->points.size(); ++i)
{
  size_t size = spin_images->points.descriptorSize();
  for (size_t j = 0; j != size - 1; ++j)
   ofs1 << spin_images->points.histogram[j] << "\t";
  ofs1 << spin_images->points.histogram[size - 1] << "\n";
}
ofs1.close();
std::system("pause");
return 0;
}
运行compute函数报错
Unhandled exception at 0x00007FF81E4D7788 in rift.exe: Microsoft C++ exception: pcl::PCLException at memory location 0x00000069116FEFF0.


回复

使用道具 举报

本版积分规则

QQ|小黑屋|点云技术相关产学研社区 ( 陕ICP备13001629号 )

GMT+8, 2024-3-29 13:21 , Processed in 2.147843 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表