forked from atduskgreg/opencv-processing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFace.pde
More file actions
64 lines (52 loc) · 1.24 KB
/
Face.pde
File metadata and controls
64 lines (52 loc) · 1.24 KB
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
/**
* Which Face Is Which
* Daniel Shiffman
* http://shiffman.net/2011/04/26/opencv-matching-faces-over-time/
*
* Modified by Jordi Tost (call the constructor specifying an ID)
* @updated: 01/10/2014
*/
class Face {
// A Rectangle
Rectangle r;
// Am I available to be matched?
boolean available;
// Should I be deleted?
boolean delete;
// How long should I live if I have disappeared?
int timer = 127;
// Assign a number to each face
int id;
// Make me
Face(int newID, int x, int y, int w, int h) {
r = new Rectangle(x,y,w,h);
available = true;
delete = false;
id = newID;
}
// Show me
void display() {
fill(0,0,255,timer);
stroke(0,0,255);
rect(r.x,r.y,r.width, r.height);
//rect(r.x*scl,r.y*scl,r.width*scl, r.height*scl);
fill(255,timer*2);
text(""+id,r.x+10,r.y+30);
//text(""+id,r.x*scl+10,r.y*scl+30);
//text(""+id,r.x*scl+10,r.y*scl+30);
}
// Give me a new location / size
// Oooh, it would be nice to lerp here!
void update(Rectangle newR) {
r = (Rectangle) newR.clone();
}
// Count me down, I am gone
void countDown() {
timer--;
}
// I am deed, delete me
boolean dead() {
if (timer < 0) return true;
return false;
}
}