-
Notifications
You must be signed in to change notification settings - Fork 0
/
clm_video_responses.html
249 lines (221 loc) · 7.74 KB
/
clm_video_responses.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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<!doctype html>
<html lang="en">
<head>
<title>Face tracker</title>
<meta charset="utf-8">
<link href="./styles/bootstrap.min.css" rel="stylesheet" type="text/css">
<style>
@import url(https://fonts.googleapis.com/css?family=Lato:300italic,700italic,300,700);
body {
font-family: 'Lato';
background-color: #f0f0f0;
margin: 0px auto;
max-width: 1150px;
}
#overlay {
position: absolute;
top: 0px;
left: 0px;
-o-transform : scaleX(-1);
-webkit-transform : scaleX(-1);
transform : scaleX(-1);
-ms-filter : fliph; /*IE*/
filter : fliph; /*IE*/
}
#videoel {
-o-transform : scaleX(-1);
-webkit-transform : scaleX(-1);
transform : scaleX(-1);
-ms-filter : fliph; /*IE*/
filter : fliph; /*IE*/
}
#container {
position : relative;
width : 370px;
/*margin : 0px auto;*/
}
#content {
margin-top : 70px;
margin-left : 100px;
margin-right : 100px;
max-width: 950px;
}
#sketch {
display: none;
}
#filter {
display: none;
}
h2 {
font-weight : 400;
}
.nogum {
display : none;
}
.btn {
font-family: 'Lato';
font-size: 16px;
}
.hide {
display : none;
}
.nohide {
display : block;
}
</style>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-32642923-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<script src="./js/utils.js"></script>
<script src="./js/numeric-1.2.6.min.js"></script>
<script src="./js/mosse.js"></script>
<script src="./js/jsfeat-min.js"></script>
<script src="./js/frontalface.js"></script>
<script src="./js/jsfeat_detect.js"></script>
<script src="./js/left_eye_filter.js"></script>
<script src="./js/right_eye_filter.js"></script>
<script src="./js/nose_filter.js"></script>
<script src="./models/model_pca_20_svm.js"></script>
<script src="./js/clm.js"></script>
<script src="./js/svmfilter_webgl.js"></script>
<script src="./js/svmfilter_fft.js"></script>
<script src="./js/mossefilter.js"></script>
<script src="./js/Stats.js"></script>
<div id="content">
<h2>Response types example</h2>
<div id="container">
<video id="videoel" width="400" height="300" preload="auto" loop>
<!--<video id="videoel" width="320" height="240" preload="auto">-->
<!--<source src="./media/franck.ogv" type="video/ogg"/>-->
</video>
<canvas id="overlay" width="400" height="300"></canvas>
</div>
<br/>
<input class="btn" type="button" value="wait, loading video" disabled="disabled" onclick="startVideo()" id="startbutton"></input>
<p>Select different responses modes:
<select name="mode" id="selectmode">
<option value="0">Type: "single", List: ["raw"]</option>
<option value="1">Type: "single", List: ["lbp"]</option>
<option value="2">Type: "single", List: ["sobel"]</option>
<option value="3">Type: "cycle", List: ["raw", "lbp"]</option>
<option value="4">Type: "cycle", List: ["lbp", "sobel"]</option>
<option value="5">Type: "blend", List: ["raw", "lbp"]</option>
<option value="6">Type: "blend", List: ["lbp", "sobel"]</option>
</select></p>
<div id="text">
<p>This is an example of different types of responses. For more details, have a look at <a href="http://auduno.github.io/clmtrackr/docs/reference.html#responses">the reference</a></p>
</div>
</div>
<a href="https://github.com/auduno/clmtrackr"><img style="position: absolute; top: 0; left: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_left_green_007200.png" alt="Fork me on GitHub"></a>
<script>
var vid = document.getElementById('videoel');
var overlay = document.getElementById('overlay');
var overlayCC = overlay.getContext('2d');
var ctrack = new clm.tracker({useWebGL : true});
ctrack.init(pModel);
stats = new Stats();
stats.domElement.style.position = 'absolute';
stats.domElement.style.top = '0px';
document.getElementById('container').appendChild( stats.domElement );
function enablestart() {
var startbutton = document.getElementById('startbutton');
startbutton.value = "start";
startbutton.disabled = null;
}
var insertAltVideo = function(video) {
if (supports_video()) {
if (supports_ogg_theora_video()) {
video.src = "./media/cap12_edit.ogv";
} else if (supports_h264_baseline_video()) {
video.src = "./media/cap12_edit.mp4";
} else {
return false;
}
//video.play();
return true;
} else return false;
}
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
window.URL = window.URL || window.webkitURL || window.msURL || window.mozURL;
// check for camerasupport
if (navigator.getUserMedia) {
// set up stream
var videoSelector = {video : true};
if (window.navigator.appVersion.match(/Chrome\/(.*?) /)) {
var chromeVersion = parseInt(window.navigator.appVersion.match(/Chrome\/(\d+)\./)[1], 10);
if (chromeVersion < 20) {
videoSelector = "video";
}
};
navigator.getUserMedia(videoSelector, function( stream ) {
if (vid.mozCaptureStream) {
vid.mozSrcObject = stream;
} else {
vid.src = (window.URL && window.URL.createObjectURL(stream)) || stream;
}
vid.play();
}, function() {
insertAltVideo(vid);
document.getElementById('gum').className = "hide";
document.getElementById('nogum').className = "nohide";
alert("There was some problem trying to fetch video from your webcam, using a fallback video instead.");
});
} else {
insertAltVideo(vid);
document.getElementById('gum').className = "hide";
document.getElementById('nogum').className = "nohide";
alert("Your browser does not seem to support getUserMedia, using a fallback video instead.");
}
vid.addEventListener('canplay', enablestart, false);
function startVideo() {
// start video
vid.play();
// start tracking
ctrack.start(vid);
// start loop to draw face
drawLoop();
}
function drawLoop() {
requestAnimFrame(drawLoop);
overlayCC.clearRect(0, 0, 400, 300);
//psrElement.innerHTML = "score :" + ctrack.getScore().toFixed(4);
if (ctrack.getCurrentPosition()) {
ctrack.draw(overlay);
}
}
// update stats on every iteration
document.addEventListener('clmtrackrIteration', function(event) {
stats.update();
}, false);
function switchMode(el) {
var mode = parseInt(el.target.value, 10);
if (mode == 0) {
ctrack.setResponseMode("single",["raw"]);
} else if (mode == 1) {
ctrack.setResponseMode("single",["lbp"]);
} else if (mode == 2) {
ctrack.setResponseMode("single",["sobel"]);
} else if (mode == 3) {
ctrack.setResponseMode("cycle",["raw", "lbp"]);
} else if (mode == 4) {
ctrack.setResponseMode("cycle",["sobel", "lbp"]);
} else if (mode == 5) {
ctrack.setResponseMode("blend",["raw", "lbp"]);
} else if (mode == 6) {
ctrack.setResponseMode("blend",["sobel", "lbp"]);
}
};
document.getElementById('selectmode').addEventListener('change', switchMode, false);
</script>
</div>
</body>
</html>