Ask Your Question
1

Unable to combine MLS and mesh generation in one file

asked 2014-07-20 11:10:48 -0600

updated 2014-07-20 11:13:08 -0600

Hi,

I am able to do MLS and then also generate mesh, but I need to do both of them separately. I am not able to find a way to do it in one go. First I do MLS and save the file. And then read that file again and generate mesh.

If I combine both I am encountering segmentation fault. The code does MLS successfully but than fails. The two tutorials which I tried to combine are:

Greedy projection : http://pointclouds.org/documentation/...

and

MLS : http://pointclouds.org/documentation/...

Also since MLS itself compute the surface normal so I commented the part of the code where normal are generated.

Any help of pointers is greatly appreciated.

Let me know if I ask PCL related questions somewhere else?

My combined code is:





int
main (int argc, char** argv)
{
  ros::init(argc, argv, "seg"); //is the third param node name
  ros::NodeHandle nh;
  int p_setKSearch = 20;
  double p_setSearchRadius = 0.025;
  double p_setMu = 2.5;

  double p_neighbours = 100;
  double p_maxSurfAnglePiDiv = 4; // 45 degrees
  double p_minAnglePiDiv =18; // 10 degrees

  double p_maxAnglePiDiv = 1.5; // 120 degrees
  bool p_normal_consist = false;
  std::string p_pcd_file = "/home/aknirala/chair.pcd";

  double lDv;   //Loaded double value
  int lIv;
  bool lBv;
  std::string lSv;

  std::cout<<"\n Getting the parameters...............";
  if(nh.getParam("/mesh/meshParam/p_setKSearch", lIv))          p_setKSearch = lIv;
  if(nh.getParam("/mesh/meshParam/p_setSearchRadius", lDv))     p_setSearchRadius = lDv;
  if(nh.getParam("/mesh/meshParam/p_setMu", lDv))               p_setMu = lDv;

  if(nh.getParam("/mesh/meshParam/p_neighbours", lDv))          p_neighbours = lDv;
  if(nh.getParam("/mesh/meshParam/p_maxSurfAnglePiDiv", lDv))   p_maxSurfAnglePiDiv = lDv;
  if(nh.getParam("/mesh/meshParam/p_minAnglePiDiv", lDv))       p_minAnglePiDiv = lDv;

  if(nh.getParam("/mesh/meshParam/p_maxAnglePiDiv", lDv))       p_maxAnglePiDiv = lDv;
  if(nh.getParam("/mesh/meshParam/p_normal_consist", lBv))      p_normal_consist = lBv;
  if(nh.getParam("/mesh/sourceFile", lSv))      p_pcd_file = lSv;

  std::cout<<"\n p_setKSearch : "<<p_setKSearch;
  std::cout<<"\n p_setSearchRadius : "<<p_setSearchRadius;
  std::cout<<"\n p_setMu : "<<p_setMu;

  std::cout<<"\n p_neighbours : "<<p_neighbours;
  std::cout<<"\n p_maxSurfAnglePiDiv : "<<p_maxSurfAnglePiDiv;
  std::cout<<"\n p_minAnglePiDiv : "<<p_minAnglePiDiv;

  std::cout<<"\n p_maxAnglePiDiv : "<<p_maxAnglePiDiv;
  std::cout<<"\n p_normal_consist : "<<p_normal_consist;
  std::cout<<"\n p_pcd_file : "<<p_pcd_file;

  // Load input file into a PointCloud<T> with an appropriate type
  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
  pcl::PCLPointCloud2 cloud_blob;
  pcl::io::loadPCDFile (p_pcd_file, cloud_blob);
  pcl::fromPCLPointCloud2 (cloud_blob, *cloud);     //What exactly is being converted here?
                                                     //cloud_blob may not be of type XYZ :-)
  //* the data should be available in cloud
  //Convert a PCLPointCloud2 binary data blob ---> into a pcl::PointCloud<T> object
  //Oh, so this is one of the way to load any point cloud type from a pcd file, which we do not
  // know before reading the file to desired point type. IN this case, to PointXYZ.






  /*
  // 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 (cloud);
  n.setInputCloud (cloud);
  n.setSearchMethod (tree);
  n.setKSearch (p_setKSearch);      //It was 20
  n.compute (*normals);             //Normals are estimated using standard method.
  //* normals should not contain the point ...
(more)
edit retag flag offensive close merge delete

Comments

Just to know...exactly on which line, are you encountering the segmentation fault ?

sai gravatar imagesai ( 2014-07-20 21:53:20 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-07-20 15:25:44 -0600

ahendrix gravatar image

PCL has a mailing list that is probably more appropriate for this type of question: http://www.pcl-users.org/

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-07-20 11:10:48 -0600

Seen: 256 times

Last updated: Jul 20 '14