Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김현기
/
KindOfYourDog
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
김현기
2020-06-24 23:15:12 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7eb85fac16bfab206fe1edbb19057cfe7d29ed0e
7eb85fac
1 parent
5ddeae5c
aws rekognition으로 사진 분석 성공
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
3 deletions
app.js
app.js
View file @
7eb85fa
...
...
@@ -13,9 +13,9 @@ var bucketName = "kindofyourdogimage";
// s3 버킷의 엔드 포인트
var
bucketRegion
=
'ap-northeast-2'
;
// access key
var
accessId
=
'
AKIAQVXKGU466IQYEGRN
'
;
var
accessId
=
'
your_accessId
'
;
// access secret key
var
secretKey
=
'
0FrMPdZR6+AkMkabAyPZWrnsVVi9EaI9/IdrWKCm
'
;
var
secretKey
=
'
your_secretKey
'
;
// AWS Cognito 인증
//var identityPoolId = "ap-northeast-2:7cba9a17-588b-40d6-8c70-eb8ba4d573be";
...
...
@@ -137,17 +137,62 @@ app.get('/form', function(req, res){
</html>
`
;
res
.
send
(
output
);
console
.
log
(
output
);
});
// image를 받았을 때
app
.
post
(
'/upload_receiver'
,
function
(
req
,
res
){
var
form
=
new
formidable
.
IncomingForm
();
console
.
log
(
form
);
const
client
=
new
AWS
.
Rekognition
();
const
params
=
{
"Image"
:
{
"S3Object"
:
{
"Bucket"
:
bucketName
,
"Name"
:
fileName
}
},
"MaxLabels"
:
10
,
"MinConfidence"
:
75
}
// 이미지 분석하기
client
.
detectLabels
(
params
,
function
(
err
,
response
)
{
if
(
err
)
{
console
.
log
(
err
,
err
.
stack
);
// an error occurred
}
else
{
console
.
log
(
`Detected labels for:
${
form
.
name
}
`
)
response
.
Labels
.
forEach
(
label
=>
{
console
.
log
(
`Label:
${
label
.
Name
}
`
)
console
.
log
(
`Confidence:
${
label
.
Confidence
}
`
)
console
.
log
(
"Instances:"
)
label
.
Instances
.
forEach
(
instance
=>
{
let
box
=
instance
.
BoundingBox
console
.
log
(
" Bounding box:"
)
console
.
log
(
` Top:
${
box
.
Top
}
`
)
console
.
log
(
` Left:
${
box
.
Left
}
`
)
console
.
log
(
` Width:
${
box
.
Width
}
`
)
console
.
log
(
` Height:
${
box
.
Height
}
`
)
console
.
log
(
` Confidence:
${
instance
.
Confidence
}
`
)
})
console
.
log
(
"Parents:"
)
label
.
Parents
.
forEach
(
parent
=>
{
console
.
log
(
`
${
parent
.
Name
}
`
)
})
console
.
log
(
"------------"
)
console
.
log
(
""
)
})
// for response.labels
}
// if
});
// S3에 upload해주기
form
.
parse
(
req
,
function
(
err
,
fields
,
files
){
var
s3
=
new
AWS
.
S3
();
var
params
=
{
Bucket
:
bucketName
,
ACL
:
'public-read'
,
Key
:
files
.
userfile
.
name
m
,
Key
:
files
.
userfile
.
name
,
Body
:
require
(
'fs'
).
createReadStream
(
files
.
userfile
.
path
)
}
s3
.
upload
(
params
,
function
(
err
,
data
){
...
...
Please
register
or
login
to post a comment