把一个文件夹下的多帧图像数据转成一个文件中,方便动态特征图

#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

后面两个循环----------------------- 是取出 眼睛眉毛和嘴 这三部分。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值