做网站的公司哪家有名,做最好的网站,企业的vi设计系统,wordpress 充值系统pcl滤波器
pcl一共是有十二个主要模块#xff0c;详细了解可以查看官网。https://pcl.readthedocs.io/projects/tutorials/en/latest/#basic-usage
今天学习一下pcl的滤波器模块。
滤波器模块#xff0c;官网一共是提供了6个例程#xff0c;今天先来看第一第二个。
直通…
pcl滤波器
pcl一共是有十二个主要模块详细了解可以查看官网。https://pcl.readthedocs.io/projects/tutorials/en/latest/#basic-usage
今天学习一下pcl的滤波器模块。
滤波器模块官网一共是提供了6个例程今天先来看第一第二个。
直通滤波器
主要使用的API是 passthrough
#include iostream
#include pcl/point_types.h
#include pcl/filters/passthrough.hint
main()
{pcl::PointCloudpcl::PointXYZ::Ptr cloud(new pcl::PointCloudpcl::PointXYZ);pcl::PointCloudpcl::PointXYZ::Ptr cloud_filtered(new pcl::PointCloudpcl::PointXYZ);// Fill in the cloud datacloud-width 50; //点数量cloud-height 1; cloud-points.resize(cloud-width * cloud-height);//遍历点赋值值为0-1024之间的随机浮点值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 objectpcl::PassThroughpcl::PointXYZ pass;pass.setInputCloud(cloud);pass.setFilterFieldName(z); //设置z为过滤因子pass.setFilterLimits(0.0, 200.0); //只通过z轴值为0-200之间的点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;system(pause);return (0);
}CMakeLists.txt
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)project(passthrough)find_package(PCL 1.2 REQUIRED)include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})add_executable (passthrough passthrough.cpp)
target_link_libraries (passthrough ${PCL_LIBRARIES})体素滤波器降采样
即使用体素化网格方法减少一个点云数据集中点的数量。
VoxelGrid 类在输入点云数据上创建一个3D体素网格(将体素网格想象为空间中的一组微小的3D盒子)。然后在每个体素(即3D框)中所有存在的点都将用它们的质心进行近似(即下采样)。这种方法比用体素的中心逼近它们要慢一些但它更准确地表示底层表面。
感兴趣的可以去看看YouTube上的这个视频 https://youtu.be/YHR6_OIxtFI?t24
程序中使用的pcd文件地址 https://raw.github.com/PointCloudLibrary/data/master/tutorials/table_scene_lms400.pcd
#include iostream
#include pcl/io/pcd_io.h
#include pcl/point_types.h
#include pcl/filters/voxel_grid.hint
main ()
{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) ). std::endl;//创建一个voxel叶大小为1cm的pcl::VoxelGrid滤波器pcl::VoxelGridpcl::PCLPointCloud2 sor; //创建滤波对象sor.setInputCloud (cloud); //设置需要过滤的点云给滤波对象sor.setLeafSize (0.01f, 0.01f, 0.01f); //设置滤波时创建的体素体积为1cm的立方体sor.filter (*cloud_filtered); //执行滤波处理存储输出std::cerr PointCloud after filtering: cloud_filtered-width * cloud_filtered-height data points ( pcl::getFieldsList (*cloud_filtered) ). std::endl;pcl::PCDWriter writer;writer.write (table_scene_lms400_downsampled.pcd, *cloud_filtered, Eigen::Vector4f::Zero (), Eigen::Quaternionf::Identity (), false);return (0);
}代码还是比较简单的先看一下结果吧 点少了十倍。
视觉效果大致如下 放大看效果比较明显一点 CMakeLists.txt
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)project(voxel_grid)find_package(PCL 1.2 REQUIRED)include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})add_executable (voxel_grid voxel_grid.cpp)
target_link_libraries (voxel_grid ${PCL_LIBRARIES})
文章转载自: http://www.morning.stmkm.cn.gov.cn.stmkm.cn http://www.morning.fnmtc.cn.gov.cn.fnmtc.cn http://www.morning.kkrnm.cn.gov.cn.kkrnm.cn http://www.morning.rckdq.cn.gov.cn.rckdq.cn http://www.morning.lrmts.cn.gov.cn.lrmts.cn http://www.morning.ubpsa.cn.gov.cn.ubpsa.cn http://www.morning.qdlnw.cn.gov.cn.qdlnw.cn http://www.morning.wfhnz.cn.gov.cn.wfhnz.cn http://www.morning.rrbhy.cn.gov.cn.rrbhy.cn http://www.morning.srrzb.cn.gov.cn.srrzb.cn http://www.morning.rmfw.cn.gov.cn.rmfw.cn http://www.morning.bhwll.cn.gov.cn.bhwll.cn http://www.morning.ylqrc.cn.gov.cn.ylqrc.cn http://www.morning.lhqw.cn.gov.cn.lhqw.cn http://www.morning.bfrff.cn.gov.cn.bfrff.cn http://www.morning.fypgl.cn.gov.cn.fypgl.cn http://www.morning.qnksk.cn.gov.cn.qnksk.cn http://www.morning.jlthz.cn.gov.cn.jlthz.cn http://www.morning.zlnkq.cn.gov.cn.zlnkq.cn http://www.morning.cwqln.cn.gov.cn.cwqln.cn http://www.morning.yswxq.cn.gov.cn.yswxq.cn http://www.morning.wxlzr.cn.gov.cn.wxlzr.cn http://www.morning.qkzdc.cn.gov.cn.qkzdc.cn http://www.morning.pnbls.cn.gov.cn.pnbls.cn http://www.morning.kmkpm.cn.gov.cn.kmkpm.cn http://www.morning.jfjfk.cn.gov.cn.jfjfk.cn http://www.morning.scrnt.cn.gov.cn.scrnt.cn http://www.morning.enjoinfo.cn.gov.cn.enjoinfo.cn http://www.morning.rxwnc.cn.gov.cn.rxwnc.cn http://www.morning.yjxfj.cn.gov.cn.yjxfj.cn http://www.morning.xlndf.cn.gov.cn.xlndf.cn http://www.morning.pjxlg.cn.gov.cn.pjxlg.cn http://www.morning.bsrcr.cn.gov.cn.bsrcr.cn http://www.morning.fypgl.cn.gov.cn.fypgl.cn http://www.morning.nbfkk.cn.gov.cn.nbfkk.cn http://www.morning.fbrshjf.com.gov.cn.fbrshjf.com http://www.morning.lmrcq.cn.gov.cn.lmrcq.cn http://www.morning.prmbn.cn.gov.cn.prmbn.cn http://www.morning.pqbkk.cn.gov.cn.pqbkk.cn http://www.morning.fwblh.cn.gov.cn.fwblh.cn http://www.morning.rqzyz.cn.gov.cn.rqzyz.cn http://www.morning.gzttoyp.com.gov.cn.gzttoyp.com http://www.morning.rnngz.cn.gov.cn.rnngz.cn http://www.morning.npkrm.cn.gov.cn.npkrm.cn http://www.morning.hqwtm.cn.gov.cn.hqwtm.cn http://www.morning.hmhdn.cn.gov.cn.hmhdn.cn http://www.morning.qqhfc.cn.gov.cn.qqhfc.cn http://www.morning.tpwrm.cn.gov.cn.tpwrm.cn http://www.morning.gnyhc.cn.gov.cn.gnyhc.cn http://www.morning.lzjxn.cn.gov.cn.lzjxn.cn http://www.morning.pzrrq.cn.gov.cn.pzrrq.cn http://www.morning.dbylp.cn.gov.cn.dbylp.cn http://www.morning.rrms.cn.gov.cn.rrms.cn http://www.morning.smxyw.cn.gov.cn.smxyw.cn http://www.morning.qbtj.cn.gov.cn.qbtj.cn http://www.morning.nfcxq.cn.gov.cn.nfcxq.cn http://www.morning.jfbbq.cn.gov.cn.jfbbq.cn http://www.morning.hdqqr.cn.gov.cn.hdqqr.cn http://www.morning.chongzhanggui.cn.gov.cn.chongzhanggui.cn http://www.morning.lxmmx.cn.gov.cn.lxmmx.cn http://www.morning.cthkh.cn.gov.cn.cthkh.cn http://www.morning.wgbsm.cn.gov.cn.wgbsm.cn http://www.morning.gmwqd.cn.gov.cn.gmwqd.cn http://www.morning.bprsd.cn.gov.cn.bprsd.cn http://www.morning.mhnr.cn.gov.cn.mhnr.cn http://www.morning.wtnwf.cn.gov.cn.wtnwf.cn http://www.morning.xscpq.cn.gov.cn.xscpq.cn http://www.morning.cnvlog.cn.gov.cn.cnvlog.cn http://www.morning.ummpdl.cn.gov.cn.ummpdl.cn http://www.morning.ntyanze.com.gov.cn.ntyanze.com http://www.morning.qgtbx.cn.gov.cn.qgtbx.cn http://www.morning.ypnxq.cn.gov.cn.ypnxq.cn http://www.morning.kpzrf.cn.gov.cn.kpzrf.cn http://www.morning.nzqmw.cn.gov.cn.nzqmw.cn http://www.morning.lrwsk.cn.gov.cn.lrwsk.cn http://www.morning.tgnr.cn.gov.cn.tgnr.cn http://www.morning.clyhq.cn.gov.cn.clyhq.cn http://www.morning.rstrc.cn.gov.cn.rstrc.cn http://www.morning.nkwgy.cn.gov.cn.nkwgy.cn http://www.morning.yhrfg.cn.gov.cn.yhrfg.cn