Toggle navigation
Toggle navigation
This project
Loading...
Sign in
임연수
/
FaceDetection
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
2
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
임연수
2018-12-14 03:31:00 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e19f4019bccbb447c6a9b63b30b23d1bcaa05e21
e19f4019
1 parent
97ebb162
change upload filename as it's own name
add gitignore upload folder
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
18 deletions
.gitignore
app.js
views/facedetection.html
.gitignore
View file @
e19f401
node_modules/
.idea/
package-lock.json
\ No newline at end of file
package-lock.json
/uploads
\ No newline at end of file
...
...
app.js
View file @
e19f401
...
...
@@ -14,13 +14,13 @@ app.set('view engine', 'html');
app
.
engine
(
'html'
,
require
(
'ejs'
).
renderFile
);
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
false
}));
var
imgname
;
var
storage
=
multer
.
diskStorage
({
//이 객체의 프로퍼티는 2개갖고 있다.
destination
:
function
(
req
,
file
,
cb
)
{
cb
(
null
,
'uploads/'
);
//업로드 위치를 저장하는 path함수
},
filename
:
function
(
req
,
file
,
cb
)
{
// cb(null, file.originalname); //저장할 파일명
cb
(
null
,
'mypic.jpg'
);
cb
(
null
,
file
.
originalname
);
}
});
var
upload
=
multer
({
storage
:
storage
});
...
...
@@ -31,7 +31,6 @@ var subscriptionKey = '61650f4a2941462ea2dba74eabefd114';
// subscription keys. For example, if you got your subscription keys from
// westus, replace "westcentralus" in the URL below with "westus".
var
uriBase
=
'https://eastasia.api.cognitive.microsoft.com/face/v1.0/detect'
;
var
imageUrl
=
'http://54.180.159.73/user/mypic.jpg'
;
// Request parameters.
var
params
=
{
'returnFaceId'
:
'true'
,
...
...
@@ -39,16 +38,6 @@ var params = {
'returnFaceAttributes'
:
'age,gender,emotion,hair'
//'headPose,smile,facialHair,glasses, emotion,hair,makeup,occlusion,accessories,blur,exposure,noise'
};
var
options
=
{
uri
:
uriBase
,
qs
:
params
,
body
:
'{"url": '
+
'"'
+
imageUrl
+
'"}'
,
headers
:
{
'Content-Type'
:
'application/json'
,
'Ocp-Apim-Subscription-Key'
:
subscriptionKey
}
};
app
.
get
(
'/home'
,
function
(
req
,
res
){
console
.
log
(
"home"
);
...
...
@@ -57,10 +46,19 @@ app.get('/home', function(req,res){
app
.
post
(
'/uploads'
,
upload
.
single
(
'userfile'
),
function
(
req
,
res
){
res
.
render
(
"facedetection"
);
imgname
=
req
.
file
.
filename
;
});
app
.
get
(
'/send2api'
,
function
(
req
,
res
)
{
console
.
log
(
"aa"
)
var
options
=
{
uri
:
uriBase
,
qs
:
params
,
body
:
'{"url": "http://54.180.159.73:8080/uploads/'
+
imgname
+
'"}'
,
headers
:
{
'Content-Type'
:
'application/json'
,
'Ocp-Apim-Subscription-Key'
:
subscriptionKey
}
};
request
.
post
(
options
,
(
error
,
response
,
body
)
=>
{
if
(
error
)
{
console
.
log
(
'Error: '
,
error
);
...
...
@@ -73,5 +71,5 @@ app.get('/send2api', function (req, res) {
})
app
.
listen
(
8080
,
function
(){
console
.
log
(
"connect 8080"
);
console
.
log
(
"connect 8080"
);
});
...
...
views/facedetection.html
View file @
e19f401
...
...
@@ -20,7 +20,7 @@
</head>
<body
ng-controller=
"mainAdminController"
>
<div
class=
"left-box"
>
<img
src=
"http://54.180.159.73:8080/u
ser
/mypic.jpg"
>
<img
src=
"http://54.180.159.73:8080/u
ploads
/mypic.jpg"
>
</div>
<div
class=
"right-box"
>
...
...
Please
register
or
login
to post a comment