-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpotato.html
More file actions
78 lines (57 loc) · 2.02 KB
/
potato.html
File metadata and controls
78 lines (57 loc) · 2.02 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
h1 {
font-size: 3em;
position: absolute;
transition: all .5s;
transform: translate(-50%, -50%);
}
</style>
</head>
<body>
<h1 data-part="nose">👃</h1>
<h1 data-part="leftEye">👁</h1>
<h1 data-part="rightEye">👁</h1>
<h1 data-part="leftEar">🌽</h1>
<h1 data-part="rightEar">👂</h1>
<h1 data-part="leftShoulder">🦿</h1>
<h1 data-part="rightShoulder">🐘</h1>
<h1 data-part="leftElbow"><</h1>
<h1 data-part="rightElbow">></h1>
<h1 data-part="leftWrist">🖐</h1>
<h1 data-part="rightWrist">✊</h1>
<h1 data-part="leftHip">[--</h1>
<h1 data-part="rightHip">--]</h1>
<h1 data-part="leftKnee">🍔</h1>
<h1 data-part="rightKnee">🍟</h1>
<h1 data-part="leftAnkle">🦶</h1>
<h1 data-part="rightAnkle">⚽</h1>
<script src="https://unpkg.com/@tensorflow/tfjs"></script>
<script src="https://unpkg.com/@tensorflow-models/posenet">
</script>
<script type="module">
import { PoseStream } from './poses.js';
// Video stream - in progress
const stream = new PoseStream({ delay: 0 });
stream.start()
stream.video.style.display = 'none'
stream.addEventListener('pose', (event) => {
for (const element of document.querySelectorAll('[data-part]')) {
for (const { part, position } of event.data.keypoints) {
if (element.dataset.part == part) {
let { x, y } = position
element.style.left = ((x / stream.video.width) * 100) + '%'
element.style.top = ((y / stream.video.height) * 100) + '%'
}
}
}
})
</script>
</body>
</html>