Toggle navigation
Toggle navigation
This project
Loading...
Sign in
박선진
/
video-emergency-detection
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
3
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
박선진
2020-06-29 18:43:41 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e0973bbc2be18a3a7a0fbb268da4e30f8f896a09
e0973bbc
1 parent
82333e4b
코드 정리 + 테스트 데이터 추가
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
32 deletions
Back-end/apiRouter.js
방문자 사진.jpg
침입자+화재.mp4
Back-end/apiRouter.js
View file @
e0973bb
...
...
@@ -8,6 +8,7 @@ const router = express.Router();
router
.
post
(
'/videoResult'
,
function
(
req
,
res
)
{
delete_prevResult_image
(
'./fire'
);
delete_prevResult_image
(
'./unknown'
);
delete_prevResult_image
(
'./data'
);
try
{
let
preview
=
req
.
body
[
0
].
preview
;
...
...
@@ -29,26 +30,26 @@ router.post('/videoResult', function (req, res) {
file_name
:
'frame_%s'
},
function
(
error
,
files
)
{
if
(
!
error
)
for
(
var
i
=
0
;
i
<
files
.
length
-
1
;
i
++
)
{
let
base64str
=
base64_encode
(
files
[
i
]);
request
.
post
({
url
:
'http://101.101.210.73/process'
,
form
:
{
'data'
:
base64str
,
'index'
:
i
},
json
:
true
},
(
err
,
response
,
body
)
=>
{
console
.
log
(
body
)
var
index
=
body
[
'index'
];
if
(
body
[
'unknown_person'
]
==
true
)
{
save_Result_image
((
files
[
index
]),
'unknown'
,
index
);
}
if
(
body
[
'fire_broken'
]
==
true
)
{
save_Result_image
((
files
[
index
]),
'fire'
,
index
);
}
})
}
for
(
var
i
=
0
;
i
<
files
.
length
-
1
;
i
++
)
{
let
base64str
=
base64_encode
(
files
[
i
]);
request
.
post
({
url
:
'http://101.101.210.73/process'
,
form
:
{
'data'
:
base64str
,
'index'
:
i
},
json
:
true
},
(
err
,
response
,
body
)
=>
{
console
.
log
(
body
)
var
index
=
body
[
'index'
];
if
(
body
[
'unknown_person'
]
==
true
)
{
save_Result_image
((
files
[
index
]),
'unknown'
,
index
);
}
if
(
body
[
'fire_broken'
]
==
true
)
{
save_Result_image
((
files
[
index
]),
'fire'
,
index
);
}
})
}
}
)
})
...
...
@@ -88,24 +89,19 @@ function base64_encode(file) {
return
new
Buffer
(
bitmap
).
toString
(
'base64'
);
}
function
save_Result_image
(
file
,
type
,
index
){
function
save_Result_image
(
file
,
type
,
index
)
{
var
bitmap
=
fs
.
readFileSync
(
file
);
var
filePath
=
'./'
+
type
+
'/'
+
index
+
'.jpg'
;
fs
.
writeFile
(
filePath
,
bitmap
,
function
(
err
)
{
fs
.
writeFile
(
filePath
,
bitmap
,
function
(
err
)
{
console
.
log
(
'save'
);
});
}
function
delete_prevResult_image
(
filePath
){
fs
.
readdir
(
filePath
,
(
err
,
files
)
=>
{
if
(
err
)
throw
err
;
for
(
const
file
of
files
)
{
fs
.
unlink
(
path
.
join
(
filePath
,
file
),
err
=>
{
if
(
err
)
throw
err
;
});
}
});
function
delete_prevResult_image
(
filePath
)
{
let
files
=
fs
.
readdirSync
(
filePath
);
for
(
const
file
of
files
)
{
fs
.
unlinkSync
(
path
.
join
(
filePath
,
file
));
}
}
module
.
exports
=
router
;
\ No newline at end of file
...
...
방문자 사진.jpg
0 → 100644
View file @
e0973bb
1.05 MB
침입자+화재.mp4
0 → 100644
View file @
e0973bb
This file is too large to display.
Please
register
or
login
to post a comment