-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathHandDetectorWebcam.pde
52 lines (37 loc) · 1.01 KB
/
HandDetectorWebcam.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
import ch.bildspur.vision.*;
import ch.bildspur.vision.result.*;
import processing.video.Capture;
Capture cam;
DeepVision vision = new DeepVision(this);
SSDMobileNetwork network;
ResultList<ObjectDetectionResult> detections;
public void setup() {
size(640, 480);
colorMode(HSB, 360, 100, 100);
println("creating network...");
network = vision.createHandDetector();
println("loading model...");
network.setup();
network.setConfidenceThreshold(0.5);
println("setup camera...");
cam = new Capture(this, "pipeline:autovideosrc");
cam.start();
}
public void draw() {
background(55);
if (cam.available()) {
cam.read();
}
image(cam, 0, 0);
if(cam.width == 0) {
return;
}
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("Hand Detection Test - FPS: " + Math.round(frameRate));
}