|
网上找的一段高斯滤波程序,运行一直出错,下面是代码和错误信息
#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/common/gaussian.h>
#include <pcl/filters/filter.h>
#include <pcl/filters/convolution.h>
#include <pcl/filters/convolution_3d.h>
int
main (int argc, char** argv)
{
//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("D:\\frame_saver_output\\front\\cloud_front_1_filtered.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(0.05);
std::cout << "Convolution Start" << std::endl;
convolution.convolve(*outputcloud);
std::cout << "Convoluted" << std::endl;
//write to file
pcl::io::savePCDFileASCII ("D:\\frame_saver_output\\front\\cloud_front_1_filtered_GaussianKernel_filters.pcd", *outputcloud);
std::cout << "Written to File" << std::endl;
system ("pause");
return (0);
}
|
|