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);
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?
gaussian convolution point-cloud-library kernel-density
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
add a comment
1 Answer
activeoldestvotes
up vote0down vote
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 :)
转载:http://stackoverflow.com/questions/35024359/pcl-gaussian-kernal-example
0 0
- pcl::filter::GaussianKernal
- pcl-filter-passthrough
- PCL学习笔记三:filter
- PCL:使用VoxelGrid filter对点云进行下采样
- PCL:使用StatisticalOutlierRemoval filter移除点云异常值
- PCL 学习笔记之一 Filtering a PointCloud using a PassThrough filter
- ROS PCL 点云处理学习之二 Downsampling a PointCloud using a VoxelGrid filter
- PCL--pcl::copyPointCloud 使用方法
- PCL学习
- PCL registration
- PCL学习
- PCL配置
- QT + PCL
- PCL入门
- pcl install
- PCL配置
- PCL输入输出
- Pcl配置
- Hackerrank Fibonacci Numbers Tree
- 使用Node.js+socket.io制作服务端,unity+socket.io for unity 制作客户端 ,验证位置同步Demo
- yield
- 对象类型转换为数组类型实例
- easy UI异步树的动态加载treegrid(实践记录)
- pcl::filter::GaussianKernal
- bootstrap Popover弹出框插件
- 致我们即将迎来的考试周
- java调用外部接口
- 《编写高质量代码改善C++程序的150个建议》摘录
- JavaScript Dom编程艺术学习笔记(第3章)
- php发送邮件email
- Mac配置环境变量
- shell多线程写法