-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbooth.html
105 lines (90 loc) · 2.5 KB
/
booth.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
<!doctype html>
<html>
<head>
<style>
#face {
z-index: 1;
position: absolute;
top: 100px;
left: 730px;
border: 0;
padding: 0;
}
#hole {
z-index: 2;
position: absolute;
top: 175px;
left: 635px;
border: 0;
padding: 0;
}
#frame {
z-index: 3;
position: absolute;
top: 100px;
left: 540px;
border: 0;
padding: 0;
}
</style>
</head>
<body>
<div>
<div id="canvas">
<video autoplay id="face" height="300px" width="400px"></video>
<canvas id="hole" width="700" height="400"></canvas>
<canvas id="frame" width="768" height="1024"></canvas>
</div>
<script type="text/javascript">
navigator.getUserMedia = navigator.webkitGetUserMedia || navigator.getUserMedia;
window.URL = window.URL || window.webkitURL;
var faceLayer;
var holeLayer;
var frameLayer;
var faceCtx;
var holeCtx;
var frameCtx;
function init() {
faceLayer = document.getElementById("face");
holeLayer = document.getElementById("hole");
holeCtx = holeLayer.getContext("2d");
frameLayer = document.getElementById("frame");
frameCtx = frameLayer.getContext("2d");
setTimeout(drawAll, 0);
}
function drawAll() {
drawFace();
drawHole();
drawFrame();
}
function drawFace() {
console.log("drawing face...");
navigator.getUserMedia({video: true}, stream, error);
}
function stream(stream) {
faceLayer.src = window.URL.createObjectURL(stream);
stream.onended = error;
faceLayer.onerror = function (e) {
stream.stop();
};
}
function error(e) {
console.log(e);
}
function drawHole() {
console.log("drawing hole...");
var image = new Image();
image.src = "./images/president_t.gif";
holeCtx.drawImage(image, 0, 0);
}
function drawFrame() {
console.log("drawing frame...");
var image = new Image();
image.src = "./images/frame_t.gif";
frameCtx.drawImage(image, 0, 0);
}
init();
</script>
</div>
</body>
</html>