2013-10-15 64 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