测试集_转换WEKA格式_保留版

/*******************************
作者:David Bao
时间:2012年3月15日
描述:使用PCA对图像进行变幻后得到PCA系数,现在是一个大矩阵,每一行是一幅图像的PCA特征
		   6种表情,每种表情3个图片,共108副,此程序专门针对test集!
		   矩阵大小为18*200 导入转换成arff文件
********************************/
#include <string>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <sstream>
#define N 70
using namespace std;
void main()
{
	string FileName;
	char name[30];
	
	fstream InFile;
	ofstream OutFile("C:\\Users\\user\\Desktop\\MyDoc\\ExpressionData\\JAFFE\\DCT\\Whole\\DCT-test-Whole.arff");

	if(OutFile.is_open())
	{
		OutFile<<"@relation 'FER'"<<endl;
		char *ch = new char;
		for(int i=1;i<=300;i++)
		{
			itoa(i,ch,10);
			OutFile<<"@attribute feature"+string(ch)+" real"<<endl;
		}
		OutFile << "@attribute 'class' {angry,disgust,fear,happy,neutral,sad,surprise}"<<endl;
		OutFile << "@data" << endl;
		FileName = string("C:\\Users\\user\\Desktop\\MyDoc\\ExpressionData\\JAFFE\\DCT\\TXT\\DCT-test-Whole.txt");
		cout << FileName.c_str() <<endl;
		InFile.open(FileName.c_str(),ios::in);

		//int counter = 0;
		string line;
		int i=1;
		while(getline(InFile,line))
		{
			istringstream stream(line);
			string word;
			while(stream >> word)
			{
				OutFile << word.c_str() << ",";
			}
			if(i>=1 && i<=10)
			{
				OutFile << "angry"<<endl;
			}
			if(i>=11 && i<=20)
			{
				OutFile << "disgust" <<endl;
			}
			if(i>=21 && i<=30)
			{
				OutFile << "fear" <<endl;
			}
			if(i>=31 && i<=40)
			{
				OutFile << "happy" <<endl;
			}
			if(i>=41 && i<=50)
			{
				OutFile << "neutral" <<endl;
			}
			if(i>=51 && i<=60)
			{
				OutFile << "sad" <<endl;
			}
			if(i>=61 && i<=70)
			{
				OutFile << "surprise" <<endl;
			}
			//CMU database
			//switch(i)
			//{
			//case 1:
			//case 2:
			//case 3:
			//	OutFile << "angry"<<endl;
			//	break;
			//case 4:
			//case 5:
			//case 6:
			//	OutFile << "disgust"<<endl;
			//	break;
			//case 7:
			//case 8:
			//case 9:
			//	OutFile << "fear"<<endl;
			//	break;
			//case 10:
			//case 11:
			//case 12:
			//	OutFile << "sadness"<<endl;
			//	break;
			//case 13:
			//case 14:
			//case 15:
			//	OutFile << "smile"<<endl;
			//	break;				
			//case 16:
			//case 17:
			//case 18:
			//	OutFile << "surprise"<<endl;
			//	break;
			//}
			i++;
		}
		
		InFile.close();
	}
	else
	{
		cout << "打开文件失败哇……" <<endl;
	}
	OutFile.close();
	//system("pause");
}

 

CMU:测试集:18幅 = 6种表情 * 3幅

JAFFE:测试集 : 70幅 = 7种表情 * 10幅

 

 


 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值