如图点云以csv文件存储,下面代码读取每个点的坐标值存放在 pcl::PointCloud中:
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <pcl/point_types.h>
#include <pcl/io/pcd_io.h>
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<pcl::PointXYZ>::Ptr &cloud)
{
cloud-