当前位置:   article > 正文

pcl::filter::GaussianKernal_pcl::gaussiankernel

pcl::gaussiankernel
//Create the input and filtered cloud objects
  pcl::PointCloud<pcl::PointXYZ>::Ptr inputcloud (new pcl::PointCloud<pcl::PointXYZ>);
  pcl::PointCloud<pcl::PointXYZ>::Ptr outputcloud (new pcl::PointCloud<pcl::PointXYZ>);



  //Read in the input file
  if (pcl::io::loadPCDFile("SR4500LOG_pt0.pcd", *inputcloud) == -1) //* load the file
    {
      PCL_ERROR ("Couldn't read file test_pcd.pcd \n"); // if couldnt open the file ?
      return (-1);
    }



  //Set up the Gaussian Kernel
  pcl::filters::GaussianKernel<pcl::PointXYZ,pcl::PointXYZ>:: Ptr kernel (new pcl::filters::GaussianKernel<pcl::PointXYZ, pcl::PointXYZ>);
  (*kernel).setSigma(4);
  (*kernel).setThresholdRelativeToSigma(4);
  std::cout << "Kernel made" << std::endl;



  //Set up the KDTree
  pcl::search::KdTree<pcl::PointXYZ>::Ptr kdtree (new pcl::search::KdTree<pcl::PointXYZ>);
  (*kdtree).setInputCloud(inputcloud);
  std::cout << "KdTree made" << std::endl;



  //Set up the Convolution Filter
  pcl::filters::Convolution3D <pcl::PointXYZ, pcl::PointXYZ, pcl::filters::GaussianKernel<pcl::PointXYZ,pcl::PointXYZ> > convolution;
  convolution.setKernel(*kernel);
  convolution.setInputCloud(inputcloud);
  convolution.setSearchMethod(kdtree);
  convolution.setRadiusSearch(100);
  std::cout << "Convolution Start" << std::endl;
  convolution.convolve(*outputcloud);
  std::cout << "Convoluted" << std::endl;



  //write to file
  pcl::io::savePCDFileASCII ("smoothpallet.pcd", *outputcloud);

  std::cout << "Written to File" << std::endl;

转载:http://www.pcl-users.org/3D-Gaussian-Smoothing-td4030953.html



I need help in applying a Gaussian Kernel on my points cloud to smooth the cloud.

I could not figure out how I should write the code and I could not find any plain examples.

Update:

I am using Point Cloud Library (pcl):

  1. pcl::io::loadPCDFile ("/home/..../2240.pcd", *raw_cloud);
  2. Eigen::VectorXf horizontal;
  3. //Set up the Gaussian Kernel
  4. pcl::GaussianKernel<pcl::PointXYZRGB> gaussianKernel;
  5. gaussianKernel.compute(5,horizontal,40);
  6. pcl::filters::Convolution<pcl::PointXYZRGB> conv;
  7. conv.setInputCloud(raw_cloud);
  8. conv.setKernel(horizontal);

This is the code, it is not complete and I am not sure what if the approach is right?

anyone have an idea about this?

 
 
You need to provide the code you tried and explain why it is that it's not doing what you need it to - including providing sample input and output. Refer to stackoverflow.com/help/mcve –  Nathaniel Ford  Jan 28 at 22:04

1 Answer

up vote 0 down vote accepted

I found the right way to make a Gaussian Smoothing via PCL:

  1. pcl::PointCloud<pcl::PointXYZRGB>::Ptr inputCloud,cloud;
  2. pcl::filters::Convolution<pcl::PointXYZRGB, pcl::PointXYZRGB> convolution;
  3. Eigen::ArrayXf gaussian_kernel(5);
  4. gaussian_kernel << 1.f/16, 1.f/4, 3.f/8, 1.f/4, 1.f/16;
  5. convolution.setBordersPolicy(
  6. pcl::filters::Convolution<pcl::PointXYZRGB, pcl::PointXYZRGB>::BORDERS_POLICY_IGNORE);
  7. convolution.setDistanceThreshold (static_cast<float> (0.1));
  8. convolution.setInputCloud (inputCloud);
  9. convolution.setKernel (gaussian_kernel);
  10. convolution.convolve(*cloud);

Hope it would help anyone in his work :)

share improve this answer












































































转载:http://stackoverflow.com/questions/35024359/pcl-gaussian-kernal-example
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号