将pcd格式的点云数据去掉第四维度Itensity信息仍保存为pcd格式
生活随笔
收集整理的這篇文章主要介紹了
将pcd格式的点云数据去掉第四维度Itensity信息仍保存为pcd格式
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
#include "pch.h"
#include <iostream>//標(biāo)準(zhǔn)C++庫中的輸入輸出類相關(guān)的頭文件
#include <string.h>
#include <pcl/io/auto_io.h>//pcd讀寫類相關(guān)的頭文件int main(int argc, char** argv)
{std::string filename = "F:\\cout-saved\\back_1.pcd";
//創(chuàng)建一個(gè)pcl::PointCloud<pcl::PointXYZI>boost共享指針并進(jìn)行實(shí)例化pcl::PointCloud<pcl::PointXYZI>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZI>);
//打開點(diǎn)云文件if (pcl::io::loadPCDFile(filename, *cloud) < 0){std::cout << "open file error" << std::endl;Sleep(3000);return -1;}pcl::PointCloud<pcl::PointXYZ>::Ptr new_cloud(new pcl::PointCloud<pcl::PointXYZ >);new_cloud->width = cloud->width;new_cloud->height = cloud->height;new_cloud->points.resize(cloud->points.size());for (int i = 0; i < cloud->points.size(); ++i){new_cloud->points[i].x = cloud->points[i].x;new_cloud->points[i].y = cloud->points[i].y;new_cloud->points[i].z = cloud->points[i].z;}if (pcl::io::savePCDFile("F:\\cout-saved\\back_1_remove.pcd", *new_cloud) < 0){std::cout << "save file error" << std::endl;Sleep(3000);return -1;}else{std::cout << "save file success" << std::endl;Sleep(3000);return 0;}
}
上述代碼功能為:將點(diǎn)云數(shù)據(jù)的Pcd格式數(shù)據(jù)包含XYZI的刪除掉I,仍保存為Pcd格式。此點(diǎn)云數(shù)據(jù)有(841行X777列)=653457個(gè)點(diǎn)
總結(jié)
以上是生活随笔為你收集整理的将pcd格式的点云数据去掉第四维度Itensity信息仍保存为pcd格式的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 1.(基于欧式距离聚类实现的点云分割)
- 下一篇: 点云滤波