在PCL中使用直通滤波器对点云进行滤波处理

#include 
#include 
#include 

int
main(int argc, char** argv)
{
	pcl::PointCloud::Ptr cloud(new pcl::PointCloud);
	pcl::PointCloud::Ptr cloud_filtered(new pcl::PointCloud);

	// Fill in the cloud data
	cloud->width = 5;
	cloud->height = 1;
	cloud->points.resize(cloud->width * cloud->height);

	for (size_t i = 0; i < cloud->points.size(); ++i)
	{
		cloud->points[i].x = 1024 * rand() / (RAND_MAX + 1.0f);
		cloud->points[i].y = 1024 * rand() / (RAND_MAX + 1.0f);
		cloud->points[i].z = 1024 * rand() / (RAND_MAX + 1.0f);
	}

	std::cerr << "Cloud before filtering: " << std::endl;
	for (size_t i = 0; i < cloud->points.size(); ++i)
		std::cerr << "    " << cloud->points[i].x << " "
		<< cloud->points[i].y << " "
		<< cloud->points[i].z << std::endl;

	// Create the filtering object
	pcl::PassThrough pass;
	pass.setInputCloud(cloud);
	pass.setFilterFieldName("z");
	pass.setFilterLimits(100.0, 400.0);
	//pass.setFilterLimitsNegative (true);
	//pass.setNegative(true);
	pass.filter(*cloud_filtered);

	std::cerr << "Cloud after filtering: " << std::endl;
	for (size_t i = 0; i < cloud_filtered->points.size(); ++i)
		std::cerr << "    " << cloud_filtered->points[i].x << " "
		<< cloud_filtered->points[i].y << " "
		<< cloud_filtered->points[i].z << std::endl;
	system("pause");
	return (0);
}

template
void pcl::PassThrough< PointT >::setFilterLimitsNegative ( const bool  limit_negative )  
inline

Set to true if we want to return the data outside the interval specified by setFilterLimits (min, max) Default: false.

Warning
This method will be removed in the future. Use  setNegative() instead.
Parameters
[in] limit_negative return data inside the interval (false) or outside (true)

Definition at line 154 of file passthrough.h.


template
void pcl::FilterIndices< PointT >::setNegative ( bool  negative )  
inline

Set whether the regular conditions for points filtering should apply, or the inverted conditions.

Parameters
[in] negative false = normal filter behavior (default), true = inverted behavior.

Definition at line 127 of file filter_indices.h.

Referenced by pcl::people::GroundBasedPeopleDetectionApp< PointT >::compute().


你可能感兴趣的:(PCL学习)