RANSAC Example Segfaulting

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

RANSAC Example Segfaulting

Ian Douglas Miller
I am working on getting RANSAC working in PCL, and even the example code at http://pointclouds.org/documentation/tutorials/random_sample_consensus.php is segfaulting.  I cam running precompiled PCL 1.8 from the Ubuntu repo on Ubuntu 18.04.  Here is a minimal example:

#include <iostream>
#include <pcl/console/parse.h>
#include <pcl/filters/extract_indices.h>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/sample_consensus/ransac.h>
#include <pcl/sample_consensus/sac_model_plane.h>
#include <pcl/sample_consensus/sac_model_sphere.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <boost/thread/thread.hpp>

int
main(int argc, char** argv)
{
// initialize PointClouds
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);

// populate our PointCloud with points
cloud->width = 500;
cloud->height = 1;
cloud->is_dense = false;
cloud->points.resize (cloud->width * cloud->height);
for (size_t i = 0; i < cloud->points.size (); ++i)
{
cloud->points[i].x = 1024 * rand () / (RAND_MAX + 1.0);
cloud->points[i].y = 1024 * rand () / (RAND_MAX + 1.0);
if( i % 2 == 0)
cloud->points[i].z = 1024 * rand () / (RAND_MAX + 1.0);
else
cloud->points[i].z = -1 * (cloud->points[i].x + cloud->points[i].y);
}

// created RandomSampleConsensus object and compute the appropriated model
pcl::SampleConsensusModelPlane<pcl::PointXYZ>::Ptr
model_p (new pcl::SampleConsensusModelPlane<pcl::PointXYZ> (cloud));
pcl::RandomSampleConsensus<pcl::PointXYZ> ransac (model_p);
ransac.setDistanceThreshold (.01);
ransac.computeModel();
return 0;
}

The backtrace is as follows:

#0  __GI___libc_free (mem=0x31) at malloc.c:3103
#1  0x000055555557a2e7 in Eigen::internal::handmade_aligned_free (
    ptr=0x5555557d6710) at /usr/include/eigen3/Eigen/src/Core/util/Memory.h:98
#2  0x000055555557a343 in Eigen::internal::aligned_free (ptr=0x5555557d6710)
    at /usr/include/eigen3/Eigen/src/Core/util/Memory.h:179
#3  0x000055555557b2d2 in Eigen::internal::conditional_aligned_free<true> (
    ptr=0x5555557d6710) at /usr/include/eigen3/Eigen/src/Core/util/Memory.h:230
#4  0x000055555557db3c in Eigen::internal::conditional_aligned_delete_auto<float, true> (ptr=0x5555557d6710, size=4)
    at /usr/include/eigen3/Eigen/src/Core/util/Memory.h:416
#5  0x000055555557c497 in Eigen::DenseStorage<float, -1, -1, 1, 0>::~DenseStorage (this=0x7fffffffd0e8, __in_chrg=<optimized out>)
    at /usr/include/eigen3/Eigen/src/Core/DenseStorage.h:542
#6  0x000055555557b0d0 in Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 1, 0, -1, 1> >::~PlainObjectBase (this=0x7fffffffd0e8, __in_chrg=<optimized out>)
    at /usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h:98
#7  0x000055555557b0ec in Eigen::Matrix<float, -1, 1, 0, -1, 1>::~Matrix (
    this=0x7fffffffd0e8, __in_chrg=<optimized out>)
    at /usr/include/eigen3/Eigen/src/Core/Matrix.h:178
#8  0x000055555557e6b8 in pcl::SampleConsensus<pcl::PointXYZ>::~SampleConsensus
    (this=0x7fffffffd0a0, __in_chrg=<optimized out>)
    at /usr/include/pcl-1.8/pcl/sample_consensus/sac.h:134
#9  0x0000555555584300 in pcl::RandomSampleConsensus<pcl::PointXYZ>::~RandomSamp---Type <return> to continue, or q <return> to quit---
leConsensus (this=0x7fffffffd0a0, __in_chrg=<optimized out>)
    at /usr/include/pcl-1.8/pcl/sample_consensus/ransac.h:56
#10 0x0000555555579774 in main (argc=1, argv=0x7fffffffdc08)
    at /home/ian/cpp_scripts/pcl_ransac/ransac.cpp:36


The full backtrace is here: https://pastebin.com/cHDXUR3L.

Thank you!



_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users