-
Notifications
You must be signed in to change notification settings - Fork 0
/
TrackedFace.pde
71 lines (54 loc) · 1.21 KB
/
TrackedFace.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
final int MLOST_FRAME=3;
class TrackedFace{
PVector position,sizee;
float cur_happy;
float happy_score;
int mlost_track;
TrackedFace(PVector position_,PVector size_,float happy_){
position=position_;
sizee=size_;
cur_happy=happy_;
happy_score=0;
mlost_track=0;
}
void drawDebug(){
if(mlost_track>0) return;
pushMatrix();
translate(position.x,position.y);
if(cur_happy>0.5) image(smile_image[2],0,0);
else if(cur_happy>0.2) image(smile_image[1],0,0);
else image(smile_image[0],0,0);
// text(happy_score,0,0);
if(DEBUG_MODE){
pushStyle();
stroke(255,0,0);
noFill();
rect(0,0,sizee.x,sizee.y);
popStyle();
}
popMatrix();
}
void updateHappyScore(float score){
cur_happy=score;
// happy_score+=score;
}
void updateGeometry(PVector pos_,PVector sizee_){
if(pos_.x==0 && pos_.y==0){
mlost_track++;
// return;
}else{
mlost_track=0;
}
PVector scaled_pos=pos_.get();
scaled_pos.x*=Kinect_Scale.x;
scaled_pos.y*=Kinect_Scale.y;
scaled_pos.add(Kinect_Position);
position=scaled_pos;
sizee=sizee_.get();
sizee.x*=Kinect_Scale.x;
sizee.y*=Kinect_Scale.y;
}
boolean hasLostTrack(){
return mlost_track>MLOST_FRAME;
}
}