-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathYOLODetectObjects.pde
42 lines (29 loc) · 926 Bytes
/
YOLODetectObjects.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
import ch.bildspur.vision.*;
import ch.bildspur.vision.result.*;
DeepVision deepVision = new DeepVision(this);
YOLONetwork yolo;
ResultList<ObjectDetectionResult> detections;
PImage image;
public void setup() {
size(640, 480);
colorMode(HSB, 360, 100, 100);
image = loadImage("hk.jpg");
println("creating model...");
yolo = deepVision.createYOLOv4();
println("loading yolo model...");
yolo.setup();
println("inferencing...");
yolo.setConfidenceThreshold(0.3f);
detections = yolo.run(image);
}
public void draw() {
background(55);
image(image, 0, 0);
noFill();
strokeWeight(2f);
for (ObjectDetectionResult detection : detections) {
stroke((int)(360.0 / yolo.getLabels().size() * detection.getClassId()), 80, 100);
rect(detection.getX(), detection.getY(), detection.getWidth(), detection.getHeight());
}
surface.setTitle("YOLO Test - FPS: " + Math.round(frameRate));
}