-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
61 lines (48 loc) · 1.82 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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fake happy - smiling face with camera</title>
<link rel="stylesheet" href="./style.css">
<link rel="apple-touch-icon" sizes="180x180" href="./apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="./favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="./favicon-16x16.png">
<link rel="manifest" href="./manifest.json">
<meta name="theme-color" content="#ffffff">
<script src="./vendor/tracking-min.js"></script>
<script src="./vendor/face-min.js"></script>
</head>
<body>
<header>
<p>Oh please, I bet everybody here is <a href="https://www.youtube.com/watch?v=w8vsuOXZBXc" target="_blank">fake happy</a> too</p>
</header>
<div class="demo-frame">
<div class="demo-container">
<video id="video" width="320" height="240" preload autoplay loop muted></video>
<canvas id="canvas" width="320" height="240"></canvas>
</div>
</div>
<script>
window.onload = function() {
navigator.mediaDevices.getUserMedia({video: {facingMode: 'user'}}).then(function (stream) {
document.getElementById('video').srcObject = stream;
});
var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d');
var img = new Image();
img.src = './fakesmile.png';
var tracker = new tracking.ObjectTracker('face');
tracker.setInitialScale(4);
tracker.setStepSize(2.3);
tracker.setEdgesDensity(0.1);
tracking.track('#video', tracker, { camera: true });
tracker.on('track', function(event) {
context.clearRect(0, 0, canvas.width, canvas.height);
event.data.forEach(function(rect) {
context.drawImage(img, rect.x, rect.y, rect.width, rect.height);
});
});
};
</script>
</body>
</html>