PointCloudLibrary / PointCloudLibrary/pcl

pcl::MeshQuadricDecimationVTK seg fault

Open
#967 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: stale
Dominant language
C++
Stars
11.1k
Forks
4.7k
Avg merge
4d 10h
Merged PRs (30d)
6

Description

Oi,

I am running a continuous loop that get the latest point-cloud from a laser sensor and transform it into a mesh.
The Point-cloud( input data) is very similar in each loop.
I am using the pcl::MeshQuadricDecimationVTK to decimate most of the mesh.
The code works for a few loops, behaving exactly like expected, but after what appears to be a random number of iterations it seg-faults with the following ( from gbd):

Program received signal SIGSEGV, Segmentation fault.

[Switching to Thread 0x7fffa6ffd700 (LWP 2502)]
0x00007fffde6006f9 in vtkQuadricDecimation::CollapseEdge(long long, long long) () from /usr/lib/libvtkGraphics.so.5.8
(gdb) bt
#0  0x00007fffde6006f9 in vtkQuadricDecimation::CollapseEdge(long long, long long) ()
   from /usr/lib/libvtkGraphics.so.5.8
#1  0x00007fffde602927 in vtkQuadricDecimation::RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) () from /usr/lib/libvtkGraphics.so.5.8
#2  0x00007fffe0973204 in vtkExecutive::CallAlgorithm(vtkInformation*, int, vtkInformationVector**, vtkInformationVector*) () from /usr/lib/libvtkFiltering.so.5.8
#3  0x00007fffe096775c in vtkDemandDrivenPipeline::ExecuteData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) () from /usr/lib/libvtkFiltering.so.5.8
#4  0x00007fffe096a79d in vtkDemandDrivenPipeline::ProcessRequest(vtkInformation*, vtkInformationVector**, vtkInformationVector*) () from /usr/lib/libvtkFiltering.so.5.8
#5  0x00007fffe0aa6cac in vtkStreamingDemandDrivenPipeline::ProcessRequest(vtkInformation*, vtkInformationVector**, vtkInformationVector*) () from /usr/lib/libvtkFiltering.so.5.8
#6  0x00007fffe09692a7 in vtkDemandDrivenPipeline::UpdateData(int) () from /usr/lib/libvtkFiltering.so.5.8
#7  0x00007fffe0aa8485 in vtkStreamingDemandDrivenPipeline::Update(int) () from /usr/lib/libvtkFiltering.so.5.8
#8  0x00007fffe586af1d in pcl::MeshQuadricDecimationVTK::performProcessing(pcl::PolygonMesh&) ()
   from /usr/lib/libpcl_surface.so.1.7
#9  0x00007fffe5717986 in pcl::MeshProcessing::process(pcl::PolygonMesh&) () from /usr/lib/libpcl_surface.so.1.7
#10 0x00007fffee194a88 in TrajOpt::AtlasTraj::PrepPointCloud(boost::shared_ptr<pcl::PointCloud<pcl::PointXYZRGB> >, Eigen::Transform<double, 3, 2, 0>) () from /home/fpolido/drc_workspace/src/trajopt/build_trajopt/lib/libatlas_traj.so
#11 0x000000000040ec07 in ConvexDecompLoop() ()
#12 0x00007ffff7020ce9 in thread_proxy () from /usr/lib/libboost_thread.so.1.46.1
#13 0x00007ffff6dfee9a in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#14 0x00007fffed6f331d in clone () from /lib/x86_64-linux-gnu/libc.so.6
#15 0x0000000000000000 in ?? ()

The specific lines in my code are =

pcl::PolygonMesh::Ptr simpleMesh(new pcl::PolygonMesh()); 
pcl::MeshQuadricDecimationVTK mesh_decimator; 
mesh_decimator.setInputMesh(triangles); 
mesh_decimator.setTargetReductionFactor(1 - 0.1); 
mesh_decimator.process(*simpleMesh); 

For reference, the mesh generation from Point-Cloud is:

// Normal estimation*
pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> n;
pcl::PointCloud<pcl::Normal>::Ptr normals (new pcl::PointCloud<pcl::Normal>);
pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ>);
tree->setInputCloud (temp);
n.setInputCloud (temp);
n.setSearchMethod (tree);
n.setKSearch (20);
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>);
pcl::concatenateFields (*temp, *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);

// Initialize objects
pcl::GreedyProjectionTriangulation<pcl::PointNormal> gp3;
//pcl::PolygonMesh triangles;
pcl::PolygonMesh::Ptr triangles(new pcl::PolygonMesh());

// Set the maximum distance between connected points (maximum edge length)
//Very importan in setting the size of blocks:
gp3.setSearchRadius (0.15); //0.025

// Set typical values for the parameters
gp3.setMu (250);//2.5
gp3.setMaximumNearestNeighbors (100);
gp3.setMaximumSurfaceAngle(M_PI/4); // 45 degrees
gp3.setMinimumAngle(M_PI/18); // 10 degrees
gp3.setMaximumAngle(2*M_PI/3); // 120 degrees
gp3.setNormalConsistency(false);

// Get result
gp3.setInputCloud (cloud_with_normals);
gp3.setSearchMethod (tree2);
gp3.reconstruct (*triangles);

The computer is concurrently running a simulator, which hogs a lot of the memory. I am guessing this is an internal memory-leak. I wasn't able to find any similar bugs on the Issue Tracker

Any ideas? And is there any alternative options for the same functionality as MeshQuadricDecimationVTK?

Thanks in advance!

Felipe

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the MeshQuadricDecimationVTK::process call and the VTK CollapseEdge backtrace, then inspect the repeated loop that builds triangles with GreedyProjectionTriangulation. Reproduce the crash across iterations under the simulator's memory load and compare mesh inputs; done means documenting a reproducible cause and a verified fix or supported alternative.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-vision
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.