2. FAAST 下載/使用 (如果出現msvcp110.dll問題, 就下載Viscal Studio 2012 Redistributable檔) 2.1 試著寫 FAAST的手勢判斷
目標: kinect的一個作品: 一馬當先(手舉起來/手往右.手往左)
1. 手舉起來
程式碼:
int stage=0, hourseID=0, oldTime=0;
void setup(){
size(600,400);
textSize(40);
}
void draw(){
if(stage==0){
background(0);
text("Wait for your Input/UP", 100, 100);
}else if(stage==1){
background(255,0,0);
text("Select your hourse", 100,100);
text("Now Select ",hourseID, 200,200);
oldTime=millis();
}else if(stage==2){
background(0,255,0);
text("Run Run my hourse"+hourseID,100,100);
int nowTime=millis();
int t=int((nowTime-oldTime)/10000);
text("Running "+t, 200,200);
if(t>20) stage=3;
}else if(stage==3){
background(0,0,255);
}else background(255,255,0);
}
void keyPressed(){
if(keyCode==UP){
println("UP");
if(stage==0) stage=1;
else if(stage==1) stage=2;
else if(stage==2) stage=3;
}
if(keyCode==RIGHT) hourseID=(hourseID-1)%4;
if(keyCode==LEFT) hourseID=(hourseID-1+4)%4;
}







沒有留言:
張貼留言