-
Notifications
You must be signed in to change notification settings - Fork 0
/
static_face_detect.pde
62 lines (52 loc) · 1.25 KB
/
static_face_detect.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
import processing.video.*;
// this library contains graphics & shapes
import java.awt.Rectangle;
// opencv is a computer vision library
import gab.opencv.*;
// declare variable types
PImage pic;
OpenCV opencv;
Rectangle[] faces;
Rectangle[] eyes;
color c;
float r, g, b;
boolean pressed;
void setup(){
opencv = new OpenCV(this, "afghan.jpg");
size(200, 300);
opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);
opencv.loadCascade(OpenCV.CASCADE_EYE);
faces = opencv.detect();
eyes = opencv.detect();
pic = loadImage("afghan.jpg");
pic.loadPixels();
}
void draw(){
image(opencv.getInput(), 0, 0);
noFill();
// green
stroke(0, 255, 0);
strokeWeight(3);
// display rectangles around all detected faces
for (int i = 0; i < faces.length; i++){
rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height);
}
stroke(0, 0, 255);
strokeWeight(2);
for(int i = 0; i < eyes.length; i++){
rect(eyes[i].x, eyes[i].y, eyes[i].width, eyes[i].height);
}
c = get(mouseX,mouseY);
r = red(c);
g = green(c);
b = blue(c);
print(r,g,b);
printArray(faces);
printArray(eyes);
if (pressed){
text("X: " + mouseX + " Y: " + mouseY,10,15);
}
}
void mousePressed(){
pressed = true;
}