Quantcast

Poisson mesh construction fails in PCL, works in MeshLab

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Poisson mesh construction fails in PCL, works in MeshLab

nblythe
I'm trying to use Poisson mesh reconstruction on the sample point cloud 'CSite1-orig-utm.pcd' from this repo: https://github.com/PointCloudLibrary/data.

I wrote a simple program using PCL to test the process. For reference, the original file looks like this:


First I downsample using a voxel grid, producing this:


Then I smooth, upsample (with RANDOM_UNIFORM_DENSITY), and compute normals using MLS to produce:


So far so good, I think. I can play around with the parameters of the downsampling and smoothing/upsampling to produce more or less smooth clouds with more or less uniform normals. The cloud at this point of processing can be found here: http://www.pastefile.com/download/Gpg2RA

Now, if I use MeshLab to perform Poisson surface reconstruction on this cloud (with octree depth 8, solver divide 8, 10 samples per node) I get this nice cloud/polygons/surface:




But if I use PCL to do the same, I get this cloud (normals not shown):



The snippet I'm using to do the Poisson reconstruction with PCL looks like:
  pcl::PolygonMesh mesh;
  pcl::Poisson<pcl::PointNormal> poisson;
  poisson.setInputCloud(cloudUpsampledNormals);
  poisson.setDepth(8);
  poisson.setSolverDivide(8);
  poisson.setIsoDivide(8);
  poisson.setSamplesPerNode(10);
  poisson.reconstruct(mesh);

I've tried playing with all the other options for the pcl::Poisson, but to no real effect. I always get this "segmented" thing. Thoughts? Any input is appreciated!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Poisson mesh construction fails in PCL, works in MeshLab

tlou
Hi, I may try your cloud later. I have applied Poisson shortly before and it worked fine for me. My code is as below, with less configuration than yours. Have you tried higher depth? I think Poisson tends to close up the surface, so finer subdivision should be better. I have to use 14 for even small scene.

template<class T>
std::pair<typename pcl::PointCloud<T>::Ptr, std::vector<pcl::Vertices> >
trianglulate_mesh_poisson(const typename pcl::PointCloud<T>::ConstPtr &cloud,
                          const int depth)
{
  typename pcl::PointCloud<T>::Ptr vertices(new pcl::PointCloud<T>());
  std::vector<pcl::Vertices> faces;
  typename pcl::Poisson<T> poisson;
  poisson.setDepth(depth);
  poisson.setInputCloud(cloud);
  poisson.setSearchMethod(get_search_kdtree<T>(cloud));
//  poisson.reconstruct(*mesh);
  poisson.reconstruct(*vertices, faces);
  return std::pair<typename pcl::PointCloud<T>::Ptr, std::vector<pcl::Vertices> >(vertices, faces);
}

What is the picture under "But if I use PCL to do the same, I get this cloud (normals not shown):"? If it is the result of MLS, I suggest you also post your code for MLS. Maybe you should not upsample. Mine is like below, but I already have normal, so it is just for filtering

template<class T>
typename pcl::PointCloud<T>::Ptr smooth_mls(const typename pcl::PointCloud<T>::ConstPtr &cloud,
                                            const double radius)
{
  typename pcl::PointCloud<T>::Ptr smoothed(new pcl::PointCloud<T>());
  typename pcl::MovingLeastSquares<T, T> mls;
  mls.setComputeNormals(false);
  mls.setInputCloud(cloud);
  mls.setPolynomialFit(true);
  mls.setSearchMethod(get_search_kdtree<T>(cloud));
  mls.setSearchRadius(radius);
  mls.process(*smoothed);
  return smoothed;
}
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Poisson mesh construction fails in PCL, works in MeshLab

nblythe
tlou wrote
Hi, I may try your cloud later. I have applied Poisson shortly before and it worked fine for me. My code is as below, with less configuration than yours. Have you tried higher depth? I think Poisson tends to close up the surface, so finer subdivision should be better. I have to use 14 for even small scene.
Hi tlou, thanks for the quick reply! Depth 8 works fine in MeshLab, and PCL and MeshLab use the same screened Poisson algorithm, but just to be sure I ran it again with depth 12 - same problem. I also tried using your code (less configuration), and still the same problem. No matter what configuration parameters I use, I PCL gives me that "segmented" looking output.

tlou wrote
What is the picture under "But if I use PCL to do the same, I get this cloud (normals not shown):"? If it is the result of MLS, I suggest you also post your code for MLS.
That picture shows the vertices in the mesh produced by PCL's Poisson implementation, for comparison against the (correct) mesh vertices that MeshLab produces. The MLS is working fine, as far as I can tell. The output after MLS looks right, the normals look correct, and if I import it into MeshLab, it produces the correct mesh using the same Poisson algorithm. The only part that differs is whether I run the Poisson surface reconstruction with PCL or with MeshLab.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Poisson mesh construction fails in PCL, works in MeshLab

nblythe
I've solved the problem. For whatever reason, the demo point clouds from that repository are offset very far away from the origin - approximately 5.4e6 in the y direction! I realized this when I turned on axes in MeshLab and they appeared as a tiny dot in the distance.

While MeshLab can still apply Poisson surface reconstruction regardless of the relative location of the model, PCL doesn't like it. So I added code to translate the point cloud such that the centroid is located at the origin:

  Eigen::Vector4f centroid;
  pcl::compute3DCentroid(*cloudDownsampled, centroid);
  std::cout << centroid << std::endl;

  Eigen::Affine3f transform = Eigen::Affine3f::Identity();
  transform.translation() << -centroid[0], -centroid[1], -centroid[2];

  std::cout << transform.matrix() << std::endl;

  pcl::PointCloud<pcl::PointXYZ>::Ptr cloudTranslated(new pcl::PointCloud<pcl::PointXYZ>());
  pcl::transformPointCloud(*cloudDownsampled, *cloudTranslated, transform);

Then I continue on and upsample/smooth the translated cloud, then run Poisson reconstruction on the result.


Hope this helps somebody else!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Poisson mesh construction fails in PCL, works in MeshLab

nblythe
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Poisson mesh construction fails in PCL, works in MeshLab

tlou
Hi,

I want to try to make a general normalizer for pcl, but when I try Poisson directly on http://www.pastefile.com/download/Gpg2RA, the result looks very good. Did you update the data or is there some fix in recent pcl versions? I use pcl 1.8 built locally(Arch Linux). thanks

tlou

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Poisson mesh construction fails in PCL, works in MeshLab

nblythe
Interesting - can you post the code you're using? I didn't update the data, it still fails for me if I don't translate to the origin. I'm using pcl 1.8 as pre-packaged for Ubuntu.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Poisson mesh construction fails in PCL, works in MeshLab

tlou
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Poisson mesh construction fails in PCL, works in MeshLab

nblythe
Not sure why you're not seeing the same problem. I compiled PCL from trunk and I still see it occurring.
Loading...