日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

PCL两种方式的点云读写

發布時間:2023/11/27 生活经验 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 PCL两种方式的点云读写 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

首先第一種讀取方式使用reader


#include <pcl/point_types.h>//PCL對各種格式的點的支持頭文件
#include <pcl/io/pcd_io.h>//PCL的PCD格式文件的輸入輸出頭文件
#include <pcl/kdtree/kdtree_flann.h>
typedef pcl::PointXYZI PointT;
int
main (int argc, char** argv)
{
pcl::PointCloud<pcl::PointXYZI>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZI>);	// Generate pointcloud data,新建指針cloud存放點云	
pcl::PCDReader reader;	
reader.read<pcl::PointXYZI>("1.pcd", *cloud);//讀取1.pcd文件,用指針傳遞給cloud。
std::cout << "Loaded "<< cloud->width * cloud->height<< " data points from test_pcd.pcd with the following fields: "<< std::endl;for (std::size_t i = 0; i < cloud->points.size (); ++i){std::cout << "    " << cloud->points[i].x<< " "    << cloud->points[i].y<< " "    << cloud->points[i].z << std::endl;}return (0);
}

第二種使用loadPCDFile

#include <pcl/point_types.h>//PCL對各種格式的點的支持頭文件
#include <pcl/io/pcd_io.h>//PCL的PCD格式文件的輸入輸出頭文件
#include <pcl/kdtree/kdtree_flann.h>
typedef pcl::PointXYZI PointT;
//pcl:Pointcloud<pcl::PointXYZ>cloud    //1111111111111111111111
pcl::PointCloud<pcl::PointXYZI>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZI>);	// Generate pointcloud data,新建指針cloud存放點云	
if (pcl::io::loadPCDFile<pcl::PointXYZI>("1.pcd", *cloud) == -1)//*打開點云文件。
{PCL_ERROR("Couldn't read that pcd file\n");return(-1);//如果沒找到該文件,返回-1,跳出整個main函數
}//寫入方法一:
pcl::PCDWriter writer;
writer.write<pcl::PointXYZI>("name_cluster.pcd", *INcloud, false);//將點云保存到PCD文件中
//*INcloud該參數帶不帶*號,取決于你自己定義的cloud類型,如上使用的是Ptr,智能指針所以下邊傳參也要帶*號-------按照111111111111方式定義點云的話,傳參不帶*號
//寫入方法二:
pcl::io::savePCDFileASCII("name_cluster.pcd", *INcloud); //將點云保存到PCD文件中

?

總結

以上是生活随笔為你收集整理的PCL两种方式的点云读写的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。