Commit 7eb5bc11 authored by Matteo's avatar Matteo
Browse files

refactor

parent ee66ff7d
......@@ -2,4 +2,18 @@
The core of the acquisition process is splitted in two AI-modules: the audio analyser and the video analyser. The video analyser takes advantage of computer vision to detect anomalies on the tape area recorded in video.
In simple words the analyser takes in input the video, takes a frame in the middle of the video to find ROIs
\ No newline at end of file
In simple words the analyser takes in input the video, takes a frame in the middle of the video to find ROIs
```mermaid
timeline
title History of Social Media Platform
2002 : LinkedIn
2004 : Facebook
: Google
2005 : Youtube
2006 : Twitter
```
<script>
mermaid.initialize({ startOnLoad: true });
</script>
......@@ -16,6 +16,7 @@ $search
$mathjax
<link href="$relpath^$stylesheet" rel="stylesheet" type="text/css" />
$extrastylesheet
<script src="https://cdn.jsdelivr.net/npm/mermaid@10.0.2/dist/add-html-label-6e56ed67.min.js"></script>
<script type="text/javascript" src="$relpath^../doxygen-awesome-css/doxygen-awesome-darkmode-toggle.js"></script>
<script type="text/javascript" src="$relpath^../doxygen-awesome-css/doxygen-awesome-fragment-copy-button.js"></script>
<script type="text/javascript" src="$relpath^../doxygen-awesome-css/doxygen-awesome-paragraph-link.js"></script>
......
#ifndef FORAUDIOANALYSER_H
#define FORAUDIOANALYSER_H
#include <filesystem>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
......@@ -61,4 +63,5 @@ void extractIrregularityImagesForAudio(std::string outputPath, const std::string
std::cout << "\033[0;31mTimeLabel error for Audio Analyser Irregularity " << i << "." << std::endl;
}
}
}
\ No newline at end of file
}
#endif // FORAUDIOANALYSER_H
\ No newline at end of file
......@@ -4,13 +4,9 @@
using std::cout, std::endl, std::cerr, std::ofstream, std::ios;
void files::saveFile(std::filesystem::path fileName, std::string content, bool append) {
void files::save_file(std::filesystem::path fileName, std::string content) {
ofstream outputFile;
if (append) {
outputFile.open(fileName, ios::app);
} else {
outputFile.open(fileName);
}
outputFile.open(fileName);
outputFile << content << endl;
outputFile.close();
}
......@@ -23,16 +19,9 @@ void files::findFileNameFromPath(std::string* path, std::string* fileName, std::
*extension = path->substr(path->find_last_of(".") + 1, path->size());
}
int files::findFileName(std::string videoPath, std::string& fileName, std::string& extension) {
std::pair<std::string, std::string> files::get_filename_and_extension(std::string videoPath) {
std::string fileName, extension;
files::findFileNameFromPath(&videoPath, &fileName, &extension);
if (extension.compare("avi") != 0 && extension.compare("mp4") != 0 && extension.compare("mov") != 0) {
cerr << "Input file extension must be \"avi\", \"mp4\" or \"mov\"." << endl;
return -1;
} else {
cout << "Video to be analysed: " << endl;
cout << " File name: " << fileName << endl;
cout << " Extension: " << extension << endl;
}
return 0;
return std::pair<std::string, std::string>(fileName, extension);
}
......@@ -25,16 +25,13 @@
*/
namespace files {
/**
* @fn void saveFile(std::filesystem::path fileName, std::string content, bool
* append)
* @fn void save_file(std::filesystem::path fileName, std::string content)
* @brief Save content to a file
*
* @param fileName the name of the file
* @param content the content to be saved
* @param append if true, the content will be appended to the file, otherwise
* the file will be overwritten
*/
void saveFile(std::filesystem::path fileName, std::string content, bool append);
void save_file(std::filesystem::path fileName, std::string content);
/**
* @fn void findFileNameFromPath(std::string* path, std::string* fileName,
......@@ -48,15 +45,12 @@ void saveFile(std::filesystem::path fileName, std::string content, bool append);
void findFileNameFromPath(std::string* path, std::string* fileName, std::string* extension);
/**
* @fn int findFileName(std::string videoPath, std::string &fileName,
* std::string &extension)
* @fn std::pair<std::string, std::string> findFileName(std::string videoPath)
* @brief Check if the specified input video file exists and is supported.
*
* @param[in] videoPath Full video path;
* @param[out] fileName Video file name;
* @param[out] extension Video extension.
* @return int -1 if the format is not supported, 0 otherwise.
* @param videoPath Full video path;
* @return a pair of strings containing the video file name and its extension.
*/
int findFileName(std::string videoPath, std::string& fileName, std::string& extension);
std::pair<std::string, std::string> get_filename_and_extension(std::string videoPath);
} // namespace files
#endif // FILES_H
\ No newline at end of file
This diff is collapsed.
......@@ -223,12 +223,12 @@ SceneObject::SceneObject(int minDist, Threshold threshold) {
this->threshold = threshold;
}
SceneObject SceneObject::from_file(fs::path path, Object obj) {
SceneObject SceneObject::from_file(fs::path path, ROI obj) {
ifstream iConfig(path);
json j;
iConfig >> j;
if (obj == Object::TAPE) {
if (obj == ROI::TAPE) {
return SceneObject(j["MinDist"],
Threshold(j["TapeThresholdPercentual"], j["AngleThresh"], j["ScaleThresh"], j["PosThresh"]));
} else {
......
#ifndef UTILITY_H
#define UTILITY_H
#include <filesystem>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
......@@ -158,11 +160,11 @@ struct Threshold {
};
/**
* @enum Object
* @enum ROI
* @brief Enum containing the possible objects to detect.
*
*/
enum Object { TAPE, CAPSTAN };
enum ROI { TAPE, CAPSTAN };
/**
* @struct SceneObject
......@@ -187,5 +189,6 @@ struct SceneObject {
* @param obj The object to detect.
* @return SceneObject The SceneObject created from the file.
*/
static SceneObject from_file(fs::path path, Object obj);
static SceneObject from_file(fs::path path, ROI obj);
};
#endif // UTILITY_H
\ No newline at end of file
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