1. 程式人生 > >ROS PCL 點雲處理學習之二 Downsampling a PointCloud using a VoxelGrid filter

ROS PCL 點雲處理學習之二 Downsampling a PointCloud using a VoxelGrid filter

mkdir test2
cd test2
touch voxel_grid.cpp 
gedit voxel_grid.cpp  

#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 data
  pcl::PCDReader reader;
  // Replace the path below with the path where you saved your file
  reader.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 object
  pcl::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);
}

touch CMakeList.txt 
gedit CMakeList.txt 

cmake_minimum_required(VERSION 2.8 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})

結果為 :

PointCloud before filtering: 460400 data points (x y z intensity distance sid)
PointCloud after filtering: 41049 data points (x y z intensity distance sid)


相關推薦

ROS PCL 處理學習 Downsampling a PointCloud using a VoxelGrid filter

mkdir test2 cd test2 touch voxel_grid.cpp gedit voxel_grid.cpp #include <iostream> #include <pcl/io/pcd_io.h> #include <

pcl處理pca演算法

2018年11月08日 19:10:20 weixin_41825780 閱讀數:2 標籤: pcl

PCL學習&VS2010(X64)》Part 22 鐳射雷達資料處理相關演算法庫收集

2.Point Cloud Library (PCL) 是一個獨立的大型的處理二維/三維影象和點雲資料的開源工程,由Willow Garage公司開發,起初只是以PR2機器人在3D資料感知演算法處理上速度更快為目標,後來才漸漸發展為一個獨立的函式庫。PCL包含了許多先進演算法,比如濾波,特徵估計,表面重建,

PCL處理視覺化——法向顯示錯誤“no override found for vtk actor”解決方法

一、環境 Win10 X64 VS2015 PCL1.8.0AllinOne 二、程式碼 #include "stdafx.h" #include <pcl/point_types.h> #include <pcl/io/pcd_io.h> #inc

ros/pcl 分割——分離地面

程式碼  #include <ros/ros.h> // PCL specific includes #include <sensor_msgs/PointCloud2.h> #include <pcl_conversions/pcl_conv

PCL學習&VS2010(X64)》Part 51 PTDV0.2迭代加密三角網演算法V0.2

《PCL點雲庫學習&VS2010(X64)》Part 51 PTDV0.2迭代加密三角網演算法V0.2 1、利用實際點雲測試初級版本的漸進加密三角網演算法: 1、獲取最低點 2、構建初始三角網 3、更新最低點 4、更新三角

PCL處理BUG記錄及分析

1) PCL_ROS 其實引用了PCL庫,不要隨意編譯PCL庫,可能導致PCL-ROS不能使用! 2) PCL自動安裝的時候與C11不相容,如果想使用C11,需要自己編譯PCL庫,並在PCL編譯之前的CMakelist.txt中加入C11的編譯項! 不過編譯的過程中PCL

PCL學習&VS2010(X64)》Part 34 旋轉平移矩陣用法

《PCL點雲庫學習&VS2010(X64)》Part 34 旋轉平移矩陣用法 1、變換與投影矩陣講解: 點雲變換主要涉及平移、旋轉、縮放、反射、剪下、視角轉換、投影等,這裡主要介紹平移與旋轉。 2、使用Eigen::Matrix4f 進行變換 #includ

pcl學習筆記

點雲檔案的開啟。 #include <pcl/point_types.h> #include <pcl/common/common.h> #include <pcl/point_cloud.h> #include <pcl/io/

PCL學習&VS2010(X64)》Part 8 PCL1.72(VTK6.2.0)視覺化例程

Part 8 PCL1.72(VTK6.2.0)視覺化例程                                                                                                PCL1.72 VTK

PCL學習&VS2010(X64)》Part 24 PCL&VTK&Eigen Spline曲線擬合

《PCL點雲庫學習&VS2010(X64)》Part 24 PCL&VTK&Eigen Spline曲線擬合 1、PCL曲線擬合: 由於需要編譯PCL的原始碼才能使用曲線擬合功能,所以,暫時在另外一臺計算機上編譯成功PCL1.8.0。出現了一個問題

PCL—關鍵點檢測(rangeImage)低層次處理

數據結構 關系 n-1 -a 平面 邊緣提取 bubuko 數據 方式 博客轉載自:http://www.cnblogs.com/ironstark/p/5046479.html 關鍵點又稱為感興趣的點,是低層次視覺通往高層次視覺的捷徑,抑或是高層次感知對低層次處理手段的妥

pcl的濾波與特徵學習筆記

參考連結: 點雲資料時不可避免的存在噪聲,或者離群點(離主體點雲即被測物體點雲較遠的離散點)。 濾波是點雲資料處理流程中的第一步,往往對後續處理管道影響很大,只有在濾波預處理中將噪聲點、離群點、孔洞、資料壓縮等按照後續處理定製,才能夠更好的進行配準、特徵提取、曲面

Azure平臺學習路()——SQL Database

1、什麼是SQL Database? 託管關係資料庫,資料庫即服務,IaaS的一種。 2、有哪些特點? (1)為SaaS應用提供可擴充套件的資料儲存服務。 (2)易於操作大量的資料庫。稍後介紹幾種操作資料庫的方法。 (3)效能更高,穩定性更好。基於A

pcl的一些學習認識

博主最近在做三維重建,之前就瞭解過pcl庫,俗話說,二維處理靠opencv,三維處理靠pcl,那麼這個點雲庫到底有什麼神奇功能呢?博主才疏學淺,現在就學瞭如何將三維點顯示和一些簡單的濾波,在這裡,對自己,也是對廣大初學者都可以做個複習和簡單的介紹。首先如何將已有的三維點顯示,

ROS中的處理

使用點雲庫(Point Cloud Library, pcl)可以三維影象感測器的資料。這個開源庫是獨立的,但是可以在ROS中使用。pcl中提供了一系列函式來處理三維資料。本文使用一些常用的函式介紹一些簡單的功能。 簡單的點雲顯示節點 pcl_ut

pcl:三維模型obj格式轉成pcl常用處理格式.pcd+matlab:.ply.pcd+其他.stl,.obj,.ply等三維格式互相轉化方法

①程式碼: #include <pcl/io/io.h> #include <pcl/io/pcd_io.h> #include <pcl/io/obj_io.h>

Monkeyrunner學習(如何使用id去選的方法)

Monkeyrunner學習之一中學習到如何檢視控制元件id,接下來我們學習Monkeyrunner如何使用id去點選的方法 from com.android.monkeyrunner import MonkeyRunner, MonkeyDevicefrom com.an

【opencv學習十四】OpenCV濾波處理對比

OpenCV的鄰域濾波處理函式主要都通影象的卷積操作,有 1方框濾波boxFilter(),屬於線性濾波,其原理是用一個矩陣和一個核矩陣卷積操作; 2均值濾波blur(),也屬於線性濾波,是方框濾波一種歸一化後的方框濾波; 3高斯濾波GaussianBlur(),屬於線性濾

linux學習:日常的基礎命令收集

幫助文檔 gedit 查看 日期 取整 style 位置 某月 linux 1、 ls 2、pwd  顯示當前目錄所在位置 3、date  日期時間 4、cal  日歷   默認顯示當前該月   cal 2012 :查看2012年的日歷   cal 月 年 : 查看某年某月