-
Notifications
You must be signed in to change notification settings - Fork 22
/
RealSenseYoloDetector.pde
62 lines (45 loc) · 1.32 KB
/
RealSenseYoloDetector.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 ch.bildspur.vision.DeepVision;
import ch.bildspur.vision.YOLONetwork;
import ch.bildspur.vision.result.*;
import ch.bildspur.realsense.*;
RealSenseCamera camera = new RealSenseCamera(this);
DeepVision vision = new DeepVision(this);
YOLONetwork net;
ResultList<ObjectDetectionResult> result;
void setup()
{
size(848, 480);
colorMode(HSB, 360, 100, 100);
println("creating network...");
net = vision.createYOLOv4Tiny();
println("loading model...");
net.setup();
net.setConfidenceThreshold(0.1f);
net.setSkipNMS(false);
println("starting camera...");
if (camera.getDeviceCount() < 1) {
println("no camera connected!");
exit();
}
camera.enableColorStream(848, 480, 30);
camera.start();
}
void draw()
{
background(55);
// read frames
camera.readFrames();
// show color image
PImage input = camera.getColorImage();
result = net.run(input);
image(input, 0, 0);
noFill();
strokeWeight(2f);
for (ObjectDetectionResult detection : result) {
stroke(round(360.0f * (float) detection.getClassId() / net.getLabels().size()), 75, 100);
rect(detection.getX(), detection.getY(), detection.getWidth(), detection.getHeight());
textSize(15);
text(detection.getClassName(), detection.getX(), detection.getY());
}
surface.setTitle("YOLO Test - FPS: " + Math.round(frameRate));
}