点云技术相关产学研社区

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

扫一扫,访问微社区

查看: 3731|回复: 2

Marching cubes 代码调试问题

[复制链接]
发表于 2014-3-4 17:39:56 | 显示全部楼层 |阅读模式
代码遇到问题,在reconsturct的时候中断 ,请高手帮忙看看是什么原因
#include "stdafx.h"
#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/surface/marching_cubes.h>
#include <pcl/surface/marching_cubes_greedy.h>
#include <pcl/surface/marching_cubes_hoppe.h>
#include <pcl/surface/marching_cubes_rbf.h>
#include <pcl/features/normal_3d.h>
#include <pcl/features/integral_image_normal.h>
#include <pcl/kdtree/kdtree.h>
#include <pcl/kdtree/kdtree_flann.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <boost/thread/thread.hpp>

using namespace std;

int
main (int argc, char** argv)
{
  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);

  if (pcl::io::loadPCDFile<pcl::PointXYZ> ("table_scene_lms400_downsampled.pcd", *cloud) == -1) //* load the file
  {
    PCL_ERROR ("Couldn't read file test_pcd.pcd \n");
    return (-1);
  }

  std::cout<<"PCD load done!"<<endl;
  std::cout<<"pcd size is"<<cloud->size()<<endl;

               double leafSize = 0.01;
               int isoLevel =0.5;//iso: must be between 0 and 1.0

               // Normal estimation*
               pcl::search::Search<pcl::PointXYZ>::Ptr tree = boost::shared_ptr<pcl::search::Search<pcl::PointXYZ> > (new pcl::search::KdTree<pcl::PointXYZ>);
               tree->setInputCloud(cloud);

               pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> n;
               n.setInputCloud(cloud);
               n.setSearchMethod(tree);
               n.setKSearch(20);

               pcl::PointCloud<pcl::Normal>::Ptr normals(new pcl::PointCloud<pcl::Normal>);
               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>);
               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);

               // Init objects
               pcl::PolygonMesh mesh;
              // pcl::MarchingCubesGreedy<pcl::PointNormal> mc;
                           pcl::MarchingCubesHoppe<pcl::PointNormal> mc;        
               // Set parameters
               mc.setInputCloud(cloud_with_normals);
               mc.setSearchMethod(tree2);
              // mc.setLeafSize(leafSize);
                           mc.setPercentageExtendGrid(leafSize);//体素大小
               mc.setIsoLevel(isoLevel);//
              
                           // Reconstruct
                           mc.reconstruct(mesh);
                                   boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer (new pcl::visualization::PCLVisualizer ("3D Viewer"));
                                viewer->addPolygonMesh(mesh,"MC");
                                viewer->setBackgroundColor (0, 0, 0);
                                viewer->addCoordinateSystem (1.0);
                                viewer->initCameraParameters ();
                                // 主循环
                                std::cerr<<"----------------finish--------------------"<<endl;
                                while (!viewer->wasStopped ())
                                {
                                        viewer->spinOnce (100);
                                        boost::this_thread::sleep (boost::posix_time::microseconds (100000));
                                }
                                // Finish
                           return (0);
}
错误截图:


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册加入PCL中国点云技术相关产学研社区

x
回复

使用道具 举报

发表于 2014-3-28 10:17:42 | 显示全部楼层
楼主,问题解决了吗?我也有这个问题了。求交流
回复 支持 反对

使用道具 举报

发表于 2014-5-3 15:14:48 | 显示全部楼层
同问,这个问题解决了吗?
回复 支持 反对

使用道具 举报

本版积分规则

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

GMT+8, 2024-4-29 14:27 , Processed in 1.894501 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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