Commit 4088391c authored by Matteo's avatar Matteo
Browse files

update config file management

parent 76842786
{"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
{"WorkingPath": "/home/user/preservation", "FilesName": "video", "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
title: Video Analyser
description: >
This is the API for the Video Analyser.
It is used to upload videos and get the results of the analysis.
The analysis is done by the Video Analyser
description: |
[![MPAI CAE-ARP](https://img.shields.io/badge/MPAI%20CAE--ARP-gray?style=for-the-badge&logo=AppleMusic&logoColor=cyan&link=https://mpai.community/standards/mpai-cae/about-mpai-cae/)](https://mpai.community/standards/mpai-cae/about-mpai-cae/)
Implements the Technical Specification of [MPAI CAE-ARP](https://mpai.community/standards/mpai-cae/about-mpai-cae/#Figure2) *Video Analyser* AIM, providing:
* 2 Irregularity Files;
* Irregularity Images.
This is the API for the Video Analyser. It is used to upload videos and get the results of the analysis. The analysis is done by the Video Analyser
license_info:
name: GPL-3.0
url: https://www.gnu.org/licenses/gpl-3.0.en.html
......
from fastapi import FastAPI, Response, status, Path, Query
from typing import Annotated
from mpai_cae_arp.files import get_file_content
from mpai_cae_arp.files import File, FileType
from mpai_cae_arp.types.irregularity import IrregularityFile
from mpai_cae_arp.types.schema import Info
import server.utils as utils
info = get_file_content('server/documentation.yaml', 'yaml')
info = File('server/documentation.yaml', FileType.YAML).get_content()
app = FastAPI(**info)
......@@ -43,13 +43,13 @@ async def get_irregularity_file(
required_file = f'VideoAnalyser_IrregularityFileOutput{id}.json'
try:
return get_file_content(required_file, 'json')
return File(required_file, FileType.JSON).get_content()
except:
process = utils.analyze(files_name, working_path)
process = await utils.analyze(files_name, working_path)
if process.returncode == 0:
return get_file_content(required_file, 'json')
return File(required_file, FileType.JSON).get_content()
else:
response.status_code = status.HTTP_412_PRECONDITION_FAILED
......
......@@ -21,7 +21,7 @@ lazy_loader==0.2
librosa==0.10.0.post2
llvmlite==0.39.1
MarkupSafe==2.1.2
mpai-cae-arp==0.1.0
mpai-cae-arp==0.2.0
msgpack==1.0.5
numba==0.56.4
numpy==1.23.3
......
import os
import subprocess
import json
from mpai_cae_arp.files import get_file_content
from mpai_cae_arp.files import File, FileType
def analyze(files_name: str, working_path: str | None = None) -> subprocess.CompletedProcess:
executable = os.path.abspath("frame_extraction/bin/frame_extraction")
executable = os.path.abspath("bin/video_analyser")
config = get_file_content("config/config.json", "json")
config_file = File("config/config.json", FileType.JSON)
config = config_file.get_content()
# 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)
config_file.write_content(config)
process = subprocess.run([executable], capture_output=True)
return process
......@@ -118,7 +118,7 @@ string END = "\033[0m";
*/
bool getArguments(int argc, char** argv) {
// Read configuration file
ifstream iConfig("../config/config.json");
ifstream iConfig("config/config.json");
iConfig >> configurationFile;
if (argc == 1) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment