forked from salazarm/CaptchaCaptcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlock.html.orig
313 lines (217 loc) · 7.96 KB
/
lock.html.orig
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
</style>
<head>
<style>
body {
margin: 0px;
padding: 0px;
}
#myCanvas {
border: 1px solid #9C9898;
}
canvas { display:block; border:1px solid #aaa; margin:1em auto; background:#eee; }
</style>
<meta charset="utf-8">
<!--
<script src="//maps.google.com/maps?file=api&v=3&sensor=false&key=AIzaSyAHFGS76spQ8SVcsk2Rq3UAZH3RZqo80TE"
type="text/javascript"></script>
!-->
<script src="http://maps.googleapis.com/maps/api/js?v=3&sensor=false"></script>
<title>Full Immersion: HELLO WORLD... a.k.a. Google Holla At ME</title>
<script src="http://dl.dropbox.com/u/110033260/compatibility.js"></script>
<script src="http://dl.dropbox.com/u/110033260/smoother.js"></script>
<script src="http://dl.dropbox.com/u/110033260/objectdetect.js"></script>
<script src="http://dl.dropbox.com/u/110033260/objectdetect.frontalface.js"></script>
<script src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
<script src="http://dl.dropbox.com/u/110033260/jquery.objectdetect.js"></script>
<script>
var smoother = new Smoother(0.5, [0, 0, 0, 0, 0]);
var initial_heading=360;
var initial_zoom=1;
var initial_pitch=0;
var myPano;
var sv;
jQuery.extend({
insertArray: function(array, index, items, flattenIt){
if ($.isArray(array)){
array.splice(index,0,items);
if(flattenIt) {return $.flattenArray(array);}
return array;
}
return(array);
}
});
function initialize(){
}
$(window).load(function() {
var video = $("#video").get(0);
try {
compatibility.getUserMedia({video: true}, function(stream) {
try {
video.src = compatibility.URL.createObjectURL(stream);
} catch (error) {
video.src = stream;
}
video.play();
compatibility.requestAnimationFrame(tick);
}, function (error) {
alert("WebRTC not available");
});
} catch (error) {
alert(error);
}
function tick() {
compatibility.requestAnimationFrame(tick);
if (video.readyState === video.HAVE_ENOUGH_DATA) {
$(video).objectdetect("all", {scaleMin: 3, scaleFactor: 1.1, classifier: objectdetect.frontalface}, function(coords) {
if (coords[0]) {
coords = smoother.smooth(coords[0]);
video_ratio=document.getElementById('video').style.width;
if(video_ratio.indexOf("px")!=-1){ //found pixel definition
video_ratio.replace("px","");
video_ratio=parseInt(video_ratio);
video_ratio=video_ratio/video.videoWidth;
}else{
//don't specify percentages... this section still broken
video_ratio.replace("%","");
video_ratio=parseInt(video_ratio);
video_ratio=video_ratio*screen.width/100;
video_ratio=video_ratio/video.videoWidth;
}
$("#glasses").css({
"left": ~~((coords[0] + coords[2] * 1.0/8)*video_ratio + $(video).offset().left) + "px",
"top": ~~((coords[1] + coords[3] * 0.8/8)*video_ratio + $(video).offset().top) + "px",
"width": ~~((coords[2] * 6/8)*video_ratio) + "px",
"height": ~~((coords[3] * 6/8)*video_ratio) + "px",
"display": "block"
});
setLock(coords);
} else {
$("#glasses").css("display", "none");
}
});
}
}
function setLock(coords){
x = coords[0] + coords[2]/2; // top left x + width/2
y = coords[1] + coords[3]/2; // top left y + height/2
zoom = coords[4];
video_width=video.videoWidth;
video_height=video.videoHeight;
max_displacement = video_width - coords[2]; //max displacement from center in pixels, accounts for head size
displacement = (x - video_width/2) / max_displacement * 100;
//console.log( "x is: " + x + " y is: " + y + "coords: 0,1,2,3,4: " + coords[0] + " " + coords[1] + " " + coords[2] + " " + coords[3] + " " + coords[4]);
console.log("displacement is: " + displacement);
setPos(displacement, 20)
}
var dialCenter = [129,124];
var needleCenter = [ 13, 121.5 ];
var dial = new Image, needle = new Image;
var c = document.getElementsByTagName('canvas')[0];
var ctx = c.getContext('2d');
dial.src = 'dial.png';
needle.src = 'needle.png';
var timeGood = 0
var lastDisp = 0
var errorDisp = 5
var last60 = new Array()
var count = 0
function setPos(displacement, actualAns){
last60[count%60] = displacement
minElem = 600
maxElem = -600
for(var x = 0; x < last60.length; x++){
minElem = Math.min(minElem,last60[x])
maxElem = Math.max(maxElem,last60[x])
console.log("min" + minElem)
}
count += 1
if(Math.abs(maxElem - minElem) < 5 && last60.length == 60){
alert('done')
}
/*
if (Math.abs(displacement - actualAns) < errorDisp ){
timeGood += 1
if (timeGood >= 60){
console.log('You have won')
}
console.log(timeGood)
}
else
{
timeGood = 0
}*/
ctx.save();
ctx.clearRect( 0, 0, c.width, c.height );
// Center the dial on the canvas.
ctx.translate( c.width/2 , c.height/2 );
ctx.drawImage( dial, -dialCenter[0], -dialCenter[1] );
// Center the needle on the canvas.
ctx.rotate( displacement/100*Math.PI*2- 0.15 );
ctx.drawImage( needle, -needleCenter[0], -needleCenter[1] );
ctx.restore();
}
function setMap(coords){
x = coords[0] + coords[2]/2;
y = coords[1] + coords[3]/2;
zoom = coords[4];
video_width=video.videoWidth;
video_height=video.videoHeight;
var vr_head = Math.atan( (x-(video_width/2)) / (video_width) ) * 180 / Math.PI + initial_heading;
var vr_pitch = 1*Math.atan( (y - (video_height/2)) / (video_width) ) *180 / Math.PI + initial_pitch;
var vr_zoom = initial_zoom;
var x_inc = 3;
var y_inc = .5;
if(Math.abs(y - video_height)/video_height >.75 ){
initial_pitch = Math.min((initial_pitch + y_inc), 90);
}
else{
if(Math.abs(y - video_height)/video_height <.25 ){
initial_pitch = Math.max((initial_pitch - y_inc), -90);
}
else
{
if(Math.abs(x - video_width)/video_width >.75 ){
initial_heading = (initial_heading - x_inc) % 360;
}
if(Math.abs(x - video_width)/video_width <.25 ){
initial_heading = (initial_heading + x_inc) % 360;
}
}
}
myPano.setPov({
heading: vr_head,
zoom:vr_zoom,
pitch:vr_pitch
});
}
});
function fullScreen(){
document.getElementById('pano').style.width = "100%";
document.getElementById('pano').style.height = "100%";
google.maps.event.trigger(myPano, 'resize');
}
function smallScreen(){
document.getElementById('pano').style.width = "500px";
document.getElementById('pano').style.height = "300px";
google.maps.event.trigger(myPano, 'resize');
document.getElementById('video').onchange;
}
</script>
</head>
<body onload="initialize();" onunload="GUnload()">
<div name="pano" id="pano" style="z-index:-1; position: absolute; width: 100%; height: 100%"></div>
<div name="buttons" id="buttons" style="position: absolute; top:0; right: 0;">
<button type="button btn-primary" onClick = "fullScreen()" style="float: top;">Full Screen!</button>
<button type="button btn-primary" onClick = "smallScreen()" style="float: top;">Small Screen!</button>
</div>
<video id="video" style="float:right; margin-right:1em; width: 600px;"></video>
<img id="glasses" src="http://dl.dropbox.com/u/110033260/batman.jpg" style="position:absolute; display:none">
<!DOCTYPE HTML>
<canvas id="myCanvas" width="578" height="200"></canvas>
</body>
</html>