Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
MPAI-Private
MPAI-CAE
arp
Video Analyzer
Commits
d5720591
Commit
d5720591
authored
Apr 03, 2023
by
Matteo
Browse files
update server endpoints
parent
2d316e30
Changes
5
Hide whitespace changes
Inline
Side-by-side
.dockerignore
View file @
d5720591
PerformanceResults.xlsx
PerformanceResults.xlsx
README.md
README.md
.DS_Store
.DS_Store
\ No newline at end of file
server/venv
server/pycache
\ No newline at end of file
config/config.json
View file @
d5720591
{
"WorkingPath"
:
"/data"
,
"FilesName"
:
"sad"
,
"Brands"
:
true
,
"Speed"
:
7.5
,
"TapeThresholdPercentual"
:
80
,
"CapstanThresholdPercentual"
:
50
,
"MinDist"
:
10
,
"AngleThresh"
:
10000
,
"ScaleThresh"
:
200
,
"PosThresh"
:
40
,
"MinDistCapstan"
:
1
,
"AngleThreshCapstan"
:
1000
,
"ScaleThreshCapstan"
:
30
,
"PosThreshCapstan"
:
10
}
{
"WorkingPath"
:
"./"
,
"FilesName"
:
"prova"
,
"Brands"
:
true
,
"Speed"
:
7.5
,
"TapeThresholdPercentual"
:
80
,
"CapstanThresholdPercentual"
:
50
,
"MinDist"
:
10
,
"AngleThresh"
:
10000
,
"ScaleThresh"
:
200
,
"PosThresh"
:
40
,
"MinDistCapstan"
:
1
,
"AngleThreshCapstan"
:
1000
,
"ScaleThreshCapstan"
:
30
,
"PosThreshCapstan"
:
10
}
\ No newline at end of file
\ No newline at end of file
server/documentation.yaml
View file @
d5720591
...
@@ -2,4 +2,11 @@ title: Video Analyser
...
@@ -2,4 +2,11 @@ title: Video Analyser
description
:
>
description
:
>
This is the API for the Video Analyser.
This is the API for the Video Analyser.
It is used to upload videos and get the results of the analysis.
It is used to upload videos and get the results of the analysis.
The analysis is done by the Video Analyser
The analysis is done by the Video Analyser
\ No newline at end of file
license_info
:
name
:
GPL-3.0
url
:
https://www.gnu.org/licenses/gpl-3.0.en.html
contact
:
name
:
Matteo Spanio
email
:
dev2@audioinnova.com
version
:
1.0.0
\ No newline at end of file
server/functions.py
0 → 100644
View file @
d5720591
import
os
import
subprocess
import
json
import
yaml
def
analyze
(
files_name
:
str
,
working_path
:
str
|
None
=
None
)
->
subprocess
.
CompletedProcess
:
executable
=
os
.
path
.
abspath
(
"frame_extraction/bin/frame_extraction"
)
config
=
get_file_content
(
"config/config.json"
,
"json"
)
# Update configuration file with query parameters
config
[
"FilesName"
]
=
files_name
if
working_path
is
not
None
:
config
[
"WorkingPath"
]
=
working_path
with
open
(
"config/config.json"
,
"w"
)
as
json_file
:
json
.
dump
(
config
,
json_file
)
process
=
subprocess
.
run
([
executable
],
capture_output
=
True
)
return
process
def
get_file_content
(
file_name
:
str
,
format
:
str
)
->
dict
:
with
open
(
file_name
)
as
fd
:
if
format
==
"yaml"
:
content
=
yaml
.
safe_load
(
fd
)
return
content
elif
format
==
"json"
:
content
=
json
.
load
(
fd
)
return
content
server/main.py
View file @
d5720591
import
os
import
subprocess
import
json
import
yaml
from
fastapi
import
FastAPI
,
Response
,
status
from
fastapi
import
FastAPI
,
Response
,
status
with
open
(
"VideoAnalyser.json"
)
as
json_file
:
import
server.functions
as
functions
info
=
json
.
load
(
json_file
)
app
=
FastAPI
(
info
=
functions
.
get_file_content
(
'server/documentation.yaml'
,
'yaml'
)
title
=
"Video Analyser"
,
app
=
FastAPI
(
**
info
)
description
=
info
[
"Description"
],
version
=
info
[
"Identifier"
][
"Specification"
][
"Version"
],
contact
=
{
"name"
:
"Matteo Spanio"
,
"email"
:
"dev2@audioinnova.com"
,
},
license_info
=
{
"name"
:
"GPL-3.0 License"
,
"url"
:
"http://www.gnu.org/licenses/gpl-3.0.html"
}
)
@
app
.
get
(
"/"
)
@
app
.
get
(
"/"
)
def
index
():
def
index
():
return
{
"endpoints"
:
[
"
analyze
"
,
"docs"
]}
return
{
"endpoints"
:
[
"
irregularityFile1"
,
"irregularityFile2"
,
"description
"
,
"docs"
]}
@
app
.
get
(
"/description"
)
@
app
.
get
(
"/description"
)
async
def
get_description
():
async
def
get_description
():
with
open
(
'server/documentation.yaml'
)
as
yaml_file
:
return
info
documentation
=
yaml
.
safe_load
(
yaml_file
)
return
documentation
@
app
.
get
(
"/
analyze
"
,
status_code
=
200
)
@
app
.
get
(
"/
irregularityFile/{id}
"
,
status_code
=
200
)
async
def
analyz
e
(
files_name
:
str
,
response
:
Response
,
working_path
:
str
|
None
=
None
):
def
get_irregularity_fil
e
(
files_name
:
str
,
id
:
int
,
response
:
Response
,
working_path
:
str
|
None
=
None
):
executable
=
os
.
path
.
abspath
(
"frame_extraction/bin/frame_extraction"
)
required_file
=
f
'VideoAnalyser_IrregularityFileOutput
{
id
}
.json'
try
:
return
functions
.
get_file_content
(
required_file
,
'json'
)
# Read configuration file
except
:
with
open
(
"config/config.json"
)
as
json_file
:
process
=
functions
.
analyze
(
files_name
,
working_path
)
config
=
json
.
load
(
json_file
)
# Update configuration file with query parameters
if
process
.
returncode
==
0
:
config
[
"FilesName"
]
=
files_name
return
functions
.
get_file_content
(
required_file
,
'json'
)
if
working_path
is
not
None
:
config
[
"WorkingPath"
]
=
working_path
with
open
(
"config/config.json"
,
"w"
)
as
json_file
:
json
.
dump
(
config
,
json_file
)
process
=
[
else
:
executable
,
response
.
status_code
=
status
.
HTTP_412_PRECONDITION_FAILED
]
return
{
"error"
:
{
"returncode"
:
process
.
returncode
,
cprocess
=
subprocess
.
run
(
process
,
capture_output
=
True
)
"stdout"
:
process
.
stdout
.
decode
(
"utf-8"
),
"stderr"
:
process
.
stderr
.
decode
(
"utf-8"
),
if
cprocess
.
returncode
==
0
:
}}
with
open
(
'AudioAnalyser_IrregularityFileOutput1.json'
)
as
json_file
:
editing_list
=
json
.
load
(
json_file
)
return
editing_list
else
:
response
.
status_code
=
status
.
HTTP_412_PRECONDITION_FAILED
return
{
"error"
:
{
"returncode"
:
cprocess
.
returncode
,
"stdout"
:
cprocess
.
stdout
.
decode
(
"utf-8"
),
"stderr"
:
cprocess
.
stderr
.
decode
(
"utf-8"
),
}}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment