-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyolo.js
43 lines (42 loc) · 928 Bytes
/
yolo.js
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
console.log("BC");
let video;
let yolo;
let results;
function setup() {
createCanvas(1280, 720);
video = createCapture(VIDEO);
yolo = ml5.YOLO(video, onReady);
}
function onReady() {
console.log("OK");
detect();
}
function detect(){
yolo.detect((err,res) => {
console.log(res.length);
if(res.length>0){
results = res;
console.log(results);
detect();
}
});
}
function draw() {
image(video, 0, 0,width,height);
if(results){
for(let i=0;i<results.length;i++){
noStroke();
fill(159,79,187);
text(results[i].label,
results[i].x*width,
results[i].y*height +20);
noFill();
strokeWeight(5);
stroke(0,255,0);
rect(results[i].x*width,
results[i].y*height,
results[i].w*width,
results[i].h*height);
}
}
}