#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <sstream>
#define NUM_FILE 24
using namespace std;
void main()
{
vector<int> x;
vector<int> y;
for(int i=1; i <= NUM_FILE; i++)
{
fstream file;
string FileName = "D:\\test\\56-fear\\";
char *n_str = new char;
itoa(i,n_str,10);
FileName = FileName + n_str;
FileName = FileName +".txt";
file.open(FileName.c_str(),ios::in);
if(!file.is_open())
{
cout << "打开失败了。"<<endl;
system("pause");
}
int flag = 1;
//从文件中获取每一行,用每一行初始化一个字符串流,
string line;
while(getline(file,line))
{
istringstream stream(line);
int w;
while(stream >> w)
{
switch(flag % 3)
{
case 1:
x.push_back(w);
break;
case 2:
y.push_back(w);
break;
default:
break;
}
cout <<w <<" ";
flag++;
}
cout <<endl;
}
file.close();
}
//x中存放一组文件中的x坐标
//文件1[66个x坐标],文件2[66个x坐标]...文件30[66个x坐标]
//y中存放一组文件中的y坐标
//文件1[66个y坐标],文件2[66个y坐标]...文件30[66个y坐标]
//下面要将每个
string outfileName("D:\\test\\56-fear\\");
outfileName = outfileName + "PointSet1.txt";
fstream outfile;
outfile.open(outfileName.c_str(),ios::out);
//outfile.open(argv[1]+"PointSet1.txt",ios::out);
//1-60
//这里过滤掉1到17,脸颊的点。
//
for(int i=18; i<=27; ++i)
{
//outfile<<"X("<<i<<"):";
for(int j=i-1; j<(NUM_FILE)*66 ; j=j+66)
{
outfile << x.at(j) << " ";
}
outfile << endl;
//outfile<<"Y("<<i<<"):";
for(int k=i-1; k<(NUM_FILE)*66 ; k=k+66)
{
outfile << y.at(k) <<" ";
}
outfile << endl;
}
for(int i=37; i<=60; ++i)
{
//outfile<<"X("<<i<<"):";
for(int j=i-1; j<(NUM_FILE)*66 ; j=j+66)
{
outfile << x.at(j) << " ";
}
outfile << endl;
//outfile<<"Y("<<i<<"):";
for(int k=i-1; k<(NUM_FILE)*66 ; k=k+66)
{
outfile << y.at(k) <<" ";
}
outfile << endl;
}
}
NUM_FILE--------------------------该文件夹下的帧图像数据文件的个数
输入文件的文件夹 ----------------FileName
输出文件保存的目录---------------outfileName
后面两个循环----------------------- 是取出 眼睛眉毛和嘴 这三部分。