pcl 读txt对每个坐标+0.001 并且保存格式为txt
时间: 2024-01-24 09:04:52 浏览: 88
可以使用以下代码来实现:
```cpp
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
void readPointCloud(std::string inputFile, std::string outputFile)
{
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
if (pcl::io::loadPCDFile<pcl::PointXYZ>(inputFile, *cloud) == -1)
{
throw std::runtime_error("Couldn't read input file");
}
std::ofstream outFile(outputFile, std::ios::out | std::ios::trunc);
if (!outFile.is_open())
{
throw std::runtime_error("Couldn't open output file");
}
for (auto& point : *cloud)
{
point.x *= 0.001;
point.y *= 0.001;
point.z *= 0.001;
outFile << std::fixed << std::setprecision(6) << point.x << " "
<< std::fixed << std::setprecision(6) << point.y << " "
<< std::fixed << std::set
阅读全文