std::string input_file = "E://TY//camport3-master//test_Cloud.xyz";
// 读取txt文件中的点云数据
std::ifstream infile(input_file.c_str());
std::vector<float> data;
float value;
while (infile >> value)
{
data.push_back(value);
}
infile.close();
// 将数据转换为点云格式
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
int size = data.size() / 3;
cloud->points.resize(size);
for (int i = 0; i < size; ++i)
{
cloud->points[i].x = data[i * 3];
cloud->points[i].y = data[i * 3 + 1];
cloud->points[i].z = data[i * 3 + 2];
}