Showing
2 changed files
with
33 additions
and
1 deletions
cfr_module.js
0 → 100644
1 | +var client_id = 'v3M4wjolGLkrvNA3GUIW'; | ||
2 | +var client_secret = 'fKF6vjkWhE'; | ||
3 | +var fs = require('fs'); | ||
4 | +var request = require('request'); | ||
5 | + | ||
6 | +exports.imgtodata=function(dir){ | ||
7 | + var api_url = 'https://openapi.naver.com/v1/vision/face'; // 얼굴 감지 | ||
8 | + | ||
9 | + var _formData = { | ||
10 | + image:'image', | ||
11 | + image: fs.createReadStream(__dirname + dir) // FILE 이름 | ||
12 | + }; | ||
13 | + | ||
14 | + request.post( | ||
15 | + { url:api_url, | ||
16 | + formData:_formData, | ||
17 | + headers: {'X-Naver-Client-Id':client_id, | ||
18 | + 'X-Naver-Client-Secret': client_secret} | ||
19 | + }, (err,response,body) =>{ | ||
20 | + console.log(response.statusCode); // 200 | ||
21 | + //console.log(response.headers['content-type']) | ||
22 | + | ||
23 | + data=JSON.parse(body); | ||
24 | + gender=data.faces[0].gender.value; | ||
25 | + emotion=data.faces[0].emotion.value | ||
26 | + | ||
27 | + console.log(gender); | ||
28 | + console.log(emotion); | ||
29 | + | ||
30 | + return {gender:gender,emotion:emotion}; | ||
31 | + }); | ||
32 | + } | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "name": "reply", | 2 | "name": "reply", |
3 | "version": "1.0.0", | 3 | "version": "1.0.0", |
4 | "description": "", | 4 | "description": "", |
5 | - "main": "chatbot.js", | 5 | + "main": "app.js", |
6 | "scripts": { | 6 | "scripts": { |
7 | "test": "echo \"Error: no test specified\" && exit 1" | 7 | "test": "echo \"Error: no test specified\" && exit 1" |
8 | }, | 8 | }, | ... | ... |
-
Please register or login to post a comment