Question

I followed exactly the tutorial I found here, with some modification for the input. Then my code is:

#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;
}

I'm using PCL 1.6, VS2010, all x64.

VS2010 doesn't detect any errors in the code and so I compiled it. But when I execute that, it has a problem:

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

The terminal shows this [pcl::NormalEstimationOMP::compute] input_ is empty!.

The code is executed up to 'mls.process (*cloud_smoothed);' line.

How could I solve it? I'm going crazy to solve it.

Thanks a lot in advance!!

Was it helpful?

Solution

as @Laszlo-Andras Zsurzsa said, I changed parameters, and now it goes on. But now, when it executes and saves file.vtk. I use this setting to get something good

OTHER TIPS

I don't have enough repulation so I use answer as comment for Akash question.

When using Poisson reconstruction, you just care with 2 parameters: deep of octree and number samples per node of octree. In PLC, author of Poisson algorithm set deep of octree is 8 and samples per node is 1.0. You can change deep to 10 to having smoother surface result (more time consume, of course). Author said that you should stop at 10 because more bigger number, more time needed. Samples per node of octree should in between 1.0 to 1.5 so I think it has nothing exited to change.

For question when we should use Poisson algorithm: the answer is when you need to reconstruct a watertight (close) object because Poisson algorithm use indicator function to reconstruct suface so its result is always watertight.

If you want to try other Poisson implementations in past, you can find them in this link

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top