Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The calculation results of the two versions PCL are inconsistent (PCL1.11.1 and PCL1.13.1) #5760

Closed
lzcchl opened this issue Jul 7, 2023 · 2 comments

Comments

@lzcchl
Copy link

lzcchl commented Jul 7, 2023

Hi, There is a code with two results when using two PCL versions, please, is that something change?

  • OS: WIN11
  • Compiler: VS2019 and VS2022
  • PCL Version: 1.11.1 and 1.13.1
  • Environment: VS2019+PCL1.11.1 and VS2022+PCL1.13.1

code
#include

#include <Eigen/Core>

#include <opencv2/opencv.hpp>

#include <pcl/common/angles.h>
#include <pcl/common/impl/pca.hpp>
#include <pcl/common/common.h> // for getMinMax3D()
#include <pcl/common/eigen.h>
#include <pcl/common/centroid.h>
#include <pcl/common/geometry.h>
#include <pcl/point_types.h>
#include <pcl/point_cloud.h>
#include <pcl/io/ply_io.h>
#include <pcl/io/obj_io.h>
#include <pcl/segmentation/sac_segmentation.h> //基于采样一致性分割的类的头文件

int main()
{
using namespace std;
using namespace cv;
cout << "begin" << endl;

string obj_path = R"(E:\luozc\code\cpp\ovi\sstree\spine_fwsy\build\save\cylinder\AARJ33D0003_20230627150639940_99\cloudRgbPtr.ply)";
using T = pcl::PointXYZ;
pcl::PointCloud<T>::Ptr ptcld(new pcl::PointCloud<T>);
pcl::io::loadPLYFile(obj_path, *ptcld);

double dis = 4.0;
Eigen::Vector4f coeff_plane;

pcl::PointIndices::Ptr planeInd(new pcl::PointIndices);
pcl::ModelCoefficients::Ptr coefficients(new pcl::ModelCoefficients);
pcl::SACSegmentation<T> seg;
// Optional
seg.setOptimizeCoefficients(true);
// Mandatory
seg.setModelType(pcl::SACMODEL_PLANE);
seg.setMethodType(pcl::SAC_RANSAC);//pcl::SAC_RANSAC//pcl::LMedS
seg.setDistanceThreshold(dis);

seg.setInputCloud(ptcld);
seg.segment(*planeInd, *coefficients);
coeff_plane = { coefficients->values[0],coefficients->values[1],coefficients->values[2],coefficients->values[3] };
cout << coeff_plane << endl;

system("pause");
return 0;

}

this is the data.
cloudRgbPtr.zip

@lzcchl lzcchl added kind: bug Type of issue status: triage Labels incomplete labels Jul 7, 2023
@mvieth
Copy link
Member

mvieth commented Jul 9, 2023

@lzcchl It is possible that you get different results because something in PCL changed. It is also possible that you get different results because you used different compiler versions (VS2019 or VS2022).
What are the plane coefficients that are printed in each case? Are both a good fit for the plane in your point cloud?
Can you perhaps test with more PCL versions (PCL 1.12.0, PCL 1.12.1, PCL 1.13.0) and check with which PCL version the results changed?

@mvieth
Copy link
Member

mvieth commented Jul 17, 2023

@lzcchl I investigated, pull request #4983 changed the result.
With PCL 1.11.1, I get these results:

0.00519627
  0.034637
  0.999386
  -671.016
330246 inliers

With PCL 1.13.1, I get these results:

0.00373465
 0.0342436
  0.999407
  -670.425
334283 inliers

Looking at the number of inliers, the results with PCL 1.13.1 are better. With PCL 1.11.1, the covariance matrix computation while refining/optimizing the plane coefficients was inaccurate because the points in your cloud are quite far away from the origin. This was fixed in the pull request I linked above. So use PCL 1.13.1, the results are more precise.

@mvieth mvieth closed this as completed Jul 17, 2023
@mvieth mvieth added kind: question Type of issue module: segmentation and removed kind: bug Type of issue status: triage Labels incomplete labels Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants