pcl::filter::GaussianKernal

来源:互联网 发布:共享文件夹加密软件 编辑:程序博客网 时间:2024/05/29 02:25
//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



PCL Gaussian Kernal example

up vote1down votefavorite

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):

pcl::io::loadPCDFile ("/home/..../2240.pcd", *raw_cloud);Eigen::VectorXf horizontal;//Set up the Gaussian Kernelpcl::GaussianKernel<pcl::PointXYZRGB> gaussianKernel;gaussianKernel.compute(5,horizontal,40);pcl::filters::Convolution<pcl::PointXYZRGB> conv;conv.setInputCloud(raw_cloud);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?

shareimprove this question
 
 
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

activeoldestvotes
up vote0down voteaccepted

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

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

Hope it would help anyone in his work :)

shareimprove this answer












































































转载:http://stackoverflow.com/questions/35024359/pcl-gaussian-kernal-example
0 0
原创粉丝点击