2013-10-15 65 views
0

我完全按照教程找到了here,并对输入进行了一些修改。然后我的代码是:表面重建错误 - PCL 1.6

#include <common/common.h> 
#include <io/pcd_io.h> 
#include <features/normal_3d_omp.h> 
#include <surface/mls.h> 
#include <surface/poisson.h> 
#include <pcl/io/vtk_io.h> 
using namespace pcl; 

int main (int argc, char **argv) 
{ 
    if (argc != 1) 
    { 
     PCL_ERROR ("Syntax: %s input.pcd output.ply\n", argv[0]); 
     return -1; 
    } 

    PointCloud::Ptr cloud (new PointCloud()); 
    io::loadPCDFile ("ism_test_cat.pcd", *cloud); 
    MovingLeastSquares mls; mls.setInputCloud (cloud); 
    mls.setSearchRadius (0.01); 
    mls.setPolynomialFit (true); 
    mls.setPolynomialOrder (2); 
    mls.setUpsamplingMethod (MovingLeastSquares::SAMPLE_LOCAL_PLANE); 
    mls.setUpsamplingRadius (0.005); 
    mls.setUpsamplingStepSize (0.003); 
    PointCloud::Ptr cloud_smoothed (new PointCloud()); 
    mls.process (*cloud_smoothed); 
    NormalEstimationOMP ne; 
    ne.setNumberOfThreads (8); 
    ne.setInputCloud (cloud_smoothed); 
    ne.setRadiusSearch (0.01); 
    Eigen::Vector4f centroid; 
    compute3DCentroid (*cloud_smoothed, centroid); 
    ne.setViewPoint (centroid[0], centroid[1], centroid[2]); 
    PointCloud::Ptr cloud_normals (new PointCloud()); 
    ne.compute (*cloud_normals); 

    for (size_t i = 0; i < cloud_normals->size(); ++i) 
    { 

     cloud_normals->points[i].normal_x *= -1; 
     cloud_normals->points[i].normal_y *= -1; cloud_normals->points[i].normal_z *= -1; 
    } 

    PointCloud::Ptr cloud_smoothed_normals (new PointCloud()); 
    concatenateFields (*cloud_smoothed, *cloud_normals, *cloud_smoothed_normals); 
    Poisson poisson; 
    poisson.setDepth (9); 
    poisson.setInputCloud (cloud_smoothed_normals); 
    PolygonMesh mesh; 
    poisson.reconstruct (mesh); 
    io::saveVTKFile ("sreconstruc.vtk",mesh); 
    return 0; 
} 

我使用PCL 1.6,VS2010,所有x64。

VS2010不检测代码中的任何错误,所以我编译它。但是当我执行它时,它有一个问题:

'Unhandled exception at 0x000007fee833546b (pcl_kdtree_debug.dll) in pcl_surface-reconstrucTutorial.exe: 0xC0000005: Access violation reading location 0x0000000000000000.' 

终端显示[pcl::NormalEstimationOMP::compute] input_ is empty!

代码执行到'mls.process(* cloud_smoothed);'线。

我该如何解决?我疯了解决它。

非常感谢!

+0

我用作输入的文件[这里](https://github.com/PointCloudLibrary/data/blob/ master/tutorials/ism_test_cat.pcd) – SPS

+0

您使用教程中给出的默认值吗?也是同一个文件?可能会发生,如果你使用其他文件,你需要调整一些值,然后得到结果。 (正常估计输入不会为空) – alap

+0

您确定您确实正在阅读点云文件吗?请尝试使用完整路径(不仅仅是'name.pcd'),因为当loadPCDFile尝试查找文件时,该文件不存在于该路径中时,您不会收到异常,并且程序会继续执行。 –

回答

0

@ Laszlo-Andras Zsurzsa说,我改变了参数,现在它继续。但是现在,它执行并保存file.vtk。我使用this设置得到好的东西

0

我没有足够的表达,所以我使用答案作为评论Akash问题。

当使用泊松重构时,您只需关心2个参数:八叉树深度和八叉树每个节点的数量采样。在PLC中,八叉树深度为8的泊松算法集作者,每个节点采样为1.0。您可以将深度更改为10以获得更平滑的表面效果(当然,更多的时间消耗)。作者说,你应该停止在10,因为更大的数量,更多的时间需要。每个八叉树节点的采样应该在1.0到1.5之间,所以我认为它没有什么可以改变的。

对于什么时候应该使用泊松算法的问题:答案是当您需要重建一个水密(关闭)对象时,因为泊松算法使用指示函数重建表面,所以其结果始终是水密的。

如果您想尝试在过去的其他泊松实现,你可以找到他们在这个link