计算机从相机中得到了两个文件
1.包含图像数据的二进制文件
2.用于描述二进制文件的 XML 文件
其中xml文件内容如下:
我将数据读出来,发现有些数据特别大,有些又特别小
请问需要怎么改进
代码如下:
#include<iostream>
#include <fstream>
#include <string>
#include<vector>
using namespace std;
void DataRead_CPPMode(string path);
int main()
{
string path;//文件路径
path = "img-0.dat";
DataRead_CPPMode(path);
system("pause");
return 0;
}
/*
读二进制文件
path: 文件路径
*/
void DataRead_CPPMode(string path)
{
//每次读取3个
double pos_in[3];
ifstream infile(path, ios::binary);
if (!infile)
{
cout << "读取文件失败" << endl;
return;
}
//写出
ofstream outfile("dianyun.txt");
if (!outfile)
{
cerr << "open error!" << endl;
exit(1);
}
while (!infile.eof())
{
infile.read((char*)pos_in, 3 * sizeof(double));
for (int i = 0; i < 3; i++)
{
cout << pos_in[i] << "\t";
outfile << pos_in[i] << "\t";
}
cout << endl;
outfile << endl;
}
infile.close();
outfile.close();
}