forked from cansik/deep-vision-processing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFaceDetectorCNNWebcam.pde
48 lines (35 loc) · 1009 Bytes
/
FaceDetectorCNNWebcam.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
import ch.bildspur.vision.*;
import ch.bildspur.vision.result.*;
import processing.video.Capture;
Capture cam;
DeepVision vision;
ULFGFaceDetectionNetwork network;
ResultList<ObjectDetectionResult> detections;
public void setup() {
size(640, 480, FX2D);
colorMode(HSB, 360, 100, 100);
println("creating network...");
vision = new DeepVision(this);
network = vision.createULFGFaceDetectorRFB320();
println("loading model...");
network.setup();
println("setup camera...");
String[] cams = Capture.list();
cam = new Capture(this, cams[0]);
cam.start();
}
public void draw() {
background(55);
if (cam.available()) {
cam.read();
}
image(cam, 0, 0);
detections = network.run(cam);
noFill();
strokeWeight(2f);
stroke(200, 80, 100);
for (ObjectDetectionResult detection : detections) {
rect(detection.getX(), detection.getY(), detection.getWidth(), detection.getHeight());
}
surface.setTitle("Face Recognition Test - FPS: " + Math.round(frameRate));
}