pcl::filter::GaussianKernal

11 篇文章 2 订阅
//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):

pcl::io::loadPCDFile ("/home/..../2240.pcd", *raw_cloud);
Eigen::VectorXf horizontal;
//Set up the Gaussian Kernel
pcl::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?

share improve 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

up vote 0 down vote accepted

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

share improve this answer












































































转载:http://stackoverflow.com/questions/35024359/pcl-gaussian-kernal-example
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值