#include #include #include int main () { 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 (auto& point: *cloud) { point.x = 1024 * rand () / (RAND_MAX + 1.0f); point.y = 1024 * rand () / (RAND_MAX + 1.0f); point.z = 1024 * rand () / (RAND_MAX + 1.0f); } std::cerr << "Cloud before filtering: " << std::endl; for (const auto& point: *cloud) std::cerr << " " << point.x << " " << point.y << " " << point.z << std::endl; // Create the filtering object pcl::PassThrough pass; pass.setInputCloud (cloud); pass.setFilterFieldName ("z"); pass.setFilterLimits (0.0, 1.0); //pass.setFilterLimitsNegative (true); pass.filter (*cloud_filtered); std::cerr << "Cloud after filtering: " << std::endl; for (const auto& point: *cloud_filtered) std::cerr << " " << point.x << " " << point.y << " " << point.z << std::endl; return (0); }