用体元滤波器进行降低采样
生活随笔
收集整理的這篇文章主要介紹了
用体元滤波器进行降低采样
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
我們這次用voxel filter(體元濾波器)來濾波
#include <iostream> #include <pcl/io/pcd_io.h> #include <pcl/point_types.h> #include <pcl/filters/voxel_grid.h>int main (int argc, char** argv) {pcl::PCLPointCloud2::Ptr cloud (new pcl::PCLPointCloud2 ());pcl::PCLPointCloud2::Ptr cloud_filtered (new pcl::PCLPointCloud2 ());// Fill in the cloud datapcl::PCDReader reader;// Replace the path below with the path where you saved your filereader.read ("table_scene_lms400.pcd", *cloud); // Remember to download the file first!std::cerr << "PointCloud before filtering: " << cloud->width * cloud->height << " data points (" << pcl::getFieldsList (*cloud) << ").";// Create the filtering objectpcl::VoxelGrid<pcl::PCLPointCloud2> sor;sor.setInputCloud (cloud);sor.setLeafSize (0.01f, 0.01f, 0.01f);sor.filter (*cloud_filtered);std::cerr << "PointCloud after filtering: " << cloud_filtered->width * cloud_filtered->height << " data points (" << pcl::getFieldsList (*cloud_filtered) << ").";pcl::PCDWriter writer;writer.write ("table_scene_lms400_downsampled.pcd", *cloud_filtered, Eigen::Vector4f::Zero (), Eigen::Quaternionf::Identity (), false);return (0); }以下是一些解釋
從磁盤中讀取文件
// Fill in the cloud datapcl::PCDReader reader;// Replace the path below with the path where you saved your filereader.read ("table_scene_lms400.pcd", *cloud); // Remember to download the file first!然后我們用了VoxelGrid這個濾波器,過濾的尺寸為1cm
pcl::VoxelGrid<pcl::PCLPointCloud2> sor;sor.setInputCloud (cloud);sor.setLeafSize (0.01f, 0.01f, 0.01f);sor.filter (*cloud_filtered);最終把數據存到磁盤里面
pcl::PCDWriter writer;writer.write ("table_scene_lms400_downsampled.pcd", *cloud_filtered, Eigen::Vector4f::Zero (), Eigen::Quaternionf::Identity (), false);運行結果,可以看到這把計算量降低到原來的大約十分之一
PointCloud before filtering: 460400 data points (x y z intensity distance sid). PointCloud after filtering: 41049 data points (x y z intensity distance sid).總結
以上是生活随笔為你收集整理的用体元滤波器进行降低采样的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【OpenCV 例程200篇】65. 图
- 下一篇: java盒图_java合成图片