點(diǎn)的類型有
#include <pcl/point_types.hpp>
pcl::PointXYZ
pcl::PointXYZI
pcl::PointXYZRGB
pcl::PointXYZHSV
點(diǎn)云類型
#include <pcl/point_cloud.h>
PointCloud類型:以std::vector<PointT, Eigen::aligned_allocator<PointT> > points為數(shù)據(jù)存儲(chǔ)宿接,自己又套了一層API
#include <pcl/PCLPointCloud2.h>
PCLPointCloud2類型:二進(jìn)制存儲(chǔ)的點(diǎn)云類型std::vector<pcl::uint8_t> data;褥蚯。按編碼(std::vector<pcl::PCLPointField> fields;)對應(yīng)data中各位段的意義嵌纲。
點(diǎn)云類型基本操作
/* 常用成員 */
//pcl庫的所有類型都有Ptr對應(yīng)std::share_ptr和ConstPtr
pcl::PointCloud<pcl::PointXYZ>::Ptr;
pcl::PCLPointCloud2<pcl::PointXYZ>::Ptr;
pcl::visualization::PCLVisualizer::Ptr;
-----------------------------------------------------------------------------------------------
/* 常用運(yùn)算 */
//直接拼接融合
+= 和+
//訪問元素
pc(row,col)或pc.at(row,col)其中at是帶保護(hù)的查近。且只有height>=0才能使用這兩個(gè)方法(按2D圖像方式存儲(chǔ))
而pc[i]痕囱,訪問pc中存儲(chǔ)vector的第i個(gè)值寥殖。或pc.point.data()返回首地址
//遍歷
由于點(diǎn)云實(shí)際是vector實(shí)現(xiàn)的所以可以使用標(biāo)準(zhǔn)遍歷形式
for(auto item:PC){}
//數(shù)據(jù)流重載
<<可以直接輸出
點(diǎn)云類型之間的轉(zhuǎn)換
/* ros的sensor_msgs::PointCloud2和pcl的點(diǎn)云轉(zhuǎn)換 */
#include <pcl_conversions/pcl_conversions.h>
pcl::fromROSMsg(ros_pc,pcl_pc)
pcl::moveFromROSMsg(ros_pc,pcl_pc)//盡量不用输枯,這是把ros_pc的以指針形式和內(nèi)部中間臨時(shí)變量交換,再拷貝給pcl_pc占贫。使用后pcl_pc是一個(gè)野指針桃熄。
pcl::toROSMsg(pcl_pc,ros_pc)//記得修改轉(zhuǎn)換后ros_pc的stamped⌒桶拢或在轉(zhuǎn)換器給pcl_pc的stamped賦值
pcl::moveToROSMsg(pcl_pc,ros_pc)//同上使用后pcl_pc是一個(gè)野指針瞳收。
-----------------------------------------------------------------------------------------------
/* pcl::pointcloud和pclpointcloud2轉(zhuǎn)換 */
pcl::toPCLPointCloud2(pc,pc2);
pcl::fromPCLPointCloud2(pc2,pc);
點(diǎn)云拷貝
//不必外部初始化或?yàn)閛utput甚至內(nèi)存厢汹,直接覆蓋掉元數(shù)據(jù)
pcl::copyPointCloud(intut螟深,output)