PointCloudLibrary / pcl

Point Cloud Library (PCL)
https://pointclouds.org/
Other
9.92k stars 4.61k forks source link

Using pcl::registration::CorrespondenceRejectorSampleConsensus gives segmentation fault #2702

Open virgosep18 opened 5 years ago

virgosep18 commented 5 years ago

Hello, I am using pcl::registration::CorrespondenceRejectorSampleConsensus to reject bad correspondences. But, I am getting segmentation fault when using it. Please help. Thanks,

Your Environment

SergioRAgostinho commented 5 years ago

Hi. Just having a segfault doesn't tell much about your problem. Practically all classes in pcl can segfault if not provided with the right input. What have you done so far to debug the problem?

virgosep18 commented 5 years ago

Hi, Thanks for quick reply. Actually below is my transformation estimation function: I did some debugging, and I found that when I am using PCL 1.2 version, I dont see any segfault. However, when I changed version to PCL 1.8 in CmakeList.txt, it gives me segfault. Though, I didn't get any idea yet why is it behaving such? Any suggestion to debug this further?

typedef pcl::PointXYZRGB PointT; typedef pcl::PointCloud PointCloud; typedef pcl::FPFHSignature33 Feature; typedef pcl::PointCloud Features;

void estimateRigidTransform () { // Get all correspondences pcl::registration::CorrespondenceEstimation<Feature, Feature> correspondence_estimator; correspondence_estimator.setInputSource(source_features); correspondence_estimator.setInputTarget(target_features); //correspondence_estimator.determineCorrespondences(correspondences); correspondence_estimator.determineReciprocalCorrespondences(correspondences); std::cout << "Correspondences before rejection: " << correspondences->size() << std::endl;

 // RamdomSampleConsensus bad correspondence rejector
 pcl::registration::CorrespondenceRejectorSampleConsensus<PointT> correspondence_rejector;
 correspondence_rejector.setInputSource(source_keypoints);
 correspondence_rejector.setInputTarget(target_keypoints);
 correspondence_rejector.setInlierThreshold(0.2);
 correspondence_rejector.setMaximumIterations(1000);
 correspondence_rejector.setRefineModel(true);//false
 correspondence_rejector.setInputCorrespondences(correspondences);
 correspondence_rejector.getCorrespondences(*correspondences_filtered);
 std::cout << "Correspondences after rejection: " << correspondences_filtered->size() << std::endl;

 // Estimate final transformation
 transformation_estimator.estimateRigidTransformation(*source_keypoints, *target_keypoints, *correspondences_filtered, transformation_matrix);

}

SergioRAgostinho commented 5 years ago

So this was code that was working before. How did you install pcl? Was it compiled from source? Downloaded from aptitude?

virgosep18 commented 5 years ago

I downloaded PCL v1.8 and compiled it using instructions given on internet somewhere.

virgosep18 commented 5 years ago

Just to add a bit more detail, I am calculating features as per below: void computeFeatures (PointCloud::Ptr cloud, Normals::Ptr normals, PointCloud::Ptr keypoints, Features::Ptr features_out) { // Prepare estimation pcl::FPFHEstimationOMP<PointT, NormalT, Feature> feature_estimator; feature_estimator.setSearchSurface(cloud); feature_estimator.setInputNormals(normals); feature_estimator.setRadiusSearch(0.03); feature_estimator.setInputCloud(keypoints); feature_estimator.setNumberOfThreads(4); // Compute features feature_estimator.compute(*features_out); // Purge features purgeFeatures(features_out, keypoints); }

virgosep18 commented 5 years ago

Can anyone help please?

getsumit123 commented 5 years ago

I am also facing the same issue, Crash in CorrespondenceRejectorSampleConsensus. I am trying to execute example "https://github.com/PointCloudLibrary/pcl/blob/master/doc/tutorials/content/sources/registration_api/example1.cpp" by replacing rejectBadCorrespondences with Ransac based correspondance rejection(CorrespondenceRejectorSampleConsensus). and i get segfault.

Operating System and version: Ubuntu 16.04.5 LTS PCL Version: PCL1.8

Surprisingly same code works on PCLv1.2 to PCLv1.7

Any known reason for this issue ? Or any pointers how to debug this issue.?

hekred commented 5 years ago

hello you can run that line ? correspondence_rejector.setInputCorrespondences(correspondences);

prabinrath commented 5 years ago

Did you find a solution to it??? @virgosep18 @SergioRAgostinho

stale[bot] commented 4 years ago

Marking this as stale due to 30 days of inactivity. It will be closed in 7 days if no further activity occurs.