c++ 读取csv文件格式点云

c++ 读取csv文件格式点云_第1张图片
如图点云以csv文件存储,下面代码读取每个点的坐标值存放在 pcl::PointCloud中:

#include 
#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;

//删除字符串中空格,制表符tab等无效字符
string Trim(string& str)
{
	//str.find_first_not_of(" \t\r\n"),在字符串str中从索引0开始,返回首次不匹配"\t\r\n"的位置
	str.erase(0, str.find_first_not_of(" \t\r\n"));
	str.erase(str.find_last_not_of(" \t\r\n") + 1);
	return str;
}

void csv2pointCloud(std::string filename, pcl::PointCloud::Ptr &cloud)
{
	cloud->points.clear();
	ifstream fin(filename); //打开文件流操作
	string line;
	while (getli

你可能感兴趣的:(PCL学习,c++,开发语言,后端)