-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.html
65 lines (61 loc) · 1.89 KB
/
example.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
<!doctype html>
<html lang="en">
<head>
<title>Face tracker</title>
<meta charset="utf-8">
<style>
#container {
position : relative;
}
#canvas {
position : absolute;
left : 0;
top : 0;
}
</style>
</head>
<body>
<script src="./js/utils.js"></script>
<script src="./js/clmtrackr.js"></script>
<script src="./models/model_pca_20_svm.js"></script>
<div id="content">
<h2>Example</h2>
<div id="container">
<video id="video" width="368" height="288" autoplay loop>
<source src="./media/franck.ogv" type="video/ogg"/>
</video>
<canvas id="canvas" width="368" height="288"></canvas>
</div>
<p>Printing coordinates of the first 10 points in facial features:</p>
<p id="positions"></p>
<script>
var videoInput = document.getElementById('video');
var ctracker = new clm.tracker();
ctracker.init(pModel);
ctracker.start(videoInput);
function positionLoop() {
requestAnimationFrame(positionLoop);
var positions = ctracker.getCurrentPosition();
// do something with the positions ...
// print the positions
var positionString = "";
if (positions) {
for (var p = 0;p < 10;p++) {
positionString += "featurepoint "+p+" : ["+positions[p][0].toFixed(2)+","+positions[p][1].toFixed(2)+"]<br/>";
}
document.getElementById('positions').innerHTML = positionString;
}
}
positionLoop();
var canvasInput = document.getElementById('canvas');
var cc = canvasInput.getContext('2d');
function drawLoop() {
requestAnimationFrame(drawLoop);
cc.clearRect(0, 0, canvasInput.width, canvasInput.height);
ctracker.draw(canvasInput);
}
drawLoop();
</script>
</div>
</body>
</html>