-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.html
69 lines (60 loc) · 1.84 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<title>AI hand detection</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<link rel="stylesheet" href="style.css">
<script src="https://unpkg.com/ml5@0.12.2/dist/ml5.min.js" type="text/javascript"></script>
</head>
<body>
<h2 id="loadingText">Loading...</h2>
<!-- video with size of 0px because of chrome -->
<video playsinline autoplay muted controls="true" id="video"></video>
<br><br>
<canvas id="c1" class="mirror"></canvas>
<br><br>
<table>
<tr>
<td>AI:</td>
<td>
<div class="switch">
<label>
Off
<input type="checkbox" id="ai" disabled>
<span class="lever"></span>
On
</label>
</div>
</td>
</tr>
<tr>
<td>FPS:</td>
<td>
<p class="range-field">
<input type="range" id="fps" min="1" max="40" value="30">
</p>
</td>
</tr>
</table>
<!-- is needed to prevent lag at first predict -->
<img src="mouse/pointer.png" id="img" style="display: none;">
<script>
var modelIsLoaded = false;
// Create a handpose method
const handpose = ml5.handpose({}, {}, modelLoaded);
// When the model is loaded
function modelLoaded() {
let img = document.getElementById("img");
handpose.predict(img, results => {
console.log(results)
console.log("Model Loaded!");
modelIsLoaded = true;
});
}
</script>
<script src="video.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
</body>
</html>