/*******************************
作者: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幅