Skip to content

Commit 1ebc728

Browse files
committed
UI change for prod, Full HD 1080p and win/lose message
1 parent f1b8ab0 commit 1ebc728

File tree

2 files changed

+105
-50
lines changed

2 files changed

+105
-50
lines changed

examples/examples-game/public/styles.css

Lines changed: 56 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
.page-container {
2-
left: 0;
3-
right: 0;
4-
margin: auto;
5-
margin-top: 20px;
6-
padding-right: 200px;
1+
html, body {
2+
margin: 0;
3+
padding: 0;
74
}
85

9-
@media only screen and (max-width : 992px) {
10-
.page-container {
11-
padding-left: 0;
12-
display: flex !important;
13-
}
6+
* {
7+
box-sizing: border-box;
148
}
159

1610
#navbar {
@@ -21,10 +15,12 @@
2115

2216
.center-content {
2317
display: flex;
24-
flex-direction: column;
25-
justify-content: center;
26-
align-items: center;
27-
flex-wrap: wrap;
18+
19+
}
20+
21+
.page-container {
22+
justify-content: left;
23+
align-items: normal;
2824
}
2925

3026
.side-by-side {
@@ -108,6 +104,19 @@
108104
display: flex;
109105
}
110106

107+
108+
.my-video-container {
109+
position: relative;
110+
padding-bottom: 0;
111+
height: auto;
112+
overflow: auto;
113+
}
114+
115+
.my-video-container video {
116+
width: 100% !important;
117+
height: auto !important;
118+
}
119+
111120
.video {
112121
position: relative;
113122
}
@@ -119,13 +128,13 @@
119128
right: 0;
120129
}
121130

122-
#inputVideo {
131+
/* #inputVideo {
123132
width: 640px;
124133
height: 480px;
125-
}
134+
} */
126135

127136
.pokerface {
128-
width: 640px;
137+
width: 100%;
129138
background-color: #10e886;
130139
font-family: 'upheaval_tt_brkregular', arial;
131140
font-size: 5em;
@@ -193,13 +202,11 @@
193202
}
194203

195204
.settings {
196-
/* display: none; */
205+
display: none;
197206
}
198207

199208
.detections {
200-
position: absolute;
201-
left: 100%;
202-
top: 0;
209+
text-align: center;
203210
font-family: 'upheaval_tt_brkregular', arial;
204211
font-size: 3em;
205212
line-height: 1em;
@@ -215,12 +222,9 @@
215222
}
216223

217224
.control {
218-
position: absolute;
219-
top: -168px ;
220-
left: 100%;
221225
padding: 0 14px;
222-
width: 250px;
223226
text-align: center;
227+
margin-bottom: 30px;
224228
}
225229

226230
.eightbit-btn {
@@ -296,3 +300,29 @@
296300
.mySelect {
297301
display: block;
298302
}
303+
304+
.main {
305+
flex: 1;
306+
padding: 30px;
307+
padding-bottom: 0;
308+
padding-right: 0;
309+
}
310+
311+
.sidebar {
312+
position: relative;
313+
width: 25%;
314+
overflow: hidden;
315+
padding-top: 30px;
316+
}
317+
318+
.gameResultWin, .gameResultLose {
319+
display: none;
320+
text-align: center;
321+
font-family: 'upheaval_tt_brkregular', arial;
322+
font-size: 2em;
323+
color: #10e886;
324+
}
325+
326+
.gameResultLose {
327+
color: #f51717;
328+
}

examples/examples-game/views/webcamFaceExpressionRecognition.html

Lines changed: 49 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,38 @@
4242
<div id="navbar" style="display:none;"></div>
4343
<div class="center-content page-container">
4444

45-
<div class="pokerface">
46-
<p class="title">Poker Face</p>
47-
<!-- <p class="valueMeter-label">Neutral</p> -->
48-
<div class="valueMeter" id="neutralThreshold">
49-
<i class="bar"></i>
50-
<i class="draggable-cursor"></i>
45+
<div class="main">
46+
47+
<div class="pokerface">
48+
<p class="title">Poker Face</p>
49+
<!-- <p class="valueMeter-label">Neutral</p> -->
50+
<div class="valueMeter" id="neutralThreshold">
51+
<i class="bar"></i>
52+
<i class="draggable-cursor"></i>
53+
</div>
54+
<!-- <p class="valueMeter-label">Exception</p>
55+
<div class="valueMeter" id="exceptionThreshold">
56+
<i class="bar"></i>
57+
<i class="draggable-cursor"></i>
58+
</div> -->
5159
</div>
52-
<!-- <p class="valueMeter-label">Exception</p>
53-
<div class="valueMeter" id="exceptionThreshold">
54-
<i class="bar"></i>
55-
<i class="draggable-cursor"></i>
56-
</div> -->
57-
</div>
5860

59-
<div class="video">
61+
<div class="video">
62+
63+
<div class="progress" id="loader">
64+
<div class="indeterminate"></div>
65+
</div>
66+
<div class="my-video-container">
67+
<video onloadedmetadata="onPlay(this)" id="inputVideo" autoplay muted playsinline></video>
68+
<canvas id="overlay" />
69+
</div>
6070

61-
<div class="progress" id="loader">
62-
<div class="indeterminate"></div>
63-
</div>
64-
<div style="position: relative">
65-
<video onloadedmetadata="onPlay(this)" id="inputVideo" autoplay muted playsinline></video>
66-
<canvas id="overlay" width="640" height="480" />
6771
</div>
6872

73+
</div>
74+
75+
<div class="sidebar">
76+
6977
<div class="control">
7078
<div id="countdown">
7179
<h4>Time Left:</h4>
@@ -75,14 +83,18 @@ <h4>Time Left:</h4>
7583
<button class="play eightbit-btn" id="start-game">Play</button>
7684
</div>
7785

86+
<div class="gameResultWin">You Win !</div>
87+
<div class="gameResultLose">You Lose !</div>
88+
7889
<div class="detections">
7990
<h4>Detections:</h4>
8091
<ul id="detections-list">
8192
</ul>
8293
</div>
8394

8495
</div>
85-
<a href="#" class="more-settings">Show more options</a>
96+
97+
<!-- <a href="#" class="more-settings">Show more options</a> -->
8698
<div class="settings">
8799

88100
<br>
@@ -281,8 +293,10 @@ <h4>Detections:</h4>
281293
updateTimeStats(Date.now() - ts)
282294

283295
if (result) {
284-
const canvas = $('#overlay').get(0)
285-
const dims = faceapi.matchDimensions(canvas, videoEl, true)
296+
const canvas = $('#overlay').get(0);
297+
const $videoEl = $('#inputVideo');
298+
const displaySize = { width: $videoEl.width(), height: $videoEl.height() }
299+
const dims = faceapi.matchDimensions(canvas, displaySize, true);
286300

287301
const resizedResult = faceapi.resizeResults(result, dims)
288302
const minConfidence = 0.05
@@ -300,6 +314,9 @@ <h4>Detections:</h4>
300314
pokerface(result);
301315
}
302316

317+
// $('#overlay').height($('#inputVideo').height());
318+
// $('#overlay').width($('#inputVideo').width());
319+
303320
setTimeout(() => onPlay())
304321
}
305322

@@ -311,7 +328,12 @@ <h4>Detections:</h4>
311328

312329
// try to access users webcam and stream the images
313330
// to the video element
314-
const stream = await navigator.mediaDevices.getUserMedia({ video: {} })
331+
const stream = await navigator.mediaDevices.getUserMedia({
332+
video: {
333+
width: 1920,
334+
height: 1080
335+
}
336+
})
315337
const videoEl = $('#inputVideo').get(0)
316338
videoEl.srcObject = stream
317339
}
@@ -323,7 +345,7 @@ <h4>Detections:</h4>
323345
var options = {
324346
faceExpressionThreshold: 10,
325347
faceExceptionThreshold: 10,
326-
neutralInterval: 200,
348+
neutralInterval: 100,
327349
faceException: ''
328350
}
329351

@@ -423,6 +445,7 @@ <h4>Detections:</h4>
423445

424446
function start() {
425447
isStarted = true;
448+
$('.gameResultWin, .gameResultLose').hide();
426449
$("#start-game").text('Stop');
427450
$('#countdown .values').attr('disabled','disabled');
428451
$('audio#audio-start')[0].play();
@@ -455,9 +478,11 @@ <h4>Detections:</h4>
455478
//updateSlider('exceptionThreshold', 0);
456479

457480
if(winning) {
481+
$('.gameResultWin').show();
458482
playWin();
459483
}
460484
else {
485+
$('.gameResultLose').show();
461486
playLost();
462487
}
463488
}

0 commit comments

Comments
 (0)