Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions Score.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
void comparison(){
if (eyeLeftHeight != 0.0&& plugged) {
//reportFrame();
videoFrame++;
if (videoFrame<90) {//frameCount
TableRow row = referTable.getRow(videoFrame); //sync to the referTable it was frameCount
NKframe = row.getInt("frameCount");
NKBrowL = row.getFloat("LBrowH");
NKBrowR = row.getFloat("RBrowH");
NKEyeL = row.getFloat("LEyeH");
NKEyeR = row.getFloat("REyeH");
NKNose = row.getFloat("nose");
NKMouthH = row.getFloat("MouseH");
NKMouthW = row.getFloat("MouseW");
NKOriX = row.getFloat("OriX");
NKOriY = row.getFloat("OriY");
NKOriZ = row.getFloat("OriZ");
}
//scoreStringChange();
if (endOfClip) { //frameCount >=90
//scoreStringChange();
//frameCount =0;
score = 0;
println("show the SCORE HERE");
endOfClip = false;
}else{
scoreStringChange();
}
} else {
frameCount =0;
score = 0;
}
}

void scoreStringChange() {
println("///////////////////////////////FRAME : " + NKframe+ " CSV : "+NKBrowL +" WEBCAM : "+leftEyebrowHeight + " SCORE : "+score);
if (NKBrowL-area <leftEyebrowHeight && NKBrowL+area >leftEyebrowHeight) {score++;}
if (NKBrowR-area<rightEyebrowHeight && NKBrowR+area >rightEyebrowHeight) {score++;}
if (NKEyeL-area< eyeLeftHeight && NKEyeL+area> eyeLeftHeight) {score++;}
if (NKEyeR-area< eyeRightHeight && NKEyeR+area >eyeRightHeight ) {score++;}
if (NKNose-area< nostrilHeight && NKNose+area >nostrilHeight) {score++;}
if (NKMouthH-area< mouthHeight && NKMouthH+area> mouthHeight) {score++;}
if (NKMouthW-area< mouthWidth && NKMouthW+area> mouthWidth) {score++;}
if (NKOriX-area<poseOrt_x && NKOriX+area>poseOrt_x) {score++;}
if (NKOriY-area<poseOrt_y && NKOriY+area>poseOrt_y) {score++;}
if (NKOriZ-area<poseOrt_z && NKOriZ+area>poseOrt_z) {score++;}

if (score < 400) {scoreString = "You are such a mundane person.";}
else if (score>=500 && score<=500) {scoreString = "Your acting is ok but still too boring.";}
else if ( score>500 & score <=600) {scoreString = "You are kidda fancy person.";}
else if ( score>600 & score <=700) {scoreString = "Ahrr.. May be you can be a star one day.";}
else if ( score>700 ) {scoreString = "Yeah... you do good. Ready for a celeb life?";}
}

void loadReferTable() {
//referTable = loadTable("NikkiVideoData.csv","header");
//println(referTable.getRowCount() + "total rows in table");
for (TableRow row : referTable.rows()) {
NKframe = row.getInt("frameCount");
NKBrowL = row.getFloat("LBrowH");
NKBrowR = row.getFloat("RBrowH");
NKEyeL = row.getFloat("LEyeH");
NKEyeR = row.getFloat("REyeH");
NKNose = row.getFloat("nose");
NKMouthH = row.getFloat("MouseH");
NKMouthW = row.getFloat("MouseW");
NKOriX = row.getFloat("OriX");
NKOriY = row.getFloat("OriY");
NKOriZ = row.getFloat("OriZ");
println("DATA FROM THE CSV : "+NKOriZ);
}
}

void saveReferTable(){
TableRow newRow = infoTable.addRow();
newRow.setInt("frameCount", frameCount);//infoTable.lastRowIndex());
newRow.setFloat("LBrowH", Math.round(leftEyebrowHeight*100)/100.0);
newRow.setFloat("RBrowH", Math.round(rightEyebrowHeight*100)/100.0);
newRow.setFloat("LEyeH", Math.round(eyeLeftHeight*100)/100.0);
newRow.setFloat("REyeH", Math.round(eyeRightHeight*100)/100.0);
newRow.setFloat("nose", Math.round(nostrilHeight*100)/100.0);
newRow.setFloat("MouseH", Math.round(mouthHeight*100)/100.0);
newRow.setFloat("MouseW", Math.round(mouthWidth*100)/100.0);
newRow.setFloat("OriX", Math.round(poseOrt_x*100)/100.0);
newRow.setFloat("OriY", Math.round(poseOrt_y*1000)/1000.0);
newRow.setFloat("OriZ", Math.round(poseOrt_z*100)/100.0);

}
157 changes: 19 additions & 138 deletions SelebFaceGame.pde
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,31 @@ PGraphics canvas;
PVector[] meshPoints;
PVector posePosition, poseOrientation;
Table infoTable, referTable;

///
//videoScreen Buttons
PImage Btn01,Btn02,Btn03,Btn04,Btn05;
///
boolean found;

float poseScale, posePos_x, posePos_y, poseOrt_x, poseOrt_y, poseOrt_z;
float leftEyebrowHeight, rightEyebrowHeight, eyeLeftHeight, eyeRightHeight, mouthWidth, mouthHeight, nostrilHeight;
//
int programFrame, videoFrame, i;
int programFrame, videoFrame = 0, i;
//reference values
int NKframe;
float NKBrowL, NKBrowR, NKEyeL, NKEyeR, NKNose, NKMouthH, NKMouthW, NKOriX, NKOriY, NKOriZ;
boolean play=true, readytoPlay=false, home=true;
boolean play=true, readytoPlay=false, home=true, videoScreen=false, gameMode =false, endOfClip = false, tutorial= false;
int waveCount = 0;
int mouseOver=0;
PImage js,ksi,nk,bb,gm,gg,pew,pom,shane,title;

//settings
int w = 1440, h = 860, score =0;
String scoreString="", words="XXXXXXXX";
//int area =1; //threshold
/*void settings() {
public String scoreString="";
float area =0.2;
float ori = 0.01;
void settings() {
size(w, h, P3D);
}*/
}
void setup() {
setupNewUI();
noStroke();
Expand All @@ -54,7 +59,6 @@ void setup() {
//cam = new Capture(this,1280,960, "USB Camera");
cam = new Capture(this, cameras[0]);
cam.start();

//XXXXXXXXXXXXXXXXXX
//FACEOSC PLUG-INS
//XXXXXXXXXXXXXXXXXX
Expand Down Expand Up @@ -92,7 +96,7 @@ void setup() {
//saveTable(infoTable, "table.csv");
//loadReferTable();
referTable = loadTable("NikkiVideoData.csv", "header");
canvas = createGraphics(w, h, P3D);
//canvas = createGraphics(w, h, P3D);
frameRate(30);
}

Expand All @@ -102,137 +106,14 @@ void draw() {
drawUI();
//loadReferTable();
//frameCount = programFrame;
if (eyeLeftHeight != 0.0&& plugged) {
//reportFrame();
TableRow newRow = infoTable.addRow();
newRow.setInt("frameCount", frameCount);//infoTable.lastRowIndex());
newRow.setFloat("LBrowH", Math.round(leftEyebrowHeight*100)/100.0);
newRow.setFloat("RBrowH", Math.round(rightEyebrowHeight*100)/100.0);
newRow.setFloat("LEyeH", Math.round(eyeLeftHeight*100)/100.0);
newRow.setFloat("REyeH", Math.round(eyeRightHeight*100)/100.0);
newRow.setFloat("nose", Math.round(nostrilHeight*100)/100.0);
newRow.setFloat("MouseH", Math.round(mouthHeight*100)/100.0);
newRow.setFloat("MouseW", Math.round(mouthWidth*100)/100.0);
newRow.setFloat("OriX", Math.round(poseOrt_x*100)/100.0);
newRow.setFloat("OriY", Math.round(poseOrt_y*1000)/1000.0);
newRow.setFloat("OriZ", Math.round(poseOrt_z*100)/100.0);
if (frameCount<90) {
TableRow row = referTable.getRow(frameCount);
NKframe = row.getInt("frameCount");
NKBrowL = row.getFloat("LBrowH");
NKBrowR = row.getFloat("RBrowH");
NKEyeL = row.getFloat("LEyeH");
NKEyeR = row.getFloat("REyeH");
NKNose = row.getFloat("nose");
NKMouthH = row.getFloat("MouseH");
NKMouthW = row.getFloat("MouseW");
NKOriX = row.getFloat("OriX");
NKOriY = row.getFloat("OriY");
NKOriZ = row.getFloat("OriZ");
}
println("///////////////////////////////CSV : "+NKBrowL +" WEBCAM : "+leftEyebrowHeight + " SCORE : "+score);
if (NKBrowL-area <leftEyebrowHeight && NKBrowL+area >leftEyebrowHeight) {score++;}
if (NKBrowR-area<rightEyebrowHeight && NKBrowR+area >rightEyebrowHeight) {score++;}
if (NKEyeL-area< eyeLeftHeight && NKEyeL+area> eyeLeftHeight) {score++;}
if (NKEyeR-area< eyeRightHeight && NKEyeR+area >eyeRightHeight ) {score++;}
if (NKNose-area< nostrilHeight && NKNose+area >nostrilHeight) {score++;}
if (NKMouthH-area< mouthHeight && NKMouthH+area> mouthHeight) {score++;}
if (NKMouthW-area< mouthWidth && NKMouthW+area> mouthWidth) {score++;}
if (NKOriX-area<poseOrt_x && NKOriX+area>poseOrt_x) {score++;}
if (NKOriY-area<poseOrt_y && NKOriY+area>poseOrt_y) {score++;}
if (NKOriZ-area<poseOrt_z && NKOriZ+area>poseOrt_z) {score++;}
textSize(60);
text(score+"\n"+scoreString, 30, 100);
if (frameCount >=90) {
result();
frameCount =0;
score = 0;
}
} else {
frameCount =0;
score = 0;
if(gameMode){
comparison();
println("GameMode");
//println("videoframe : " + videoFrame + " Mtime : "+round(myMovie.time()*10)/10.0 + " MDuration : "+ floor(myMovie.duration()*10)/10.0);
}
//exportFiles();///saveStringfile

//println("FC in draw: "+frameCount);
//println("FRAMECOUNT : "+frameCount+" SCORE : "+score);
saveTable(infoTable, "table.csv");//,"html");
}

float area =0.2; //threshold
float ori = 0.01;
void loadReferTable() {
//referTable = loadTable("NikkiVideoData.csv","header");
//println(referTable.getRowCount() + "total rows in table");
for (TableRow row : referTable.rows()) {
NKframe = row.getInt("frameCount");
NKBrowL = row.getFloat("LBrowH");
NKBrowR = row.getFloat("RBrowH");
NKEyeL = row.getFloat("LEyeH");
NKEyeR = row.getFloat("REyeH");
NKNose = row.getFloat("nose");
NKMouthH = row.getFloat("MouseH");
NKMouthW = row.getFloat("MouseW");
NKOriX = row.getFloat("OriX");
NKOriY = row.getFloat("OriY");
NKOriZ = row.getFloat("OriZ");
println("DATA FROM THE CSV : "+NKOriZ);
if (NKBrowL-area <leftEyebrowHeight && NKBrowL+area >leftEyebrowHeight) {
score++;
}
if (NKBrowR-area<rightEyebrowHeight && NKBrowR+area >rightEyebrowHeight) {
score++;
}
if (NKEyeL-area< eyeLeftHeight && NKEyeL+area> eyeLeftHeight) {
score++;
}
if (NKEyeR-area< eyeRightHeight && NKEyeR+area >eyeRightHeight ) {
score++;
}
if (NKNose-area< nostrilHeight && NKNose+area >nostrilHeight) {
score++;
}
if (NKMouthH-area< mouthHeight && NKMouthH+area> mouthHeight) {
score++;
}
if (NKMouthW-area< mouthWidth && NKMouthW+area> mouthWidth) {
score++;
}
if (NKOriX-ori<poseOrt_x && NKOriX+ori>poseOrt_x) {
score++;
}
if (NKOriY-ori<poseOrt_y && NKOriY+ori>poseOrt_y) {
score++;
}
if (NKOriZ-ori<poseOrt_z && NKOriZ+ori>poseOrt_z) {
score++;
}
}
}
/*void dataComparsion(Table table){
}*/
void result() {
if (score < 300) {
//text(score+"You are such a mundane person.",100,150);
//text();
scoreString = "You are such a mundane person.";
} else if (score>=300 && score<=450) {
println(score+"Your acting is ok but still too boring.");
//text(score+"Your acting is ok but still too boring.",100,150);
scoreString = "Your acting is ok but still too boring.";
} else if ( score>450 & score <=650) {
println(score+"You are kidda fancy person.");
scoreString = "You are kidda fancy person.";
//text(score+"You are kidda fancy person.",100,150);
} else if ( score>650 & score <=800) {
println(score+"Ahrr.. May be you can be a star one day.");
scoreString = "Ahrr.. May be you can be a star one day.";
//text(score+"Ahrr.. May be you can be a star one day.",100,150);
} else if ( score>800 ) {
println(score+"Yeah... you do good. Ready for a celeb life?");
scoreString = "Yeah... you do good. Ready for a celeb life?";
//text(score+"Yeah... you do good. Ready for a celeb life?",100,150);
}
}
void Score() {
//saveTable(infoTable, "table.csv");//,"html");
}
Loading