-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathindex.html
186 lines (153 loc) · 5.15 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="content-language" content="en-EN" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>GLANCE TRACKER - INTEGRATION DEMO</title>
<!-- WE INCLUDE THE MAIN SCRIPT -->
<script src="../../dist/jeelizGlanceTracker.js"></script>
<script>
"use strict"
const _states = {
idle: 0,
loading: 1,
enabled: 2,
disabled: 3
};
let _state = _states.idle;
function toggle_canvasContainer(isShow){
const DOMcanvasContainer = document.getElementById('glanceTrackerCanvasContainer');
if (!DOMcanvasContainer) return;
DOMcanvasContainer.style.opacity = (isShow) ? '1' : '0';
};
function toggle_glanceTracking(event){ // the user clic on the button
switch(_state){
case _states.idle:
init_glanceTracking();
break;
case _states.loading:
break;
case _states.enabled:
JEELIZGLANCETRACKER.toggle_pause(true, true);
toggle_canvasContainer(false);
_state = _states.disabled;
break;
case _states.disabled:
JEELIZGLANCETRACKER.toggle_pause(false, true);
toggle_canvasContainer(true);
_state = _states.enabled;
break;
}
update_button();
}; //end toggle_glanceTracking()
function update_button(){
const DOMbutton = document.getElementById('toggleGlanceTracking');
let buttonText = 'undefined';
switch(_state){
case _states.idle:
case _states.disabled:
buttonText = 'Enable glance tracking';
break;
case _states.loading:
buttonText = 'LOADING...';
break;
case _states.enabled:
buttonText = 'Disable glance tracking';
break;
}
DOMbutton.innerHTML = buttonText;
}; //end update_button()
function init_glanceTracking(){
_state = _states.loading;
JEELIZGLANCETRACKER.init({
callbackTrack: function(isDetected){
console.log('DETECTION changed! isDetected = ', isDetected);
const DOMvideo = document.getElementById('jeeVideo');
if (!DOMvideo) return;
if (isDetected){
DOMvideo.play();
toggle_canvasContainer(false);
} else {
DOMvideo.pause();
toggle_canvasContainer(true);
}
},
callbackReady: function(error){
if (error){
alert('AN ERROR HAPPENS :( CODE =' + error);
return;
}
console.log('JEELIZGLANCETRACKER is READY YEAH !');
_state = _states.enabled;
update_button();
toggle_canvasContainer(true);
},
isDisplayVideo: true,
canvasId: 'glanceTrackerCanvas',
NNCPath: '../../dist/' //where is NNC.json ?
}); //end JEELIZGLANCETRACKER.init call
}; //end init()
</script>
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans" />
<style type='text/css'>
a {color: #7af; text-decoration: none; font-weight: bold}
a:hover {color: white;}
body {
background-color: black;
margin: 0px;
text-align: center;
font-family: Helvetica Neu, Arial, sans-serif;
}
button {
cursor: pointer;
font-size: 12pt;
width: 300px;
margin: 1em;
}
#glanceTrackerCanvasContainer {
background-color: #666;
font-size: 10pt;
text-align: center;
border: 1px solid white;
z-index: 10;
position: fixed;
bottom: 0px;
right: 0px;
opacity: 0;
transition-duration: 1000ms;
}
#glanceTrackerCanvas {
max-width: 25vmin;
}
#jeeVideo {
max-width: 100%; /*for mobiles */
}
.credits {
max-width: 640px;
text-align: left;
display: inline-block;
}
</style>
</head>
<body onload='update_button()' style='color: white'>
<h1>Jeeliz Glance Tracker integration demo</h1>
<button onclick='toggle_glanceTracking(event)' id='toggleGlanceTracking'></button><br/>
<video autoplay loop id='jeeVideo' controls>
<source src="video.mp4" type="video/mp4" />
<source src="video.ogv" type="video/ogg" />
</video>
<br/><div class='credits'>
<h2>Credits</h2>
<ul>
<li>JEELIZ: Deep learning networks in browser - <a href='https://jeeliz.com' target='_blank'>jeeliz.com</a> - Twitter: <a href='https://twitter.com/Jeeliz_AR' target='_blank'>@Jeeliz_AR</a>
<li>Github of the project: <a href='https://github.com/jeeliz/jeelizGlanceTracker' target='_blank'>jeeliz/jeelizGlanceTracker</a>
<li>Video used for this demo: Big Buck Bunny by the <a href='https://www.blender.org' target='_blank'>Blender Foundation</a>
</ul>
</div>
<div id='glanceTrackerCanvasContainer'>
Tracking your glance ...<br/>
<canvas id='glanceTrackerCanvas'></canvas>
</div>
</body>
</html>