-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch.js
59 lines (45 loc) · 1.36 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
let capture;
let posenet;
let noseX, noseY;
let reyeX, reyeY;
let leyeX, leyeY;
let singlePose, skeleton;
let actor_img;
let specs, smoke;
function setup() {
createCanvas(800, 500);
capture = createCapture(VIDEO)
capture.hide();
posenet = ml5.poseNet(capture, modelLoaded);
posenet.on('pose', receivedPoses);
actor_img = loadImage('images/shahrukh.png');
specs = loadImage('images/spects.png');
smoke = loadImage('images/cigar.png');
}
function receivedPoses(poses) {
console.log(poses);
if (poses.length > 0) {
singlePose = poses[0].pose;
skeleton = poses[0].skeleton;
}
}
function modelLoaded() {
console.log('Model has loaded');
}
function draw() {
// images and videos(webcam)
image(capture, 0, 0);
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, 20);
}
stroke(255, 255, 255);
strokeWeight(5);
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)
}
//image(specs,singlePose.nose.x-35,singlePose.nose.y-50,80,80);
//image(smoke,singlePose.nose.x-35,singlePose.nose.y+10,40,40);
}
}