Toggle navigation
Toggle navigation
This project
Loading...
Sign in
seungmin lee
/
OSS2020-2_Screensaver
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
이민호
2020-12-10 00:52:20 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e14ccb491d85b6d27684a0967b06e7316d3ad6b8
e14ccb49
1 parent
4c0be6ba
add version 1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
187 additions
and
1 deletions
screensaver/bin/www
screensaver_1/index.ejs
screensaver_1/use.js
screensaver/bin/www
View file @
e14ccb4
...
...
@@ -50,7 +50,7 @@ try {
* Get port from environment and store in Express.
*/
var
port
=
normalizePort
(
process
.
env
.
PORT
||
"
808
0"
);
var
port
=
normalizePort
(
process
.
env
.
PORT
||
"
300
0"
);
app
.
set
(
"port"
,
port
);
/**
...
...
screensaver_1/index.ejs
0 → 100644
View file @
e14ccb4
<!DOCTYPE html>
<html>
<head>
<title>
<
%= title %>
</title>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
/>
<link
rel=
"stylesheet"
href=
"/stylesheets/main.css"
/>
<link
rel=
'stylesheet'
href=
'/stylesheets/style.css'
/>
</head>
<body>
<!-- <h1><%= title %></h1>
<p>Welcome to <%= title %></p> -->
<section
class=
"banner full"
>
<article>
<img
src=
"images/unknown.png"
alt=
""
/>
<div
class=
"inner"
>
<header>
<p>
protect your screen from unauthorized personnel
</p>
<h2>
AI Screensaver
</h2>
</header>
</div>
</article>
</section>
<section
id=
"one"
class=
"wrapper style2"
>
<div
class=
"inner"
>
<div
class=
"grid-style"
>
<div>
<div
class=
"box"
>
<div
class=
"image fit"
>
<img
src=
"images/person_add.png"
alt=
""
/>
</div>
<div
class=
"content"
>
<header
class=
"align-center"
>
<p>
add user to AWS Rekognition FaceCollection
</p>
<h2>
Add User
</h2>
</header>
<footer
class=
"align-center"
>
<form
action=
/register
method=
"post"
enctype=
"multipart/form-data"
>
<input
type=
"file"
id=
"img"
name=
"img"
accept=
"image/png, image/jpeg"
class=
"button alt"
>
<input
type=
'hidden'
name=
"collection"
id=
'collection'
value=
"<%= collection %>"
>
<input
type=
"text"
id=
"image_id"
name=
"text"
placeholder=
"사진 이름"
required
><input
type=
"submit"
value=
"등록"
class=
"button alt"
"
>
</form>
</footer>
</div>
</div>
</div>
<div>
<div
class=
"box"
>
<div
class=
"image fit"
>
<img
src=
"images/play.png"
alt=
""
/>
</div>
<div
class=
"content"
>
<header
class=
"align-center"
>
<p>
Detect Personnel and analyze
</p>
<h2>
Run Detection
</h2>
</header>
<footer
class=
"align-center"
>
<form
action=
"/use"
method=
"post"
>
<input
type=
"hidden"
name=
"landing"
id=
"landing"
value=
"true"
/>
<!-- <label for="type">Password (4 characters minimum):</label>
<input type='password' name='type' id='type' minlength="4" required/> -->
<input
type=
'hidden'
name=
"collection"
id=
'collection'
value=
"<%= collection %>"
>
<select
name=
"type"
id=
"type"
class=
"button alt"
>
<option
value=
"Desktop"
>
바탕화면
</option>
<option
value=
"Logout"
>
로그아웃
</option>
<option
value=
"NewDesktop"
>
화면전환
</option>
</select>
<input
type=
"submit"
value=
"시작"
class=
"button alt"
>
</form>
</footer>
</div>
</div>
</div>
</div>
</div>
</section>
<script
src=
"javascripts/jquery.min.js"
></script>
<script
src=
"javascripts/jquery.scrollex.min.js"
></script>
<script
src=
"javascripts/skel.min.js"
></script>
<script
src=
"javascripts/util.js"
></script>
<script
src=
"javascripts/main.js"
></script>
<script
type=
"text/javascript"
>
var
error
=
'<%= error %>'
;
if
(
error
!=
''
)
{
alert
(
error
);
}
</script>
</body>
</html>
screensaver_1/use.js
0 → 100644
View file @
e14ccb4
var
express
=
require
(
"express"
);
var
router
=
express
.
Router
();
var
AWS
=
require
(
"aws-sdk"
);
var
fs
=
require
(
"fs"
);
var
atob
=
require
(
"atob"
);
AWS
.
config
.
loadFromPath
(
"./config.json"
);
var
rekognition
=
new
AWS
.
Rekognition
();
const
{
exec
}
=
require
(
"child_process"
);
router
.
post
(
"/"
,
function
(
req
,
res
,
next
)
{
console
.
log
(
req
.
body
);
if
(
req
.
body
.
landing
==
"true"
)
{
res
.
render
(
"use"
,
{
method
:
req
.
body
.
type
,
collection
:
req
.
body
.
collection
,
});
}
else
{
image
=
req
.
body
.
image
;
console
.
log
(
req
.
body
.
collection
);
// console.log(image)
// var img_arr = req.body.image.split(',').map(function(item) {
// return parseInt(item, 10);
// });
// console.log(img_arr)
// enc_data = Buffer.from(image.split("data:image/png;base64,")[1], 'base64').toString('ascii')
if
(
image
[
11
]
==
"p"
)
enc_data
=
atob
(
image
.
split
(
"data:image/png;base64,"
)[
1
]);
else
if
(
image
[
11
]
==
"j"
)
enc_data
=
atob
(
image
.
split
(
"data:image/jpeg;base64,"
)[
1
]);
var
length
=
enc_data
.
length
;
imageBytes
=
new
ArrayBuffer
(
length
);
var
ua
=
new
Uint8Array
(
imageBytes
);
for
(
var
i
=
0
;
i
<
length
;
i
++
)
{
ua
[
i
]
=
enc_data
.
charCodeAt
(
i
);
}
// console.log(imageBytes)
var
params
=
{
CollectionId
:
req
.
body
.
collection
,
FaceMatchThreshold
:
95
,
Image
:
{
Bytes
:
imageBytes
,
},
MaxFaces
:
5
,
};
rekognition
.
searchFacesByImage
(
params
,
function
(
err
,
data
)
{
if
(
err
)
{
console
.
log
(
err
,
err
.
stack
);
}
else
{
if
(
data
.
FaceMatches
.
length
>
0
)
{
res
.
render
(
"redirect"
,
{
error
:
"Recognized!"
,
collection
:
req
.
body
.
collection
,
});
}
else
{
exec
(
"python action.py "
+
req
.
body
.
type
,
(
error
,
stdout
,
stderr
)
=>
{
if
(
error
)
{
res
.
render
(
"error"
,
{
message
:
"Error"
,
title
:
"No action.py"
,
content
:
"make sure you have cloned github repository"
,
});
return
;
}
if
(
stderr
)
{
res
.
render
(
"error"
,
{
message
:
"Error"
,
title
:
"No action.py"
,
content
:
"make sure you have cloned github repository"
,
});
return
;
}
console
.
log
(
`stdout:
${
stdout
}
`
);
res
.
render
(
"action"
);
});
}
}
});
}
});
router
.
get
(
"/"
,
function
(
req
,
res
,
next
)
{
res
.
render
(
"use"
);
});
module
.
exports
=
router
;
Please
register
or
login
to post a comment