Showing
32 changed files
with
911 additions
and
36 deletions
screensaver/action.py
0 → 100644
1 | +import os | ||
2 | +import sys | ||
3 | +import pyautogui | ||
4 | +import time | ||
5 | +# print(len(sys.argv)) | ||
6 | +# print(sys.argv[0]) | ||
7 | + | ||
8 | + | ||
9 | +if sys.argv[1] == "Logout": | ||
10 | + os.system("rundll32 user32.dll LockWorkStation") | ||
11 | +elif sys.argv[1] == "Desktop": | ||
12 | + pyautogui.keyDown("win") | ||
13 | + pyautogui.keyDown('d') | ||
14 | + time.sleep(0.5) | ||
15 | + pyautogui.keyUp("win") | ||
16 | + pyautogui.keyUp('d') | ||
17 | +elif sys.argv[1] == "NewDesktop": | ||
18 | + pyautogui.keyDown("win") | ||
19 | + pyautogui.keyDown('ctrl') | ||
20 | + pyautogui.keyDown('right') | ||
21 | + time.sleep(0.5) | ||
22 | + pyautogui.keyUp("win") | ||
23 | + pyautogui.keyUp('ctrl') | ||
24 | + pyautogui.keyUp('right') |
1 | -var createError = require('http-errors'); | 1 | +var createError = require("http-errors"); |
2 | -var express = require('express'); | 2 | +var express = require("express"); |
3 | -var path = require('path'); | 3 | +var path = require("path"); |
4 | -var cookieParser = require('cookie-parser'); | 4 | +var cookieParser = require("cookie-parser"); |
5 | -var logger = require('morgan'); | 5 | +var logger = require("morgan"); |
6 | 6 | ||
7 | -var indexRouter = require('./routes/index'); | 7 | +var indexRouter = require("./routes/index"); |
8 | -var usersRouter = require('./routes/users'); | 8 | +var registerRouter = require("./routes/register"); |
9 | +var useRouter = require("./routes/use"); | ||
9 | 10 | ||
10 | var app = express(); | 11 | var app = express(); |
11 | 12 | ||
12 | // view engine setup | 13 | // view engine setup |
13 | -app.set('views', path.join(__dirname, 'views')); | 14 | +app.set("views", path.join(__dirname, "views")); |
14 | -app.set('view engine', 'ejs'); | 15 | +app.set("view engine", "ejs"); |
15 | 16 | ||
16 | -app.use(logger('dev')); | 17 | +app.use(logger("dev")); |
17 | app.use(express.json()); | 18 | app.use(express.json()); |
18 | -app.use(express.urlencoded({ extended: false })); | 19 | +app.use(express.urlencoded({ extended: true })); |
19 | app.use(cookieParser()); | 20 | app.use(cookieParser()); |
20 | -app.use(express.static(path.join(__dirname, 'public'))); | 21 | +app.use(express.static(path.join(__dirname, "public"))); |
21 | 22 | ||
22 | -app.use('/', indexRouter); | 23 | +app.use("/", indexRouter); |
23 | -app.use('/users', usersRouter); | 24 | +app.use("/register", registerRouter); |
25 | +app.use("/use", useRouter); | ||
24 | 26 | ||
25 | // catch 404 and forward to error handler | 27 | // catch 404 and forward to error handler |
26 | -app.use(function(req, res, next) { | 28 | +app.use(function (req, res, next) { |
27 | next(createError(404)); | 29 | next(createError(404)); |
28 | }); | 30 | }); |
29 | 31 | ||
30 | // error handler | 32 | // error handler |
31 | -app.use(function(err, req, res, next) { | 33 | +app.use(function (err, req, res, next) { |
32 | // set locals, only providing error in development | 34 | // set locals, only providing error in development |
33 | res.locals.message = err.message; | 35 | res.locals.message = err.message; |
34 | - res.locals.error = req.app.get('env') === 'development' ? err : {}; | 36 | + res.locals.error = req.app.get("env") === "development" ? err : {}; |
35 | 37 | ||
36 | // render the error page | 38 | // render the error page |
37 | res.status(err.status || 500); | 39 | res.status(err.status || 500); |
38 | - res.render('error'); | 40 | + res.render("error"); |
39 | }); | 41 | }); |
40 | 42 | ||
41 | module.exports = app; | 43 | module.exports = app; | ... | ... |
screensaver/config.json
0 → 100644
1 | +{ "accessKeyId": "AKIATDD4YZYTJZMV3255", "secretAccessKey": "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", "region": "ap-northeast-2" } | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -4,6 +4,11 @@ | ... | @@ -4,6 +4,11 @@ |
4 | "lockfileVersion": 1, | 4 | "lockfileVersion": 1, |
5 | "requires": true, | 5 | "requires": true, |
6 | "dependencies": { | 6 | "dependencies": { |
7 | + "@tensorflow-models/blazeface": { | ||
8 | + "version": "0.0.5", | ||
9 | + "resolved": "https://registry.npmjs.org/@tensorflow-models/blazeface/-/blazeface-0.0.5.tgz", | ||
10 | + "integrity": "sha512-bIMJDV2CD8rr7v9OrIDdDZVh9sbk0EhlZdHaDFpgWUw3Lp21wUN7GSifOJVE5hV2ngmpzM+J12OH8bG1GZoDag==" | ||
11 | + }, | ||
7 | "accepts": { | 12 | "accepts": { |
8 | "version": "1.3.7", | 13 | "version": "1.3.7", |
9 | "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", | 14 | "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", |
... | @@ -18,6 +23,27 @@ | ... | @@ -18,6 +23,27 @@ |
18 | "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", | 23 | "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", |
19 | "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" | 24 | "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" |
20 | }, | 25 | }, |
26 | + "aws-sdk": { | ||
27 | + "version": "2.791.0", | ||
28 | + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.791.0.tgz", | ||
29 | + "integrity": "sha512-oIWu0hLKmDS+rOmjud2Z1CaDXtmxKSJF4937dSNLf/vNkxxjJA/6HapSfKqsraLnekI9DLP8uop5HnCHC++Abw==", | ||
30 | + "requires": { | ||
31 | + "buffer": "4.9.2", | ||
32 | + "events": "1.1.1", | ||
33 | + "ieee754": "1.1.13", | ||
34 | + "jmespath": "0.15.0", | ||
35 | + "querystring": "0.2.0", | ||
36 | + "sax": "1.2.1", | ||
37 | + "url": "0.10.3", | ||
38 | + "uuid": "3.3.2", | ||
39 | + "xml2js": "0.4.19" | ||
40 | + } | ||
41 | + }, | ||
42 | + "base64-js": { | ||
43 | + "version": "1.5.1", | ||
44 | + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", | ||
45 | + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" | ||
46 | + }, | ||
21 | "basic-auth": { | 47 | "basic-auth": { |
22 | "version": "2.0.1", | 48 | "version": "2.0.1", |
23 | "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", | 49 | "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", |
... | @@ -43,6 +69,16 @@ | ... | @@ -43,6 +69,16 @@ |
43 | "type-is": "~1.6.16" | 69 | "type-is": "~1.6.16" |
44 | } | 70 | } |
45 | }, | 71 | }, |
72 | + "buffer": { | ||
73 | + "version": "4.9.2", | ||
74 | + "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.2.tgz", | ||
75 | + "integrity": "sha512-xq+q3SRMOxGivLhBNaUdC64hDTQwejJ+H0T/NB1XMtTVEwNTrfFF3gAxiyW0Bu/xWEGhjVKgUcMhCrUy2+uCWg==", | ||
76 | + "requires": { | ||
77 | + "base64-js": "^1.0.2", | ||
78 | + "ieee754": "^1.1.4", | ||
79 | + "isarray": "^1.0.0" | ||
80 | + } | ||
81 | + }, | ||
46 | "bytes": { | 82 | "bytes": { |
47 | "version": "3.0.0", | 83 | "version": "3.0.0", |
48 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", | 84 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", |
... | @@ -120,6 +156,11 @@ | ... | @@ -120,6 +156,11 @@ |
120 | "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", | 156 | "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", |
121 | "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" | 157 | "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" |
122 | }, | 158 | }, |
159 | + "events": { | ||
160 | + "version": "1.1.1", | ||
161 | + "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", | ||
162 | + "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=" | ||
163 | + }, | ||
123 | "express": { | 164 | "express": { |
124 | "version": "4.16.4", | 165 | "version": "4.16.4", |
125 | "resolved": "https://registry.npmjs.org/express/-/express-4.16.4.tgz", | 166 | "resolved": "https://registry.npmjs.org/express/-/express-4.16.4.tgz", |
... | @@ -207,6 +248,11 @@ | ... | @@ -207,6 +248,11 @@ |
207 | "safer-buffer": ">= 2.1.2 < 3" | 248 | "safer-buffer": ">= 2.1.2 < 3" |
208 | } | 249 | } |
209 | }, | 250 | }, |
251 | + "ieee754": { | ||
252 | + "version": "1.1.13", | ||
253 | + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", | ||
254 | + "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==" | ||
255 | + }, | ||
210 | "inherits": { | 256 | "inherits": { |
211 | "version": "2.0.3", | 257 | "version": "2.0.3", |
212 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", | 258 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", |
... | @@ -217,6 +263,16 @@ | ... | @@ -217,6 +263,16 @@ |
217 | "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", | 263 | "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", |
218 | "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==" | 264 | "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==" |
219 | }, | 265 | }, |
266 | + "isarray": { | ||
267 | + "version": "1.0.0", | ||
268 | + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", | ||
269 | + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" | ||
270 | + }, | ||
271 | + "jmespath": { | ||
272 | + "version": "0.15.0", | ||
273 | + "resolved": "https://registry.npmjs.org/jmespath/-/jmespath-0.15.0.tgz", | ||
274 | + "integrity": "sha1-o/Iiqarp+Wb10nx5ZRDigJF2Qhc=" | ||
275 | + }, | ||
220 | "media-typer": { | 276 | "media-typer": { |
221 | "version": "0.3.0", | 277 | "version": "0.3.0", |
222 | "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", | 278 | "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", |
... | @@ -304,11 +360,26 @@ | ... | @@ -304,11 +360,26 @@ |
304 | "ipaddr.js": "1.9.1" | 360 | "ipaddr.js": "1.9.1" |
305 | } | 361 | } |
306 | }, | 362 | }, |
363 | + "punycode": { | ||
364 | + "version": "1.3.2", | ||
365 | + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", | ||
366 | + "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=" | ||
367 | + }, | ||
368 | + "python-shell": { | ||
369 | + "version": "2.0.2", | ||
370 | + "resolved": "https://registry.npmjs.org/python-shell/-/python-shell-2.0.2.tgz", | ||
371 | + "integrity": "sha512-8zWhh3PQT8SxrYK/cxaLJkuzR+saHUnx83V5TrTlfdEDnLQ6/wVBIpc6YfYSRSRvcrz8vkORJlSzm1FYkEFq2Q==" | ||
372 | + }, | ||
307 | "qs": { | 373 | "qs": { |
308 | "version": "6.5.2", | 374 | "version": "6.5.2", |
309 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", | 375 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", |
310 | "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" | 376 | "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" |
311 | }, | 377 | }, |
378 | + "querystring": { | ||
379 | + "version": "0.2.0", | ||
380 | + "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", | ||
381 | + "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=" | ||
382 | + }, | ||
312 | "range-parser": { | 383 | "range-parser": { |
313 | "version": "1.2.1", | 384 | "version": "1.2.1", |
314 | "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", | 385 | "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", |
... | @@ -335,6 +406,11 @@ | ... | @@ -335,6 +406,11 @@ |
335 | "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", | 406 | "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", |
336 | "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" | 407 | "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" |
337 | }, | 408 | }, |
409 | + "sax": { | ||
410 | + "version": "1.2.1", | ||
411 | + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.1.tgz", | ||
412 | + "integrity": "sha1-e45lYZCyKOgaZq6nSEgNgozS03o=" | ||
413 | + }, | ||
338 | "send": { | 414 | "send": { |
339 | "version": "0.16.2", | 415 | "version": "0.16.2", |
340 | "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz", | 416 | "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz", |
... | @@ -390,15 +466,43 @@ | ... | @@ -390,15 +466,43 @@ |
390 | "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", | 466 | "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", |
391 | "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" | 467 | "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" |
392 | }, | 468 | }, |
469 | + "url": { | ||
470 | + "version": "0.10.3", | ||
471 | + "resolved": "https://registry.npmjs.org/url/-/url-0.10.3.tgz", | ||
472 | + "integrity": "sha1-Ah5NnHcF8hu/N9A861h2dAJ3TGQ=", | ||
473 | + "requires": { | ||
474 | + "punycode": "1.3.2", | ||
475 | + "querystring": "0.2.0" | ||
476 | + } | ||
477 | + }, | ||
393 | "utils-merge": { | 478 | "utils-merge": { |
394 | "version": "1.0.1", | 479 | "version": "1.0.1", |
395 | "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", | 480 | "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", |
396 | "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" | 481 | "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" |
397 | }, | 482 | }, |
483 | + "uuid": { | ||
484 | + "version": "3.3.2", | ||
485 | + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", | ||
486 | + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" | ||
487 | + }, | ||
398 | "vary": { | 488 | "vary": { |
399 | "version": "1.1.2", | 489 | "version": "1.1.2", |
400 | "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", | 490 | "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", |
401 | "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" | 491 | "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" |
492 | + }, | ||
493 | + "xml2js": { | ||
494 | + "version": "0.4.19", | ||
495 | + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz", | ||
496 | + "integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==", | ||
497 | + "requires": { | ||
498 | + "sax": ">=0.6.0", | ||
499 | + "xmlbuilder": "~9.0.1" | ||
500 | + } | ||
501 | + }, | ||
502 | + "xmlbuilder": { | ||
503 | + "version": "9.0.7", | ||
504 | + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", | ||
505 | + "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=" | ||
402 | } | 506 | } |
403 | } | 507 | } |
404 | } | 508 | } | ... | ... |
... | @@ -6,11 +6,14 @@ | ... | @@ -6,11 +6,14 @@ |
6 | "start": "node ./bin/www" | 6 | "start": "node ./bin/www" |
7 | }, | 7 | }, |
8 | "dependencies": { | 8 | "dependencies": { |
9 | + "@tensorflow-models/blazeface": "0.0.5", | ||
10 | + "aws-sdk": "^2.791.0", | ||
9 | "cookie-parser": "~1.4.4", | 11 | "cookie-parser": "~1.4.4", |
10 | "debug": "~2.6.9", | 12 | "debug": "~2.6.9", |
11 | "ejs": "~2.6.1", | 13 | "ejs": "~2.6.1", |
12 | "express": "~4.16.1", | 14 | "express": "~4.16.1", |
13 | - "http-errors": "~1.6.3", | 15 | + "http-errors": "^1.6.3", |
14 | - "morgan": "~1.9.1" | 16 | + "morgan": "~1.9.1", |
17 | + "python-shell": "^2.0.2" | ||
15 | } | 18 | } |
16 | } | 19 | } | ... | ... |
screensaver/public/fonts/FontAwesome.otf
0 → 100644
No preview for this file type
No preview for this file type
This diff could not be displayed because it is too large.
No preview for this file type
No preview for this file type
No preview for this file type
screensaver/public/images/person_add.png
0 → 100644
6.22 KB
screensaver/public/images/play.png
0 → 100644
8.93 KB
screensaver/public/images/somi.jpg
0 → 100644
161 KB
screensaver/public/images/unknown.png
0 → 100644
460 KB
screensaver/public/javascripts/aws_setup.js
0 → 100644
screensaver/public/javascripts/index.js
0 → 100644
1 | +/** | ||
2 | + * @license | ||
3 | + * Copyright 2019 Google LLC. All Rights Reserved. | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * https://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + * ============================================================================= | ||
16 | + */ | ||
17 | + | ||
18 | + | ||
19 | +// tfjsWasm.setWasmPath('https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@latest/dist/tfjs-backend-wasm.wasm'); | ||
20 | + | ||
21 | + | ||
22 | + | ||
23 | +const stats = new Stats(); | ||
24 | +stats.showPanel(0); | ||
25 | +document.body.prepend(stats.domElement); | ||
26 | + | ||
27 | +let model, ctx, videoWidth, videoHeight, video, canvas; | ||
28 | +let face_frame_count; | ||
29 | +face_frame_count = 0 | ||
30 | + | ||
31 | +const state = { | ||
32 | + backend: 'webgl' | ||
33 | +}; | ||
34 | + | ||
35 | +// const gui = new dat.GUI(); | ||
36 | +// gui.add(state, 'backend', ['wasm', 'webgl', 'cpu']).onChange(async backend => { | ||
37 | +// await tf.setBackend(backend); | ||
38 | +// }); | ||
39 | + | ||
40 | +async function setupCamera() { | ||
41 | + video = document.getElementById('video'); | ||
42 | + | ||
43 | + const stream = await navigator.mediaDevices.getUserMedia({ | ||
44 | + 'audio': false, | ||
45 | + 'video': { facingMode: 'user' }, | ||
46 | + }); | ||
47 | + video.srcObject = stream; | ||
48 | + | ||
49 | + return new Promise((resolve) => { | ||
50 | + video.onloadedmetadata = () => { | ||
51 | + resolve(video); | ||
52 | + }; | ||
53 | + }); | ||
54 | +} | ||
55 | + | ||
56 | +async function AWS_req(img_byte){ | ||
57 | + let element = document.getElementById('method'); | ||
58 | + console.log(element.value) | ||
59 | + var rekognition = new AWS.Rekognition(); | ||
60 | + var params = { | ||
61 | + CollectionId: "6jj2", | ||
62 | + FaceMatchThreshold: 95, | ||
63 | + Image: { | ||
64 | + Bytes : img_byte | ||
65 | + }, | ||
66 | + MaxFaces: 5 | ||
67 | + }; | ||
68 | + rekognition.searchFacesByImage(params, function(err, data){ | ||
69 | + if (err) { | ||
70 | + console.log(err, err.stack); // an error occurred | ||
71 | + alert("AWS Not configured. Check /pubilc/javascripts/aws_setup.js"); | ||
72 | + window.location.href = '/'; | ||
73 | + } | ||
74 | + | ||
75 | + else console.log(data); // successful response | ||
76 | + if (data.FaceMatches.length>0){ | ||
77 | + post_data = { | ||
78 | + "result": true, | ||
79 | + "type" : element.value, | ||
80 | + "landing": "false" | ||
81 | + } | ||
82 | + } | ||
83 | + else{ | ||
84 | + post_data = { | ||
85 | + "result": false, | ||
86 | + "type" : element.value, | ||
87 | + "landing": "false" | ||
88 | + } | ||
89 | + redirectPost("/use",post_data) | ||
90 | + } | ||
91 | + | ||
92 | + | ||
93 | + } | ||
94 | + ) | ||
95 | + | ||
96 | +} | ||
97 | + | ||
98 | +const renderPrediction = async () => { | ||
99 | + stats.begin(); | ||
100 | + | ||
101 | + const returnTensors = false; | ||
102 | + const flipHorizontal = true; | ||
103 | + const annotateBoxes = true; | ||
104 | + const predictions = await model.estimateFaces( | ||
105 | + video, returnTensors, flipHorizontal, annotateBoxes); | ||
106 | + | ||
107 | + if (predictions.length > 0) { | ||
108 | + face_frame_count += 1; | ||
109 | + ctx.clearRect(0, 0, canvas.width, canvas.height); | ||
110 | + | ||
111 | + for (let i = 0; i < predictions.length; i++) { | ||
112 | + if (returnTensors) { | ||
113 | + predictions[i].topLeft = predictions[i].topLeft.arraySync(); | ||
114 | + predictions[i].bottomRight = predictions[i].bottomRight.arraySync(); | ||
115 | + if (annotateBoxes) { | ||
116 | + predictions[i].landmarks = predictions[i].landmarks.arraySync(); | ||
117 | + } | ||
118 | + } | ||
119 | + | ||
120 | + const start = predictions[i].topLeft; | ||
121 | + const end = predictions[i].bottomRight; | ||
122 | + // console.log(start) | ||
123 | + // console.log(end) | ||
124 | + const size = [end[0] - start[0], end[1] - start[1]]; | ||
125 | + ctx.fillStyle = "rgba(255, 0, 0, 0.5)"; | ||
126 | + // ctx.fillRect(start[0], start[1], size[0], size[1]); | ||
127 | + | ||
128 | + if (annotateBoxes) { | ||
129 | + const landmarks = predictions[i].landmarks; | ||
130 | + | ||
131 | + ctx.fillStyle = "blue"; | ||
132 | + for (let j = 0; j < landmarks.length; j++) { | ||
133 | + const x = landmarks[j][0]; | ||
134 | + const y = landmarks[j][1]; | ||
135 | + ctx.fillRect(x, y, 5, 5); | ||
136 | + } | ||
137 | + } | ||
138 | + } | ||
139 | + } | ||
140 | + | ||
141 | + stats.end(); | ||
142 | + if(face_frame_count > 100){ | ||
143 | + onClick() | ||
144 | + face_frame_count = 0 | ||
145 | + } | ||
146 | + requestAnimationFrame(renderPrediction); | ||
147 | +}; | ||
148 | +function onClick(){ | ||
149 | + canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height); | ||
150 | + var dataURL = canvas.toDataURL(); | ||
151 | + enc_data = atob(dataURL.split("data:image/png;base64,")[1]) | ||
152 | + // console.log(enc_data) | ||
153 | + var length = enc_data.length; | ||
154 | + imageBytes = new ArrayBuffer(length); | ||
155 | + var ua = new Uint8Array(imageBytes); | ||
156 | + for (var i = 0; i < length; i++) { | ||
157 | + ua[i] = enc_data.charCodeAt(i); | ||
158 | + } | ||
159 | + // console.log(ua) | ||
160 | + AWS_req(ua) | ||
161 | + | ||
162 | +} | ||
163 | +const setupPage = async () => { | ||
164 | + await tf.setBackend(state.backend); | ||
165 | + await setupCamera(); | ||
166 | + video.play(); | ||
167 | + | ||
168 | + videoWidth = video.videoWidth; | ||
169 | + videoHeight = video.videoHeight; | ||
170 | + video.width = videoWidth; | ||
171 | + video.height = videoHeight; | ||
172 | + | ||
173 | + canvas = document.getElementById('output'); | ||
174 | + canvas.width = videoWidth; | ||
175 | + canvas.height = videoHeight; | ||
176 | + ctx = canvas.getContext('2d'); | ||
177 | + ctx.fillStyle = "rgba(255, 0, 0, 0.5)"; | ||
178 | + | ||
179 | + model = await blazeface.load(); | ||
180 | + | ||
181 | + renderPrediction(); | ||
182 | +}; | ||
183 | + | ||
184 | +function redirectPost(url, data) { | ||
185 | + var form = document.createElement('form'); | ||
186 | + document.body.appendChild(form); | ||
187 | + form.method = 'post'; | ||
188 | + form.action = url; | ||
189 | + for (var name in data) { | ||
190 | + var input = document.createElement('input'); | ||
191 | + input.type = 'hidden'; | ||
192 | + input.name = name; | ||
193 | + input.value = data[name]; | ||
194 | + form.appendChild(input); | ||
195 | + } | ||
196 | + form.submit(); | ||
197 | +} | ||
198 | + | ||
199 | +setupPage(); |
screensaver/public/javascripts/jquery.min.js
0 → 100644
This diff is collapsed. Click to expand it.
1 | +/* jquery.scrollex v0.2.1 | (c) @ajlkn | github.com/ajlkn/jquery.scrollex | MIT licensed */ | ||
2 | +!function(t){function e(t,e,n){return"string"==typeof t&&("%"==t.slice(-1)?t=parseInt(t.substring(0,t.length-1))/100*e:"vh"==t.slice(-2)?t=parseInt(t.substring(0,t.length-2))/100*n:"px"==t.slice(-2)&&(t=parseInt(t.substring(0,t.length-2)))),t}var n=t(window),i=1,o={};n.on("scroll",function(){var e=n.scrollTop();t.map(o,function(t){window.clearTimeout(t.timeoutId),t.timeoutId=window.setTimeout(function(){t.handler(e)},t.options.delay)})}).on("load",function(){n.trigger("scroll")}),jQuery.fn.scrollex=function(l){var s=t(this);if(0==this.length)return s;if(this.length>1){for(var r=0;r<this.length;r++)t(this[r]).scrollex(l);return s}if(s.data("_scrollexId"))return s;var a,u,h,c,p;switch(a=i++,u=jQuery.extend({top:0,bottom:0,delay:0,mode:"default",enter:null,leave:null,initialize:null,terminate:null,scroll:null},l),u.mode){case"top":h=function(t,e,n,i,o){return t>=i&&o>=t};break;case"bottom":h=function(t,e,n,i,o){return n>=i&&o>=n};break;case"middle":h=function(t,e,n,i,o){return e>=i&&o>=e};break;case"top-only":h=function(t,e,n,i,o){return i>=t&&n>=i};break;case"bottom-only":h=function(t,e,n,i,o){return n>=o&&o>=t};break;default:case"default":h=function(t,e,n,i,o){return n>=i&&o>=t}}return c=function(t){var i,o,l,s,r,a,u=this.state,h=!1,c=this.$element.offset();i=n.height(),o=t+i/2,l=t+i,s=this.$element.outerHeight(),r=c.top+e(this.options.top,s,i),a=c.top+s-e(this.options.bottom,s,i),h=this.test(t,o,l,r,a),h!=u&&(this.state=h,h?this.options.enter&&this.options.enter.apply(this.element):this.options.leave&&this.options.leave.apply(this.element)),this.options.scroll&&this.options.scroll.apply(this.element,[(o-r)/(a-r)])},p={id:a,options:u,test:h,handler:c,state:null,element:this,$element:s,timeoutId:null},o[a]=p,s.data("_scrollexId",p.id),p.options.initialize&&p.options.initialize.apply(this),s},jQuery.fn.unscrollex=function(){var e=t(this);if(0==this.length)return e;if(this.length>1){for(var n=0;n<this.length;n++)t(this[n]).unscrollex();return e}var i,l;return(i=e.data("_scrollexId"))?(l=o[i],window.clearTimeout(l.timeoutId),delete o[i],e.removeData("_scrollexId"),l.options.terminate&&l.options.terminate.apply(this),e):e}}(jQuery); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
screensaver/public/javascripts/main.js
0 → 100644
1 | +/* | ||
2 | + Hielo by TEMPLATED | ||
3 | + templated.co @templatedco | ||
4 | + Released for free under the Creative Commons Attribution 3.0 license (templated.co/license) | ||
5 | +*/ | ||
6 | +function register_alert(){ | ||
7 | + alert("등록되었습니다.") | ||
8 | +} | ||
9 | +var settings = { | ||
10 | + | ||
11 | + banner: { | ||
12 | + | ||
13 | + // Indicators (= the clickable dots at the bottom). | ||
14 | + indicators: true, | ||
15 | + | ||
16 | + // Transition speed (in ms) | ||
17 | + // For timing purposes only. It *must* match the transition speed of "#banner > article". | ||
18 | + speed: 1500, | ||
19 | + | ||
20 | + // Transition delay (in ms) | ||
21 | + delay: 5000, | ||
22 | + | ||
23 | + // Parallax intensity (between 0 and 1; higher = more intense, lower = less intense; 0 = off) | ||
24 | + parallax: 0.25 | ||
25 | + | ||
26 | + } | ||
27 | + | ||
28 | +}; | ||
29 | + | ||
30 | +(function($) { | ||
31 | + | ||
32 | + skel.breakpoints({ | ||
33 | + xlarge: '(max-width: 1680px)', | ||
34 | + large: '(max-width: 1280px)', | ||
35 | + medium: '(max-width: 980px)', | ||
36 | + small: '(max-width: 736px)', | ||
37 | + xsmall: '(max-width: 480px)' | ||
38 | + }); | ||
39 | + | ||
40 | + /** | ||
41 | + * Applies parallax scrolling to an element's background image. | ||
42 | + * @return {jQuery} jQuery object. | ||
43 | + */ | ||
44 | + $.fn._parallax = (skel.vars.browser == 'ie' || skel.vars.mobile) ? function() { return $(this) } : function(intensity) { | ||
45 | + | ||
46 | + var $window = $(window), | ||
47 | + $this = $(this); | ||
48 | + | ||
49 | + if (this.length == 0 || intensity === 0) | ||
50 | + return $this; | ||
51 | + | ||
52 | + if (this.length > 1) { | ||
53 | + | ||
54 | + for (var i=0; i < this.length; i++) | ||
55 | + $(this[i])._parallax(intensity); | ||
56 | + | ||
57 | + return $this; | ||
58 | + | ||
59 | + } | ||
60 | + | ||
61 | + if (!intensity) | ||
62 | + intensity = 0.25; | ||
63 | + | ||
64 | + $this.each(function() { | ||
65 | + | ||
66 | + var $t = $(this), | ||
67 | + on, off; | ||
68 | + | ||
69 | + on = function() { | ||
70 | + | ||
71 | + $t.css('background-position', 'center 100%, center 100%, center 0px'); | ||
72 | + | ||
73 | + $window | ||
74 | + .on('scroll._parallax', function() { | ||
75 | + | ||
76 | + var pos = parseInt($window.scrollTop()) - parseInt($t.position().top); | ||
77 | + | ||
78 | + $t.css('background-position', 'center ' + (pos * (-1 * intensity)) + 'px'); | ||
79 | + | ||
80 | + }); | ||
81 | + | ||
82 | + }; | ||
83 | + | ||
84 | + off = function() { | ||
85 | + | ||
86 | + $t | ||
87 | + .css('background-position', ''); | ||
88 | + | ||
89 | + $window | ||
90 | + .off('scroll._parallax'); | ||
91 | + | ||
92 | + }; | ||
93 | + | ||
94 | + skel.on('change', function() { | ||
95 | + | ||
96 | + if (skel.breakpoint('medium').active) | ||
97 | + (off)(); | ||
98 | + else | ||
99 | + (on)(); | ||
100 | + | ||
101 | + }); | ||
102 | + | ||
103 | + }); | ||
104 | + | ||
105 | + $window | ||
106 | + .off('load._parallax resize._parallax') | ||
107 | + .on('load._parallax resize._parallax', function() { | ||
108 | + $window.trigger('scroll'); | ||
109 | + }); | ||
110 | + | ||
111 | + return $(this); | ||
112 | + | ||
113 | + }; | ||
114 | + | ||
115 | + /** | ||
116 | + * Custom banner slider for Slate. | ||
117 | + * @return {jQuery} jQuery object. | ||
118 | + */ | ||
119 | + $.fn._slider = function(options) { | ||
120 | + | ||
121 | + var $window = $(window), | ||
122 | + $this = $(this); | ||
123 | + | ||
124 | + if (this.length == 0) | ||
125 | + return $this; | ||
126 | + | ||
127 | + if (this.length > 1) { | ||
128 | + | ||
129 | + for (var i=0; i < this.length; i++) | ||
130 | + $(this[i])._slider(options); | ||
131 | + | ||
132 | + return $this; | ||
133 | + | ||
134 | + } | ||
135 | + | ||
136 | + // Vars. | ||
137 | + var current = 0, pos = 0, lastPos = 0, | ||
138 | + slides = [], indicators = [], | ||
139 | + $indicators, | ||
140 | + $slides = $this.children('article'), | ||
141 | + intervalId, | ||
142 | + isLocked = false, | ||
143 | + i = 0; | ||
144 | + | ||
145 | + // Turn off indicators if we only have one slide. | ||
146 | + if ($slides.length == 1) | ||
147 | + options.indicators = false; | ||
148 | + | ||
149 | + // Functions. | ||
150 | + $this._switchTo = function(x, stop) { | ||
151 | + | ||
152 | + if (isLocked || pos == x) | ||
153 | + return; | ||
154 | + | ||
155 | + isLocked = true; | ||
156 | + | ||
157 | + if (stop) | ||
158 | + window.clearInterval(intervalId); | ||
159 | + | ||
160 | + // Update positions. | ||
161 | + lastPos = pos; | ||
162 | + pos = x; | ||
163 | + | ||
164 | + // Hide last slide. | ||
165 | + slides[lastPos].removeClass('top'); | ||
166 | + | ||
167 | + if (options.indicators) | ||
168 | + indicators[lastPos].removeClass('visible'); | ||
169 | + | ||
170 | + // Show new slide. | ||
171 | + slides[pos].addClass('visible').addClass('top'); | ||
172 | + | ||
173 | + if (options.indicators) | ||
174 | + indicators[pos].addClass('visible'); | ||
175 | + | ||
176 | + // Finish hiding last slide after a short delay. | ||
177 | + window.setTimeout(function() { | ||
178 | + | ||
179 | + slides[lastPos].addClass('instant').removeClass('visible'); | ||
180 | + | ||
181 | + window.setTimeout(function() { | ||
182 | + | ||
183 | + slides[lastPos].removeClass('instant'); | ||
184 | + isLocked = false; | ||
185 | + | ||
186 | + }, 100); | ||
187 | + | ||
188 | + }, options.speed); | ||
189 | + | ||
190 | + }; | ||
191 | + | ||
192 | + // Indicators. | ||
193 | + if (options.indicators) | ||
194 | + $indicators = $('<ul class="indicators"></ul>').appendTo($this); | ||
195 | + | ||
196 | + // Slides. | ||
197 | + $slides | ||
198 | + .each(function() { | ||
199 | + | ||
200 | + var $slide = $(this), | ||
201 | + $img = $slide.find('img'); | ||
202 | + | ||
203 | + // Slide. | ||
204 | + $slide | ||
205 | + .css('background-image', 'url("' + $img.attr('src') + '")') | ||
206 | + .css('background-position', ($slide.data('position') ? $slide.data('position') : 'center')); | ||
207 | + | ||
208 | + // Add to slides. | ||
209 | + slides.push($slide); | ||
210 | + | ||
211 | + // Indicators. | ||
212 | + if (options.indicators) { | ||
213 | + | ||
214 | + var $indicator_li = $('<li>' + i + '</li>').appendTo($indicators); | ||
215 | + | ||
216 | + // Indicator. | ||
217 | + $indicator_li | ||
218 | + .data('index', i) | ||
219 | + .on('click', function() { | ||
220 | + $this._switchTo($(this).data('index'), true); | ||
221 | + }); | ||
222 | + | ||
223 | + // Add to indicators. | ||
224 | + indicators.push($indicator_li); | ||
225 | + | ||
226 | + } | ||
227 | + | ||
228 | + i++; | ||
229 | + | ||
230 | + }) | ||
231 | + ._parallax(options.parallax); | ||
232 | + | ||
233 | + // Initial slide. | ||
234 | + slides[pos].addClass('visible').addClass('top'); | ||
235 | + | ||
236 | + if (options.indicators) | ||
237 | + indicators[pos].addClass('visible'); | ||
238 | + | ||
239 | + // Bail if we only have a single slide. | ||
240 | + if (slides.length == 1) | ||
241 | + return; | ||
242 | + | ||
243 | + // Main loop. | ||
244 | + intervalId = window.setInterval(function() { | ||
245 | + | ||
246 | + current++; | ||
247 | + | ||
248 | + if (current >= slides.length) | ||
249 | + current = 0; | ||
250 | + | ||
251 | + $this._switchTo(current); | ||
252 | + | ||
253 | + }, options.delay); | ||
254 | + | ||
255 | + }; | ||
256 | + | ||
257 | + $(function() { | ||
258 | + | ||
259 | + var $window = $(window), | ||
260 | + $body = $('body'), | ||
261 | + $header = $('#header'), | ||
262 | + $banner = $('.banner'); | ||
263 | + | ||
264 | + // Disable animations/transitions until the page has loaded. | ||
265 | + $body.addClass('is-loading'); | ||
266 | + | ||
267 | + $window.on('load', function() { | ||
268 | + window.setTimeout(function() { | ||
269 | + $body.removeClass('is-loading'); | ||
270 | + }, 100); | ||
271 | + }); | ||
272 | + | ||
273 | + // Prioritize "important" elements on medium. | ||
274 | + skel.on('+medium -medium', function() { | ||
275 | + $.prioritize( | ||
276 | + '.important\\28 medium\\29', | ||
277 | + skel.breakpoint('medium').active | ||
278 | + ); | ||
279 | + }); | ||
280 | + | ||
281 | + // Banner. | ||
282 | + $banner._slider(settings.banner); | ||
283 | + | ||
284 | + // Menu. | ||
285 | + $('#menu') | ||
286 | + .append('<a href="#menu" class="close"></a>') | ||
287 | + .appendTo($body) | ||
288 | + .panel({ | ||
289 | + delay: 500, | ||
290 | + hideOnClick: true, | ||
291 | + hideOnSwipe: true, | ||
292 | + resetScroll: true, | ||
293 | + resetForms: true, | ||
294 | + side: 'right' | ||
295 | + }); | ||
296 | + | ||
297 | + // Header. | ||
298 | + if (skel.vars.IEVersion < 9) | ||
299 | + $header.removeClass('alt'); | ||
300 | + | ||
301 | + if ($banner.length > 0 | ||
302 | + && $header.hasClass('alt')) { | ||
303 | + | ||
304 | + $window.on('resize', function() { $window.trigger('scroll'); }); | ||
305 | + | ||
306 | + $banner.scrollex({ | ||
307 | + bottom: $header.outerHeight(), | ||
308 | + terminate: function() { $header.removeClass('alt'); }, | ||
309 | + enter: function() { $header.addClass('alt'); }, | ||
310 | + leave: function() { $header.removeClass('alt'); $header.addClass('reveal'); } | ||
311 | + }); | ||
312 | + | ||
313 | + } | ||
314 | + | ||
315 | + }); | ||
316 | + | ||
317 | +})(jQuery); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
screensaver/public/javascripts/skel.min.js
0 → 100644
1 | +/* skel.js v3.0.2-dev | (c) skel.io | MIT licensed */ | ||
2 | +var skel=function(){"use strict";var t={breakpointIds:null,events:{},isInit:!1,obj:{attachments:{},breakpoints:{},head:null,states:{}},sd:"/",state:null,stateHandlers:{},stateId:"",vars:{},DOMReady:null,indexOf:null,isArray:null,iterate:null,matchesMedia:null,extend:function(e,n){t.iterate(n,function(i){t.isArray(n[i])?(t.isArray(e[i])||(e[i]=[]),t.extend(e[i],n[i])):"object"==typeof n[i]?("object"!=typeof e[i]&&(e[i]={}),t.extend(e[i],n[i])):e[i]=n[i]})},newStyle:function(t){var e=document.createElement("style");return e.type="text/css",e.innerHTML=t,e},_canUse:null,canUse:function(e){t._canUse||(t._canUse=document.createElement("div"));var n=t._canUse.style,i=e.charAt(0).toUpperCase()+e.slice(1);return e in n||"Moz"+i in n||"Webkit"+i in n||"O"+i in n||"ms"+i in n},on:function(e,n){var i=e.split(/[\s]+/);return t.iterate(i,function(e){var a=i[e];if(t.isInit){if("init"==a)return void n();if("change"==a)n();else{var r=a.charAt(0);if("+"==r||"!"==r){var o=a.substring(1);if(o in t.obj.breakpoints)if("+"==r&&t.obj.breakpoints[o].active)n();else if("!"==r&&!t.obj.breakpoints[o].active)return void n()}}}t.events[a]||(t.events[a]=[]),t.events[a].push(n)}),t},trigger:function(e){if(t.events[e]&&0!=t.events[e].length)return t.iterate(t.events[e],function(n){t.events[e][n]()}),t},breakpoint:function(e){return t.obj.breakpoints[e]},breakpoints:function(e){function n(t,e){this.name=this.id=t,this.media=e,this.active=!1,this.wasActive=!1}return n.prototype.matches=function(){return t.matchesMedia(this.media)},n.prototype.sync=function(){this.wasActive=this.active,this.active=this.matches()},t.iterate(e,function(i){t.obj.breakpoints[i]=new n(i,e[i])}),window.setTimeout(function(){t.poll()},0),t},addStateHandler:function(e,n){t.stateHandlers[e]=n},callStateHandler:function(e){var n=t.stateHandlers[e]();t.iterate(n,function(e){t.state.attachments.push(n[e])})},changeState:function(e){t.iterate(t.obj.breakpoints,function(e){t.obj.breakpoints[e].sync()}),t.vars.lastStateId=t.stateId,t.stateId=e,t.breakpointIds=t.stateId===t.sd?[]:t.stateId.substring(1).split(t.sd),t.obj.states[t.stateId]?t.state=t.obj.states[t.stateId]:(t.obj.states[t.stateId]={attachments:[]},t.state=t.obj.states[t.stateId],t.iterate(t.stateHandlers,t.callStateHandler)),t.detachAll(t.state.attachments),t.attachAll(t.state.attachments),t.vars.stateId=t.stateId,t.vars.state=t.state,t.trigger("change"),t.iterate(t.obj.breakpoints,function(e){t.obj.breakpoints[e].active?t.obj.breakpoints[e].wasActive||t.trigger("+"+e):t.obj.breakpoints[e].wasActive&&t.trigger("-"+e)})},generateStateConfig:function(e,n){var i={};return t.extend(i,e),t.iterate(t.breakpointIds,function(e){t.extend(i,n[t.breakpointIds[e]])}),i},getStateId:function(){var e="";return t.iterate(t.obj.breakpoints,function(n){var i=t.obj.breakpoints[n];i.matches()&&(e+=t.sd+i.id)}),e},poll:function(){var e="";e=t.getStateId(),""===e&&(e=t.sd),e!==t.stateId&&t.changeState(e)},_attach:null,attach:function(e){var n=t.obj.head,i=e.element;return(!i.parentNode||!i.parentNode.tagName)&&(t._attach||(t._attach=n.firstChild),n.insertBefore(i,t._attach.nextSibling),e.permanent&&(t._attach=i),!0)},attachAll:function(e){var n=[];t.iterate(e,function(t){n[e[t].priority]||(n[e[t].priority]=[]),n[e[t].priority].push(e[t])}),n.reverse(),t.iterate(n,function(e){t.iterate(n[e],function(i){t.attach(n[e][i])})})},detach:function(t){var e=t.element;return!(t.permanent||!e.parentNode||e.parentNode&&!e.parentNode.tagName)&&(e.parentNode.removeChild(e),!0)},detachAll:function(e){var n={};t.iterate(e,function(t){n[e[t].id]=!0}),t.iterate(t.obj.attachments,function(e){e in n||t.detach(t.obj.attachments[e])})},attachment:function(e){return e in t.obj.attachments?t.obj.attachments[e]:null},newAttachment:function(e,n,i,a){return t.obj.attachments[e]={id:e,element:n,priority:i,permanent:a}},init:function(){t.initMethods(),t.initVars(),t.initEvents(),t.obj.head=document.getElementsByTagName("head")[0],t.isInit=!0,t.trigger("init")},initEvents:function(){t.on("resize",function(){t.poll()}),t.on("orientationChange",function(){t.poll()}),t.DOMReady(function(){t.trigger("ready")}),window.onload&&t.on("load",window.onload),window.onload=function(){t.trigger("load")},window.onresize&&t.on("resize",window.onresize),window.onresize=function(){t.trigger("resize")},window.onorientationchange&&t.on("orientationChange",window.onorientationchange),window.onorientationchange=function(){t.trigger("orientationChange")}},initMethods:function(){document.addEventListener?!function(e,n){t.DOMReady=n()}("domready",function(){function t(t){for(r=1;t=n.shift();)t()}var e,n=[],i=document,a="DOMContentLoaded",r=/^loaded|^c/.test(i.readyState);return i.addEventListener(a,e=function(){i.removeEventListener(a,e),t()}),function(t){r?t():n.push(t)}}):!function(e,n){t.DOMReady=n()}("domready",function(t){function e(t){for(h=1;t=i.shift();)t()}var n,i=[],a=!1,r=document,o=r.documentElement,s=o.doScroll,c="DOMContentLoaded",d="addEventListener",u="onreadystatechange",l="readyState",f=s?/^loaded|^c/:/^loaded|c/,h=f.test(r[l]);return r[d]&&r[d](c,n=function(){r.removeEventListener(c,n,a),e()},a),s&&r.attachEvent(u,n=function(){/^c/.test(r[l])&&(r.detachEvent(u,n),e())}),t=s?function(e){self!=top?h?e():i.push(e):function(){try{o.doScroll("left")}catch(n){return setTimeout(function(){t(e)},50)}e()}()}:function(t){h?t():i.push(t)}}),Array.prototype.indexOf?t.indexOf=function(t,e){return t.indexOf(e)}:t.indexOf=function(t,e){if("string"==typeof t)return t.indexOf(e);var n,i,a=e?e:0;if(!this)throw new TypeError;if(i=this.length,0===i||a>=i)return-1;for(a<0&&(a=i-Math.abs(a)),n=a;n<i;n++)if(this[n]===t)return n;return-1},Array.isArray?t.isArray=function(t){return Array.isArray(t)}:t.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},Object.keys?t.iterate=function(t,e){if(!t)return[];var n,i=Object.keys(t);for(n=0;i[n]&&e(i[n],t[i[n]])!==!1;n++);}:t.iterate=function(t,e){if(!t)return[];var n;for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])===!1)break},window.matchMedia?t.matchesMedia=function(t){return""==t||window.matchMedia(t).matches}:window.styleMedia||window.media?t.matchesMedia=function(t){if(""==t)return!0;var e=window.styleMedia||window.media;return e.matchMedium(t||"all")}:window.getComputedStyle?t.matchesMedia=function(t){if(""==t)return!0;var e=document.createElement("style"),n=document.getElementsByTagName("script")[0],i=null;e.type="text/css",e.id="matchmediajs-test",n.parentNode.insertBefore(e,n),i="getComputedStyle"in window&&window.getComputedStyle(e,null)||e.currentStyle;var a="@media "+t+"{ #matchmediajs-test { width: 1px; } }";return e.styleSheet?e.styleSheet.cssText=a:e.textContent=a,"1px"===i.width}:t.matchesMedia=function(t){if(""==t)return!0;var e,n,i,a,r={"min-width":null,"max-width":null},o=!1;for(i=t.split(/\s+and\s+/),e=0;e<i.length;e++)n=i[e],"("==n.charAt(0)&&(n=n.substring(1,n.length-1),a=n.split(/:\s+/),2==a.length&&(r[a[0].replace(/^\s+|\s+$/g,"")]=parseInt(a[1]),o=!0));if(!o)return!1;var s=document.documentElement.clientWidth,c=document.documentElement.clientHeight;return!(null!==r["min-width"]&&s<r["min-width"]||null!==r["max-width"]&&s>r["max-width"]||null!==r["min-height"]&&c<r["min-height"]||null!==r["max-height"]&&c>r["max-height"])},navigator.userAgent.match(/MSIE ([0-9]+)/)&&RegExp.$1<9&&(t.newStyle=function(t){var e=document.createElement("span");return e.innerHTML=' <style type="text/css">'+t+"</style>",e})},initVars:function(){var e,n,i,a=navigator.userAgent;e="other",n=0,i=[["firefox",/Firefox\/([0-9\.]+)/],["bb",/BlackBerry.+Version\/([0-9\.]+)/],["bb",/BB[0-9]+.+Version\/([0-9\.]+)/],["opera",/OPR\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)/],["edge",/Edge\/([0-9\.]+)/],["safari",/Version\/([0-9\.]+).+Safari/],["chrome",/Chrome\/([0-9\.]+)/],["ie",/MSIE ([0-9]+)/],["ie",/Trident\/.+rv:([0-9]+)/]],t.iterate(i,function(t,i){if(a.match(i[1]))return e=i[0],n=parseFloat(RegExp.$1),!1}),t.vars.browser=e,t.vars.browserVersion=n,e="other",n=0,i=[["ios",/([0-9_]+) like Mac OS X/,function(t){return t.replace("_",".").replace("_","")}],["ios",/CPU like Mac OS X/,function(t){return 0}],["wp",/Windows Phone ([0-9\.]+)/,null],["android",/Android ([0-9\.]+)/,null],["mac",/Macintosh.+Mac OS X ([0-9_]+)/,function(t){return t.replace("_",".").replace("_","")}],["windows",/Windows NT ([0-9\.]+)/,null],["bb",/BlackBerry.+Version\/([0-9\.]+)/,null],["bb",/BB[0-9]+.+Version\/([0-9\.]+)/,null]],t.iterate(i,function(t,i){if(a.match(i[1]))return e=i[0],n=parseFloat(i[2]?i[2](RegExp.$1):RegExp.$1),!1}),t.vars.os=e,t.vars.osVersion=n,t.vars.IEVersion="ie"==t.vars.browser?t.vars.browserVersion:99,t.vars.touch="wp"==t.vars.os?navigator.msMaxTouchPoints>0:!!("ontouchstart"in window),t.vars.mobile="wp"==t.vars.os||"android"==t.vars.os||"ios"==t.vars.os||"bb"==t.vars.os}};return t.init(),t}();!function(t,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():t.skel=e()}(this,function(){return skel}); |
screensaver/public/javascripts/util.js
0 → 100644
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
screensaver/public/stylesheets/main.css
0 → 100644
This diff is collapsed. Click to expand it.
1 | -var express = require('express'); | 1 | +var express = require("express"); |
2 | var router = express.Router(); | 2 | var router = express.Router(); |
3 | 3 | ||
4 | /* GET home page. */ | 4 | /* GET home page. */ |
5 | -router.get('/', function(req, res, next) { | 5 | +router.get("/", function (req, res, next) { |
6 | - res.render('index', { title: 'Express' }); | 6 | + res.render("index", { title: "Express" }); |
7 | }); | 7 | }); |
8 | 8 | ||
9 | module.exports = router; | 9 | module.exports = router; | ... | ... |
screensaver/routes/register.js
0 → 100644
1 | +var express = require("express"); | ||
2 | +var router = express.Router(); | ||
3 | +var AWS = require("aws-sdk"); | ||
4 | +var fs = require("fs"); | ||
5 | +AWS.config.loadFromPath("./config.json"); | ||
6 | +var rekognition = new AWS.Rekognition(); | ||
7 | + | ||
8 | +router.post("/", (req, res) => { | ||
9 | + var path_image = req.body.image; | ||
10 | + var params = {}; | ||
11 | + fs.readFile(path_image, function (err, data) { | ||
12 | + if (err) { | ||
13 | + console.log(err); | ||
14 | + } | ||
15 | + params = { | ||
16 | + CollectionId: "6jj2", | ||
17 | + DetectionAttributes: [], | ||
18 | + ExternalImageId: req.body.text, | ||
19 | + Image: { Bytes: data }, | ||
20 | + }; | ||
21 | + rekognition.indexFaces(params, function (err, data) { | ||
22 | + if (err) console.log(err, err.stack); | ||
23 | + // an error occurred | ||
24 | + else console.log(data); // successful response | ||
25 | + console.log("등록되었습니다."); | ||
26 | + res.redirect("/"); | ||
27 | + }); | ||
28 | + }); | ||
29 | +}); | ||
30 | + | ||
31 | +module.exports = router; |
screensaver/routes/use.js
0 → 100644
1 | +var express = require("express"); | ||
2 | +var router = express.Router(); | ||
3 | + | ||
4 | +const { exec } = require("child_process"); | ||
5 | + | ||
6 | +router.post("/", function (req, res, next) { | ||
7 | + console.log(req.body) | ||
8 | + if(req.body.landing == "true"){ | ||
9 | + res.render('use', { method: req.body.type }) | ||
10 | + } | ||
11 | + else{ | ||
12 | + exec( | ||
13 | + "python action.py " + | ||
14 | + req.body.type, | ||
15 | + (error, stdout, stderr) => { | ||
16 | + if (error) { | ||
17 | + res.render("error",{message : "Error", title:"No action.py", content:"make sure you have cloned github repository" }); | ||
18 | + return; | ||
19 | + } | ||
20 | + if (stderr) { | ||
21 | + res.render("error",{message : "Error", title:"No action.py", content:"make sure you have cloned github repository" }); | ||
22 | + return; | ||
23 | + } | ||
24 | + console.log(`stdout: ${stdout}`); | ||
25 | + res.render("action"); | ||
26 | + } | ||
27 | + ); | ||
28 | + } | ||
29 | +}); | ||
30 | + | ||
31 | +router.get("/", function (req, res, next) { | ||
32 | + res.render('use') | ||
33 | +}); | ||
34 | + | ||
35 | +module.exports = router; |
screensaver/routes/users.js
deleted
100644 → 0
screensaver/views/action.ejs
0 → 100644
... | @@ -2,10 +2,87 @@ | ... | @@ -2,10 +2,87 @@ |
2 | <html> | 2 | <html> |
3 | <head> | 3 | <head> |
4 | <title><%= title %></title> | 4 | <title><%= title %></title> |
5 | + <meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
6 | + <link rel="stylesheet" href="/stylesheets/main.css" /> | ||
5 | <link rel='stylesheet' href='/stylesheets/style.css' /> | 7 | <link rel='stylesheet' href='/stylesheets/style.css' /> |
6 | </head> | 8 | </head> |
7 | <body> | 9 | <body> |
8 | - <h1><%= title %></h1> | 10 | + <!-- <h1><%= title %></h1> |
9 | - <p>Welcome to <%= title %></p> | 11 | + <p>Welcome to <%= title %></p> --> |
12 | + <section class="banner full"> | ||
13 | + <article> | ||
14 | + <img src="images/unknown.png" alt="" /> | ||
15 | + <div class="inner"> | ||
16 | + <header> | ||
17 | + <p>protect your screen from unauthorized personnel</p> | ||
18 | + <h2>AI Screensaver</h2> | ||
19 | + </header> | ||
20 | + </div> | ||
21 | + </article> | ||
22 | + | ||
23 | + </section> | ||
24 | + | ||
25 | + <section id="one" class="wrapper style2"> | ||
26 | + <div class="inner"> | ||
27 | + <div class="grid-style"> | ||
28 | + | ||
29 | + <div> | ||
30 | + <div class="box"> | ||
31 | + <div class="image fit"> | ||
32 | + <img src="images/person_add.png" alt="" /> | ||
33 | + </div> | ||
34 | + <div class="content"> | ||
35 | + <header class="align-center"> | ||
36 | + <p>add user to AWS Rekognition FaceCollection</p> | ||
37 | + <h2>Add User</h2> | ||
38 | + </header> | ||
39 | + | ||
40 | + <footer class="align-center"> | ||
41 | + <form action=/register method="post"> | ||
42 | + <input type="file" id="image_path" name="image" accept="image/png, image/jpeg" class="button alt"> | ||
43 | + | ||
44 | + <input type="text" id="image_id" name="text" value="사진 이름""><input type="submit" value="등록" class="button alt" onclick="register_alert()"> | ||
45 | + </form> | ||
46 | + </footer> | ||
47 | + </div> | ||
48 | + </div> | ||
49 | + </div> | ||
50 | + | ||
51 | + <div> | ||
52 | + <div class="box"> | ||
53 | + <div class="image fit"> | ||
54 | + <img src="images/play.png" alt="" /> | ||
55 | + </div> | ||
56 | + <div class="content"> | ||
57 | + <header class="align-center"> | ||
58 | + <p>Detect Personnel and analyze</p> | ||
59 | + <h2>Run Detection</h2> | ||
60 | + </header> | ||
61 | + <footer class="align-center"> | ||
62 | + <form action="/use" method="post"> | ||
63 | + <input type="hidden" name="landing" id="landing" value="true" /> | ||
64 | + <label for="type">Choose a type:</label> | ||
65 | + <select name="type" id="type" class="button alt"> | ||
66 | + <option value="Desktop">바탕화면</option> | ||
67 | + <option value="Logout">로그아웃</option> | ||
68 | + <option value="NewDesktop">화면전환</option> | ||
69 | + </select> | ||
70 | + | ||
71 | + <input type="submit" value="시작" class="button alt"> | ||
72 | + </form> | ||
73 | + </footer> | ||
74 | + </div> | ||
75 | + </div> | ||
76 | + </div> | ||
77 | + | ||
78 | + </div> | ||
79 | + </div> | ||
80 | + </section> | ||
81 | + | ||
82 | + <script src="javascripts/jquery.min.js"></script> | ||
83 | + <script src="javascripts/jquery.scrollex.min.js"></script> | ||
84 | + <script src="javascripts/skel.min.js"></script> | ||
85 | + <script src="javascripts/util.js"></script> | ||
86 | + <script src="javascripts/main.js"></script> | ||
10 | </body> | 87 | </body> |
11 | </html> | 88 | </html> | ... | ... |
screensaver/views/use.ejs
0 → 100644
1 | +<!-- Copyright 2019 Google LLC. All Rights Reserved. | ||
2 | + | ||
3 | +Licensed under the Apache License, Version 2.0 (the "License"); | ||
4 | +you may not use this file except in compliance with the License. | ||
5 | +You may obtain a copy of the License at | ||
6 | + | ||
7 | + http://www.apache.org/licenses/LICENSE-2.0 | ||
8 | + | ||
9 | +Unless required by applicable law or agreed to in writing, software | ||
10 | +distributed under the License is distributed on an "AS IS" BASIS, | ||
11 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
12 | +See the License for the specific language governing permissions and | ||
13 | +limitations under the License. | ||
14 | +==============================================================================--> | ||
15 | + | ||
16 | +<style> | ||
17 | + body { | ||
18 | + margin: 25px; | ||
19 | + } | ||
20 | + | ||
21 | + #main { | ||
22 | + position: relative; | ||
23 | + margin: 50px 0; | ||
24 | + } | ||
25 | + | ||
26 | + canvas { | ||
27 | + position: absolute; | ||
28 | + top: 0; | ||
29 | + left: 0; | ||
30 | + } | ||
31 | + | ||
32 | + #description { | ||
33 | + margin-top: 20px; | ||
34 | + width: 600px; | ||
35 | + } | ||
36 | + | ||
37 | + #description-title { | ||
38 | + font-weight: bold; | ||
39 | + font-size: 18px; | ||
40 | + } | ||
41 | +</style> | ||
42 | + | ||
43 | +<body> | ||
44 | + <div id="main"> | ||
45 | + <video id="video" playsinline style=" | ||
46 | + -webkit-transform: scaleX(-1); | ||
47 | + transform: scaleX(-1); | ||
48 | + width: auto; | ||
49 | + height: auto; | ||
50 | + "> | ||
51 | + </video> | ||
52 | + <canvas id="output"></canvas> | ||
53 | + <div id="description"> | ||
54 | + <div id="description-title">Face Detecting...</div> | ||
55 | + | ||
56 | + </div> | ||
57 | + <video id="video" playsinline style=" | ||
58 | + -webkit-transform: scaleX(-1); | ||
59 | + transform: scaleX(-1); | ||
60 | + visibility: hidden; | ||
61 | + width: auto; | ||
62 | + height: auto; | ||
63 | + "> | ||
64 | + </video> | ||
65 | + </div> | ||
66 | + <input type="button" id="AWS_button" onclick="onClick();" value="버튼1" /> | ||
67 | + <form> | ||
68 | + <input type="hidden" id="method" name="method" value=<%= method %> /> | ||
69 | + </form> | ||
70 | +</body> | ||
71 | +<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"></script> | ||
72 | +<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm"></script> | ||
73 | +<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/blazeface"></script> | ||
74 | +<script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.6/dat.gui.min.js"></script> | ||
75 | +<script src="https://cdnjs.cloudflare.com/ajax/libs/stats.js/r16/Stats.min.js"></script> | ||
76 | +<script src="https://sdk.amazonaws.com/js/aws-sdk-2.799.0.min.js"></script> | ||
77 | +<script src="javascripts/aws_setup.js"></script> | ||
78 | +<script src="javascripts/index.js"></script> |
-
Please register or login to post a comment