seungmin lee

upload image added, random collection added

...@@ -18,6 +18,11 @@ ...@@ -18,6 +18,11 @@
18 "negotiator": "0.6.2" 18 "negotiator": "0.6.2"
19 } 19 }
20 }, 20 },
21 + "append-field": {
22 + "version": "1.0.0",
23 + "resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz",
24 + "integrity": "sha1-HjRA6RXwsSA9I3SOeO3XubW0PlY="
25 + },
21 "array-flatten": { 26 "array-flatten": {
22 "version": "1.1.1", 27 "version": "1.1.1",
23 "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", 28 "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
...@@ -84,11 +89,60 @@ ...@@ -84,11 +89,60 @@
84 "isarray": "^1.0.0" 89 "isarray": "^1.0.0"
85 } 90 }
86 }, 91 },
92 + "buffer-from": {
93 + "version": "1.1.1",
94 + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
95 + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A=="
96 + },
97 + "busboy": {
98 + "version": "0.2.14",
99 + "resolved": "https://registry.npmjs.org/busboy/-/busboy-0.2.14.tgz",
100 + "integrity": "sha1-bCpiLvz0fFe7vh4qnDetNseSVFM=",
101 + "requires": {
102 + "dicer": "0.2.5",
103 + "readable-stream": "1.1.x"
104 + }
105 + },
87 "bytes": { 106 "bytes": {
88 "version": "3.0.0", 107 "version": "3.0.0",
89 "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", 108 "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz",
90 "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" 109 "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg="
91 }, 110 },
111 + "concat-stream": {
112 + "version": "1.6.2",
113 + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
114 + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
115 + "requires": {
116 + "buffer-from": "^1.0.0",
117 + "inherits": "^2.0.3",
118 + "readable-stream": "^2.2.2",
119 + "typedarray": "^0.0.6"
120 + },
121 + "dependencies": {
122 + "readable-stream": {
123 + "version": "2.3.7",
124 + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz",
125 + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==",
126 + "requires": {
127 + "core-util-is": "~1.0.0",
128 + "inherits": "~2.0.3",
129 + "isarray": "~1.0.0",
130 + "process-nextick-args": "~2.0.0",
131 + "safe-buffer": "~5.1.1",
132 + "string_decoder": "~1.1.1",
133 + "util-deprecate": "~1.0.1"
134 + }
135 + },
136 + "string_decoder": {
137 + "version": "1.1.1",
138 + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
139 + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
140 + "requires": {
141 + "safe-buffer": "~5.1.0"
142 + }
143 + }
144 + }
145 + },
92 "content-disposition": { 146 "content-disposition": {
93 "version": "0.5.2", 147 "version": "0.5.2",
94 "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", 148 "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz",
...@@ -118,6 +172,11 @@ ...@@ -118,6 +172,11 @@
118 "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", 172 "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
119 "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" 173 "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
120 }, 174 },
175 + "core-util-is": {
176 + "version": "1.0.2",
177 + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
178 + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
179 + },
121 "debug": { 180 "debug": {
122 "version": "2.6.9", 181 "version": "2.6.9",
123 "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", 182 "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
...@@ -136,6 +195,15 @@ ...@@ -136,6 +195,15 @@
136 "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", 195 "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
137 "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" 196 "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
138 }, 197 },
198 + "dicer": {
199 + "version": "0.2.5",
200 + "resolved": "https://registry.npmjs.org/dicer/-/dicer-0.2.5.tgz",
201 + "integrity": "sha1-WZbAhrszIYyBLAkL3cCc0S+stw8=",
202 + "requires": {
203 + "readable-stream": "1.1.x",
204 + "streamsearch": "0.1.2"
205 + }
206 + },
139 "ee-first": { 207 "ee-first": {
140 "version": "1.1.1", 208 "version": "1.1.1",
141 "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", 209 "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
...@@ -311,6 +379,19 @@ ...@@ -311,6 +379,19 @@
311 "mime-db": "1.44.0" 379 "mime-db": "1.44.0"
312 } 380 }
313 }, 381 },
382 + "minimist": {
383 + "version": "1.2.5",
384 + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
385 + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
386 + },
387 + "mkdirp": {
388 + "version": "0.5.5",
389 + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
390 + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
391 + "requires": {
392 + "minimist": "^1.2.5"
393 + }
394 + },
314 "morgan": { 395 "morgan": {
315 "version": "1.9.1", 396 "version": "1.9.1",
316 "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.9.1.tgz", 397 "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.9.1.tgz",
...@@ -328,11 +409,31 @@ ...@@ -328,11 +409,31 @@
328 "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 409 "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
329 "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" 410 "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
330 }, 411 },
412 + "multer": {
413 + "version": "1.4.2",
414 + "resolved": "https://registry.npmjs.org/multer/-/multer-1.4.2.tgz",
415 + "integrity": "sha512-xY8pX7V+ybyUpbYMxtjM9KAiD9ixtg5/JkeKUTD6xilfDv0vzzOFcCp4Ljb1UU3tSOM3VTZtKo63OmzOrGi3Cg==",
416 + "requires": {
417 + "append-field": "^1.0.0",
418 + "busboy": "^0.2.11",
419 + "concat-stream": "^1.5.2",
420 + "mkdirp": "^0.5.1",
421 + "object-assign": "^4.1.1",
422 + "on-finished": "^2.3.0",
423 + "type-is": "^1.6.4",
424 + "xtend": "^4.0.0"
425 + }
426 + },
331 "negotiator": { 427 "negotiator": {
332 "version": "0.6.2", 428 "version": "0.6.2",
333 "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", 429 "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz",
334 "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" 430 "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw=="
335 }, 431 },
432 + "object-assign": {
433 + "version": "4.1.1",
434 + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
435 + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM="
436 + },
336 "on-finished": { 437 "on-finished": {
337 "version": "2.3.0", 438 "version": "2.3.0",
338 "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", 439 "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
...@@ -356,6 +457,11 @@ ...@@ -356,6 +457,11 @@
356 "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", 457 "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
357 "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" 458 "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
358 }, 459 },
460 + "process-nextick-args": {
461 + "version": "2.0.1",
462 + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
463 + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="
464 + },
359 "proxy-addr": { 465 "proxy-addr": {
360 "version": "2.0.6", 466 "version": "2.0.6",
361 "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz", 467 "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz",
...@@ -401,6 +507,24 @@ ...@@ -401,6 +507,24 @@
401 "unpipe": "1.0.0" 507 "unpipe": "1.0.0"
402 } 508 }
403 }, 509 },
510 + "readable-stream": {
511 + "version": "1.1.14",
512 + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
513 + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=",
514 + "requires": {
515 + "core-util-is": "~1.0.0",
516 + "inherits": "~2.0.1",
517 + "isarray": "0.0.1",
518 + "string_decoder": "~0.10.x"
519 + },
520 + "dependencies": {
521 + "isarray": {
522 + "version": "0.0.1",
523 + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
524 + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8="
525 + }
526 + }
527 + },
404 "safe-buffer": { 528 "safe-buffer": {
405 "version": "5.1.2", 529 "version": "5.1.2",
406 "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", 530 "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
...@@ -457,6 +581,16 @@ ...@@ -457,6 +581,16 @@
457 "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", 581 "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz",
458 "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" 582 "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew=="
459 }, 583 },
584 + "streamsearch": {
585 + "version": "0.1.2",
586 + "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz",
587 + "integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo="
588 + },
589 + "string_decoder": {
590 + "version": "0.10.31",
591 + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
592 + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ="
593 + },
460 "type-is": { 594 "type-is": {
461 "version": "1.6.18", 595 "version": "1.6.18",
462 "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", 596 "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
...@@ -466,6 +600,11 @@ ...@@ -466,6 +600,11 @@
466 "mime-types": "~2.1.24" 600 "mime-types": "~2.1.24"
467 } 601 }
468 }, 602 },
603 + "typedarray": {
604 + "version": "0.0.6",
605 + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
606 + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c="
607 + },
469 "unpipe": { 608 "unpipe": {
470 "version": "1.0.0", 609 "version": "1.0.0",
471 "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", 610 "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
...@@ -480,6 +619,11 @@ ...@@ -480,6 +619,11 @@
480 "querystring": "0.2.0" 619 "querystring": "0.2.0"
481 } 620 }
482 }, 621 },
622 + "util-deprecate": {
623 + "version": "1.0.2",
624 + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
625 + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
626 + },
483 "utils-merge": { 627 "utils-merge": {
484 "version": "1.0.1", 628 "version": "1.0.1",
485 "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", 629 "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
...@@ -508,6 +652,11 @@ ...@@ -508,6 +652,11 @@
508 "version": "9.0.7", 652 "version": "9.0.7",
509 "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", 653 "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz",
510 "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=" 654 "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0="
655 + },
656 + "xtend": {
657 + "version": "4.0.2",
658 + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
659 + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ=="
511 } 660 }
512 } 661 }
513 } 662 }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
15 "express": "~4.16.1", 15 "express": "~4.16.1",
16 "http-errors": "^1.6.3", 16 "http-errors": "^1.6.3",
17 "morgan": "~1.9.1", 17 "morgan": "~1.9.1",
18 + "multer": "^1.4.2",
18 "python-shell": "^2.0.2" 19 "python-shell": "^2.0.2"
19 } 20 }
20 } 21 }
......
...@@ -56,6 +56,8 @@ async function setupCamera() { ...@@ -56,6 +56,8 @@ async function setupCamera() {
56 async function AWS_req(img_byte){ 56 async function AWS_req(img_byte){
57 let element = document.getElementById('method'); 57 let element = document.getElementById('method');
58 console.log(element.value) 58 console.log(element.value)
59 + let collection = document.getElementById('collection');
60 +
59 var rekognition = new AWS.Rekognition(); 61 var rekognition = new AWS.Rekognition();
60 var params = { 62 var params = {
61 CollectionId: "6jj2", 63 CollectionId: "6jj2",
...@@ -66,10 +68,10 @@ async function AWS_req(img_byte){ ...@@ -66,10 +68,10 @@ async function AWS_req(img_byte){
66 MaxFaces: 5 68 MaxFaces: 5
67 }; 69 };
68 post_data = { 70 post_data = {
69 - "result": false,
70 "type" : element.value, 71 "type" : element.value,
71 "landing": "false", 72 "landing": "false",
72 - "image":img_byte 73 + "image":img_byte,
74 + "collection" :collection.value
73 } 75 }
74 console.log(img_byte) 76 console.log(img_byte)
75 redirectPost("/use",post_data) 77 redirectPost("/use",post_data)
......
...@@ -3,9 +3,7 @@ ...@@ -3,9 +3,7 @@
3 templated.co @templatedco 3 templated.co @templatedco
4 Released for free under the Creative Commons Attribution 3.0 license (templated.co/license) 4 Released for free under the Creative Commons Attribution 3.0 license (templated.co/license)
5 */ 5 */
6 -function register_alert(){ 6 +
7 - alert("등록되었습니다.")
8 -}
9 var settings = { 7 var settings = {
10 8
11 banner: { 9 banner: {
......
1 var express = require("express"); 1 var express = require("express");
2 var router = express.Router(); 2 var router = express.Router();
3 +function makeid(length) {
4 + var result = '';
5 + var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
6 + var charactersLength = characters.length;
7 + for ( var i = 0; i < length; i++ ) {
8 + result += characters.charAt(Math.floor(Math.random() * charactersLength));
9 + }
10 + return result;
11 +}
12 +var AWS = require("aws-sdk");
13 +AWS.config.loadFromPath("./config.json");
14 +var rekognition = new AWS.Rekognition();
3 15
4 /* GET home page. */ 16 /* GET home page. */
5 router.get("/", function (req, res, next) { 17 router.get("/", function (req, res, next) {
6 - res.render("index", { title: "Express" }); 18 + var collectionID = makeid(8)
19 + var params = {
20 + CollectionId: collectionID
21 + };
22 + rekognition.createCollection(params, function(err, data) {
23 + if (err) console.log(err, err.stack); // an error occurred
24 + else console.log(data); // successful response
25 + });
26 + console.log(collectionID)
27 + res.render("index", { title: "Express", error:"",collection: collectionID});
28 +});
29 +router.post("/", function (req, res, next){
30 + console.log(req.body.collection)
31 + res.render("index", { title: "Express", error:"",collection: req.body.collection});
7 }); 32 });
8 -
9 module.exports = router; 33 module.exports = router;
......
...@@ -2,28 +2,53 @@ var express = require("express"); ...@@ -2,28 +2,53 @@ var express = require("express");
2 var router = express.Router(); 2 var router = express.Router();
3 var AWS = require("aws-sdk"); 3 var AWS = require("aws-sdk");
4 var fs = require("fs"); 4 var fs = require("fs");
5 +const path = require('path');
5 AWS.config.loadFromPath("./config.json"); 6 AWS.config.loadFromPath("./config.json");
7 +const multer = require('multer');
6 var rekognition = new AWS.Rekognition(); 8 var rekognition = new AWS.Rekognition();
7 - 9 +const upload = multer({
8 -router.post("/", (req, res) => { 10 + storage: multer.diskStorage({
9 - var path_image = req.body.image; 11 + destination(req, file, cb){
10 - var params = {}; 12 + cb(null, 'uploads/')
11 - fs.readFile(path_image, function (err, data) { 13 + },
14 + filename(req, file, cb){
15 + // 확장자 추출
16 + const ext = path.extname(file.originalname);
17 + // 이름설정 (basename:확장자제외 파일명) + 현재시간 + 확장자
18 + cb(null, path.basename(file.originalname, ext) + new Date().valueOf() + ext);
19 + },
20 + }),
21 + limit: { fileSize: 5 * 1024 * 1024},
22 +});
23 +router.post("/", upload.single('img'), (req, res) => {
24 + console.log(req.file)
25 +
26 + fs.readFile(req.file.path, function (err, data) {
12 if (err) { 27 if (err) {
13 console.log(err); 28 console.log(err);
14 } 29 }
15 params = { 30 params = {
16 - CollectionId: "6jj2", 31 + CollectionId: req.body.collection,
17 DetectionAttributes: [], 32 DetectionAttributes: [],
18 ExternalImageId: req.body.text, 33 ExternalImageId: req.body.text,
19 Image: { Bytes: data }, 34 Image: { Bytes: data },
20 }; 35 };
21 rekognition.indexFaces(params, function (err, data) { 36 rekognition.indexFaces(params, function (err, data) {
22 - if (err) console.log(err, err.stack); 37 + if (err) {
38 + console.log(err, err.stack);
39 + res.render('redirect', {error:"not registered! is there any faces on image?",collection: req.body.collection})
40 + }
23 // an error occurred 41 // an error occurred
24 else console.log(data); // successful response 42 else console.log(data); // successful response
25 - console.log("등록되었습니다."); 43 +
26 - res.redirect("/"); 44 + fs.unlink(req.file.path, (err) => {
45 + if (err) throw err;
46 + console.log('image was deleted');
47 + });
48 + if(data.FaceRecords.length>0)
49 + res.render('redirect', {error:"registered!",collection: req.body.collection})
50 + else
51 + res.render('redirect', {error:"not registered! is there any faces on image?",collection: req.body.collection})
27 }); 52 });
28 }); 53 });
29 }); 54 });
......
...@@ -11,10 +11,11 @@ const { exec } = require("child_process"); ...@@ -11,10 +11,11 @@ const { exec } = require("child_process");
11 router.post("/", function (req, res, next) { 11 router.post("/", function (req, res, next) {
12 console.log(req.body) 12 console.log(req.body)
13 if (req.body.landing == "true") { 13 if (req.body.landing == "true") {
14 - res.render('use', { method: req.body.type }) 14 + res.render('use', { method: req.body.type,collection:req.body.collection })
15 } 15 }
16 else { 16 else {
17 image = req.body.image 17 image = req.body.image
18 + console.log(req.body.collection)
18 // console.log(image) 19 // console.log(image)
19 // var img_arr = req.body.image.split(',').map(function(item) { 20 // var img_arr = req.body.image.split(',').map(function(item) {
20 // return parseInt(item, 10); 21 // return parseInt(item, 10);
...@@ -33,7 +34,7 @@ router.post("/", function (req, res, next) { ...@@ -33,7 +34,7 @@ router.post("/", function (req, res, next) {
33 } 34 }
34 // console.log(imageBytes) 35 // console.log(imageBytes)
35 var params = { 36 var params = {
36 - CollectionId: "6jj2", 37 + CollectionId: req.body.collection,
37 FaceMatchThreshold: 95, 38 FaceMatchThreshold: 95,
38 Image: { 39 Image: {
39 Bytes: imageBytes 40 Bytes: imageBytes
...@@ -46,7 +47,7 @@ router.post("/", function (req, res, next) { ...@@ -46,7 +47,7 @@ router.post("/", function (req, res, next) {
46 } 47 }
47 else { 48 else {
48 if (data.FaceMatches.length>0){ 49 if (data.FaceMatches.length>0){
49 - res.redirect("/"); 50 + res.render("redirect", {error:"Recognized!",collection: req.body.collection });
50 } 51 }
51 else{ 52 else{
52 // todo 잠금 페이지로 이동. 53 // todo 잠금 페이지로 이동.
......
...@@ -38,10 +38,10 @@ ...@@ -38,10 +38,10 @@
38 </header> 38 </header>
39 39
40 <footer class="align-center"> 40 <footer class="align-center">
41 - <form action=/register method="post"> 41 + <form action=/register method="post" enctype="multipart/form-data">
42 - <input type="file" id="image_path" name="image" accept="image/png, image/jpeg" class="button alt"> 42 + <input type="file" id="img" name="img" accept="image/png, image/jpeg" class="button alt">
43 - 43 + <input type='hidden' name="collection" id='collection' value="<%= collection %>" >
44 - <input type="text" id="image_id" name="text" value="사진 이름""><input type="submit" value="등록" class="button alt" onclick="register_alert()"> 44 + <input type="text" id="image_id" name="text" value="사진 이름""><input type="submit" value="등록" class="button alt"">
45 </form> 45 </form>
46 </footer> 46 </footer>
47 </div> 47 </div>
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
63 <input type="hidden" name="landing" id="landing" value="true" /> 63 <input type="hidden" name="landing" id="landing" value="true" />
64 <label for="type">Input Password:</label> 64 <label for="type">Input Password:</label>
65 <input type='password' name='type' id='type'/> 65 <input type='password' name='type' id='type'/>
66 - 66 + <input type='hidden' name="collection" id='collection' value="<%= collection %>" >
67 <!-- <select name="type" id="type" class="button alt"> 67 <!-- <select name="type" id="type" class="button alt">
68 <option value="Desktop">바탕화면</option> 68 <option value="Desktop">바탕화면</option>
69 <option value="Logout">로그아웃</option> 69 <option value="Logout">로그아웃</option>
...@@ -85,6 +85,16 @@ ...@@ -85,6 +85,16 @@
85 <script src="javascripts/jquery.scrollex.min.js"></script> 85 <script src="javascripts/jquery.scrollex.min.js"></script>
86 <script src="javascripts/skel.min.js"></script> 86 <script src="javascripts/skel.min.js"></script>
87 <script src="javascripts/util.js"></script> 87 <script src="javascripts/util.js"></script>
88 - <script src="javascripts/main.js"></script> 88 + <script src="javascripts/main.js"></script>
89 + <script type="text/javascript">
90 + var error = '<%= error %>';
91 +
92 + if(error!='')
93 + {
94 + alert(error);
95 + }
96 +
97 +
98 + </script>
89 </body> 99 </body>
90 </html> 100 </html>
......
1 +<body>
2 +
3 +</body>
4 +<script type="text/javascript">
5 + var error = '<%= error %>';
6 +
7 + if(error!='')
8 + {
9 + alert(error);
10 + }
11 + function redirectPost(url, data) {
12 + var form = document.createElement('form');
13 + document.body.appendChild(form);
14 + form.method = 'post';
15 + form.action = url;
16 + for (var name in data) {
17 + var input = document.createElement('input');
18 + input.type = 'hidden';
19 + input.name = name;
20 + input.value = data[name];
21 + form.appendChild(input);
22 + }
23 + form.submit();
24 +}
25 +post_data = {
26 + "collection":'<%= collection %>'
27 +}
28 + // window.location.href='/'
29 + redirectPost('/',post_data)
30 + </script>
...\ No newline at end of file ...\ No newline at end of file
...@@ -66,6 +66,7 @@ limitations under the License. ...@@ -66,6 +66,7 @@ limitations under the License.
66 <input type="button" id="AWS_button" onclick="onClick();" value="버튼1" /> 66 <input type="button" id="AWS_button" onclick="onClick();" value="버튼1" />
67 <form> 67 <form>
68 <input type="hidden" id="method" name="method" value=<%= method %> /> 68 <input type="hidden" id="method" name="method" value=<%= method %> />
69 + <input type="hidden" id="collection" name="collection" value=<%= collection %> />
69 </form> 70 </form>
70 </body> 71 </body>
71 <script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"></script> 72 <script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"></script>
......