-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug.js
38 lines (30 loc) · 861 Bytes
/
debug.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
let poses = [];
let specialPoints = ["rightWrist", "leftWrist"];
function setPoses(p) {
poses = p;
}
function drawPoseNet() {
for (const pose of poses) {
drawKeyPoint(pose);
drawSkeleton(pose);
}
}
function drawKeyPoint(pose) {
for (let keypoint of pose.pose.keypoints) {
const hasKeyPoint = specialPoints.findIndex((element) => element == keypoint.part) == -1
if (hasKeyPoint)
fill(255, 0, 0);
else
fill(0, 255, 0);
noStroke();
ellipse(keypoint.position.x, keypoint.position.y, 10, 10);
}
}
function drawSkeleton(pose) {
for (const skeleton of pose.skeleton) {
let partA = skeleton[0];
let partB = skeleton[1];
stroke(255, 0, 0);
line(partA.position.x, partA.position.y, partB.position.x, partB.position.y);
}
}