如何修改PCL点云保存路径

在使用PCL库进行点云处理时,您可能需要将处理后的点云数据保存到特定的路径。下面将介绍如何修改程序中的文件保存路径。

代码示例:

int begin = 0;
	for (auto it = cluster_indices.begin(); it != cluster_indices.end(); ++it)
	{
		pcl::PointCloud<PointT>::Ptr cloud_cluster(new pcl::PointCloud<PointT>);
		for (auto pit = it->indices.begin(); pit != it->indices.end(); pit++)
		{
			cloud_cluster->push_back(cloud->points[*pit]);
		}

		std::stringstream ss;
		ss << 'D:/PointCloud/Euclidean_cluster_' << begin + 1 << '.ply'; // 修改保存路径
		pcl::io::savePLYFileBinary(ss.str(), *cloud_cluster);

		cout << ss.str() << '保存完毕!!!' << endl;
		begin++;
	}

修改保存路径

在代码示例中,我们将 ss << 'Euclidean_cluster_' << begin + 1 << '.ply'; 改为 ss << 'D:/PointCloud/Euclidean_cluster_' << begin + 1 << '.ply';。

  1. 将保存路径改为您想要的路径,例如 D:/PointCloud/。
  2. 使用单引号 ' 而不是双引号 ' 来包含路径字符串。

注意事项

  1. 确保您有写入目标路径的权限。
  2. 确保路径中没有非法字符。

总结

通过修改 stringstream 对象的内容,可以轻松地将点云数据保存到您指定的路径。


原文地址: https://www.cveoy.top/t/topic/nHMc 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录