Showing
3 changed files
with
28 additions
and
32 deletions
... | @@ -8,6 +8,7 @@ const router = express.Router(); | ... | @@ -8,6 +8,7 @@ const router = express.Router(); |
8 | router.post('/videoResult', function (req, res) { | 8 | router.post('/videoResult', function (req, res) { |
9 | delete_prevResult_image('./fire'); | 9 | delete_prevResult_image('./fire'); |
10 | delete_prevResult_image('./unknown'); | 10 | delete_prevResult_image('./unknown'); |
11 | + delete_prevResult_image('./data'); | ||
11 | try { | 12 | try { |
12 | let preview = req.body[0].preview; | 13 | let preview = req.body[0].preview; |
13 | 14 | ||
... | @@ -29,26 +30,26 @@ router.post('/videoResult', function (req, res) { | ... | @@ -29,26 +30,26 @@ router.post('/videoResult', function (req, res) { |
29 | file_name: 'frame_%s' | 30 | file_name: 'frame_%s' |
30 | }, function (error, files) { | 31 | }, function (error, files) { |
31 | if (!error) | 32 | if (!error) |
32 | - for(var i=0;i<files.length-1;i++){ | 33 | + for (var i = 0; i < files.length - 1; i++) { |
33 | - let base64str = base64_encode(files[i]); | 34 | + let base64str = base64_encode(files[i]); |
34 | - request.post({ | 35 | + request.post({ |
35 | - url: 'http://101.101.210.73/process', | 36 | + url: 'http://101.101.210.73/process', |
36 | - form: { | 37 | + form: { |
37 | - 'data': base64str, | 38 | + 'data': base64str, |
38 | - 'index': i | 39 | + 'index': i |
39 | - }, | 40 | + }, |
40 | - json: true | 41 | + json: true |
41 | - }, (err, response, body) => { | 42 | + }, (err, response, body) => { |
42 | - console.log(body) | 43 | + console.log(body) |
43 | - var index=body['index']; | 44 | + var index = body['index']; |
44 | - if(body['unknown_person'] == true){ | 45 | + if (body['unknown_person'] == true) { |
45 | - save_Result_image((files[index]), 'unknown', index); | 46 | + save_Result_image((files[index]), 'unknown', index); |
46 | - } | 47 | + } |
47 | - if(body['fire_broken'] == true){ | 48 | + if (body['fire_broken'] == true) { |
48 | - save_Result_image((files[index]), 'fire', index); | 49 | + save_Result_image((files[index]), 'fire', index); |
49 | - } | 50 | + } |
50 | - }) | 51 | + }) |
51 | - } | 52 | + } |
52 | } | 53 | } |
53 | ) | 54 | ) |
54 | }) | 55 | }) |
... | @@ -88,24 +89,19 @@ function base64_encode(file) { | ... | @@ -88,24 +89,19 @@ function base64_encode(file) { |
88 | return new Buffer(bitmap).toString('base64'); | 89 | return new Buffer(bitmap).toString('base64'); |
89 | } | 90 | } |
90 | 91 | ||
91 | -function save_Result_image(file, type, index){ | 92 | +function save_Result_image(file, type, index) { |
92 | var bitmap = fs.readFileSync(file); | 93 | var bitmap = fs.readFileSync(file); |
93 | var filePath = './' + type + '/' + index + '.jpg'; | 94 | var filePath = './' + type + '/' + index + '.jpg'; |
94 | - fs.writeFile(filePath, bitmap, function(err){ | 95 | + fs.writeFile(filePath, bitmap, function (err) { |
95 | console.log('save'); | 96 | console.log('save'); |
96 | }); | 97 | }); |
97 | } | 98 | } |
98 | 99 | ||
99 | -function delete_prevResult_image(filePath){ | 100 | +function delete_prevResult_image(filePath) { |
100 | - fs.readdir(filePath, (err, files) => { | 101 | + let files = fs.readdirSync(filePath); |
101 | - if (err) throw err; | 102 | + for (const file of files) { |
102 | - | 103 | + fs.unlinkSync(path.join(filePath, file)); |
103 | - for (const file of files) { | 104 | + } |
104 | - fs.unlink(path.join(filePath, file), err => { | ||
105 | - if (err) throw err; | ||
106 | - }); | ||
107 | - } | ||
108 | - }); | ||
109 | } | 105 | } |
110 | 106 | ||
111 | module.exports = router; | 107 | module.exports = router; |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
방문자 사진.jpg
0 → 100644
1.05 MB
침입자+화재.mp4
0 → 100644
This file is too large to display.
-
Please register or login to post a comment