点云技术相关产学研社区

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

扫一扫,访问微社区

查看: 3850|回复: 1

PCL实例greedy-projection-triangulation

[复制链接]
发表于 2016-5-11 17:29:43 | 显示全部楼层 |阅读模式
运行PCL文件包里的greedy-projection实例时,报错:Debug error:R6010,abort() has been called.
看了好多别人的博客,大概是说内存越界或超出范围,我单步调试时发现内存很乱,基本上没有数值,想知道这是怎么回事???
代码(PCL文件夹中给出的):
#include <pcl/point_types.h>
#include <pcl/io/pcd_io.h>
#include <pcl/kdtree/kdtree_flann.h>
#include <pcl/features/normal_3d.h>
#include <pcl/surface/gp3.h>

int
main (int argc, char** argv)
{
  // Load input file into a PointCloud<T> with an appropriate type
  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
  sensor_msgs::PointCloud2 cloud_blob;
  pcl::io::loadPCDFile ("bun0.pcd", cloud_blob);
  pcl::fromROSMsg (cloud_blob, *cloud);
  //* the data should be available in cloud

  // Normal estimation*
  pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> n;
  pcl::PointCloud<pcl::Normal>::Ptr normals (new pcl::PointCloud<pcl::Normal>);
  pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ>);
  tree->setInputCloud (cloud);
  n.setInputCloud (cloud);
  n.setSearchMethod (tree);
  n.setKSearch (20);
  n.compute (*normals);
  //* normals should not contain the point normals + surface curvatures

  // Concatenate the XYZ and normal fields*
  pcl::PointCloud<pcl::PointNormal>::Ptr cloud_with_normals (new pcl::PointCloud<pcl::PointNormal>);
  pcl::concatenateFields (*cloud, *normals, *cloud_with_normals);
  //* cloud_with_normals = cloud + normals

  // Create search tree*
  pcl::search::KdTree<pcl::PointNormal>::Ptr tree2 (new pcl::search::KdTree<pcl::PointNormal>);
  tree2->setInputCloud (cloud_with_normals);

  // Initialize objects
  pcl::GreedyProjectionTriangulation<pcl::PointNormal> gp3;
  pcl::PolygonMesh triangles;

  // Set the maximum distance between connected points (maximum edge length)
  gp3.setSearchRadius (0.025);

  // Set typical values for the parameters
  gp3.setMu (2.5);
  gp3.setMaximumNearestNeighbors (100);
  gp3.setMaximumSurfaceAngle(M_PI/4); // 45 degrees
  gp3.setMinimumAngle(M_PI/18); // 10 degrees
  gp3.setMaximumAngle(2*M_PI/3); // 120 degrees
  gp3.setNormalConsistency(false);

  // Get result
  gp3.setInputCloud (cloud_with_normals);
  gp3.setSearchMethod (tree2);
  gp3.reconstruct (triangles);

  // Additional vertex information
  std::vector<int> parts = gp3.getPartIDs();
  std::vector<int> states = gp3.getPointStates();

  // Finish
  return (0);
}

[img]file:///C:\Users\Administrator\AppData\Roaming\Tencent\Users\1272142403\QQ\WinTemp\RichOle\Z~~YA~]HPQ4~FNESORT@DYT.png[/img]
[img]file:///C:\Users\Administrator\AppData\Roaming\Tencent\Users\1272142403\QQ\WinTemp\RichOle\Z~~YA~]HPQ4~FNESORT@DYT.png[/img]
回复

使用道具 举报

 楼主| 发表于 2016-5-11 17:31:30 | 显示全部楼层
用的pcd文件是自己得到的:
# .PCD v.7 - Point Cloud Data file format
VERSION .7
FIELDS x y z
SIZE 32 32 32
TYPE F F F
COUNT 1 1 1
WIDTH 55061
HEIGHT 1
VIEWPOINT 0 0 0 1 0 0 0
POINTS 55061
DATA ascii
165.910849 111.848930 855.473457
232.670594 148.455302 1272.738956
232.670594 148.455302 1272.738956
回复 支持 反对

使用道具 举报

本版积分规则

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

GMT+8, 2024-5-14 12:21 , Processed in 1.082035 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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