-
Notifications
You must be signed in to change notification settings - Fork 0
/
sketch.js
44 lines (38 loc) · 1.07 KB
/
sketch.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
44
let capture;
let posenet;
let noseX, noseY;
let leyeX, leyeY;
let reyeX, reyeY;
let singlePose, skeleton;
function setup(){
createCanvas(800, 500);
capture = createCapture(VIDEO);
capture.hide();
posenet = ml5.poseNet(capture, modelLoaded);
posenet.on('pose', recievedposes);
}
function recievedposes(poses){
console.log(poses);
if(poses.length>0){
singlePose = poses[0].pose;
skeleton = poses[0].skeleton;
}
}
function modelLoaded(){
console.log("Model Loaded Succesfully");
}
function draw(){
image(capture, 0,0,800,500);
fill(255,0,0);
if(singlePose){
for(let i=0; i<singlePose.keypoints.length;i++){
ellipse(singlePose.keypoints[i].position.x, singlePose.keypoints[i].position.y, 10);
}
stroke(0,0,0);
strokeWeight(3);
for(let j=0; j<skeleton.length; j++){
line(skeleton[j][0].position.x, skeleton[j][0].position.y,
skeleton[j][1].position.x, skeleton[j][1].position.y, 10);
}
}
}