生活随笔
收集整理的這篇文章主要介紹了
PCD文件操作
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.PCD文件的創建
pcl::PointCloud<pcl::PointXYZ> cloud;// Fill in the cloud datacloud.width = 500;cloud.height = 200;cloud.is_dense = false;cloud.points.resize(cloud.width * cloud.height);for (std::size_t i = 0; i < cloud.points.size(); ++i){cloud.points[i].x =2 * rand() / (RAND_MAX + 1.0f);cloud.points[i].y =2 * rand() / (RAND_MAX + 1.0f);cloud.points[i].z = 2 * rand() / (RAND_MAX + 1.0f);}pcl::io::savePCDFileASCII("test_pcd.pcd", cloud);
2.PCD文件的讀取
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);if (pcl::io::loadPCDFile<pcl::PointXYZ>("test_pcd.pcd", *cloud) == -1) //* load the file{PCL_ERROR("Couldn't read file test_pcd.pcd \n");return (-1);}
3.點云數據的顯示
pcl::visualization::CloudViewer viewer("Cloud Viewer");viewer.showCloud(cloud);while(!viewer.wasStopped()){}
總結
以上是生活随笔為你收集整理的PCD文件操作的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。