Filtering Point Clouds with a Passthrough Filter¶
This tutorial demonstrates how to execute passthrough filtering.
Note
This tutorial is applicable for execution for both within inside and outside a Docker* image. It assumes that the pcl-oneapi-tutorials Deb package is installed, and the user has copied the tutorial directory from /opt/intel/pcl/oneapi/tutorials/ to a user-writable directory.
Prepare the environment:
oneapi_passthrough.cpp
should be in the directory with following content:1#include <pcl/oneapi/filters/passthrough.h> 2#include <pcl/io/pcd_io.h> 3#include <pcl/point_types.h> 4#include <pcl/point_cloud.h> 5 6 7int main (int argc, char** argv) 8{ 9 10 std::cout << "Running on device: " << dpct::get_default_queue().get_device().get_info<sycl::info::device::name>() << "\n"; 11 12 // Read Point Cloud 13 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_( new pcl::PointCloud<pcl::PointXYZ>() ); 14 int result = pcl::io::loadPCDFile("using_kinfu_large_scale_output.pcd", *cloud_); 15 if (result != 0) 16 { 17 pcl::console::print_info ("Load pcd file failed.\n"); 18 return result; 19 } 20 21 // Prepare Point Cloud Memory (output) 22 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_filtered_( new pcl::PointCloud<pcl::PointXYZ>() ); 23 24 // GPU calculate 25 pcl::oneapi::PassThrough<pcl::PointXYZ> ps; 26 ps.setInputCloud(cloud_); 27 ps.setFilterFieldName ("z"); 28 ps.setFilterLimits (0.0, 1.0); 29 ps.filter(*cloud_filtered_); 30 31 // print log 32 std::cout << "[oneapi passthrough] PointCloud before filtering: " << cloud_->size() << std::endl; 33 std::cout << "[oneapi passthrough] PointCloud after filtering: " << cloud_filtered_->size() << std::endl; 34}
Source the Intel® oneAPI Base Toolkit environment:
(Optional) Setup proxy setting to download test data:
Build the code:
Run the binary:
Expected results example:
Code Explanation¶
Load the example PCD into a PointCloud<PointXYZ>.
Prepare output buffer for filtered result.
Starts to compute the result.
Result (output log):