Commit c3b747c0 authored by Matteo's avatar Matteo
Browse files

minor changes

parent 8bcea3e9
......@@ -35,13 +35,10 @@ add_library(analyser_lib
src/lib/IrregularityFile.cpp
src/lib/TimeLabel.hpp
src/lib/TimeLabel.cpp
src/utility.hpp
src/utility.cpp
)
add_library(files
src/lib/files.hpp
src/lib/files.cpp
src/utility.hpp
src/utility.cpp
)
FIND_PACKAGE(OpenCV REQUIRED)
......@@ -64,7 +61,6 @@ TARGET_LINK_LIBRARIES(video_analyser
nlohmann_json::nlohmann_json
${Boost_PROGRAM_OPTIONS_LIBRARY}
analyser_lib
files
)
# enable_testing()
......
......@@ -35,5 +35,8 @@ format:
docs:
$(DOCS_GEN) docs/Doxyfile && $(OPEN) docs/html/index.html
all:
cd build && cmake .. && make
run:
./bin/video_analyser
......@@ -51,6 +51,7 @@
#include "lib/io.hpp"
#include "lib/time.hpp"
#include "utility.hpp"
#define BLACK_PIXEL 0
using namespace std;
using namespace colors;
......@@ -171,6 +172,9 @@ float rotated_rect_area(RotatedRect rect) { return rect.size.width * rect.size.h
* - The tape area under the tape head (computed on the basis of the detected
* reading head);
* - The capstan.
*
*
*
* @param frame the frame to be analysed
* @param tape the tape object
* @param capstan the capstan object
......@@ -198,6 +202,7 @@ va::Result<pair<va::detection::Roi, va::detection::Roi>> find_processing_areas(F
return va::Error("Error while finding capstan roi: " + std::get<va::Error>(capstan_roi_result));
auto rect_capstan = std::get<va::detection::Roi>(capstan_roi_result);
// save detected areas to file
cv::rectangle(frame, rect_tape.boundingRect(), cv::Scalar(0, 255, 0), 2);
cv::rectangle(frame, rect_capstan.boundingRect(), cv::Scalar(255, 0, 0), 2);
cv::imwrite(g_output_path.string() + "/my_tape_areas.jpg", frame);
......@@ -278,7 +283,7 @@ bool is_frame_different(cv::Mat prev_frame, cv::Mat current_frame, int ms_to_end
for (int i = 0; i < difference_frame.rows; i++) {
for (int j = 0; j < difference_frame.cols; j++) {
if (difference_frame.at<cv::Vec3b>(i, j)[0] == 0) {
if (difference_frame.at<cv::Vec3b>(i, j)[0] == BLACK_PIXEL) {
// There is a black pixel, then there is a difference
// between previous and current frames
num_different_pixels++;
......@@ -296,14 +301,14 @@ bool is_frame_different(cv::Mat prev_frame, cv::Mat current_frame, int ms_to_end
/********************* Tape analysis *********************/
RotatedRect corrected_tape_roi = check_skew(rect_tape);
Frame cropped_current_frame =
Frame(current_frame)
.warp(cv::getRotationMatrix2D(corrected_tape_roi.center, corrected_tape_roi.angle, 1.0))
.crop(corrected_tape_roi.size, corrected_tape_roi.center);
Frame difference_frame = get_difference_for_roi(Frame(prev_frame), Frame(current_frame), corrected_tape_roi);
/********************** Segment analysis ************************/
Frame cropped_current_frame =
Frame(current_frame)
.warp(cv::getRotationMatrix2D(corrected_tape_roi.center, corrected_tape_roi.angle, 1.0))
.crop(corrected_tape_roi.size, corrected_tape_roi.center);
num_different_pixels = 0;
float mean_current_frame_color;
int current_frame_color_sum = 0;
......@@ -313,7 +318,7 @@ bool is_frame_different(cv::Mat prev_frame, cv::Mat current_frame, int ms_to_end
current_frame_color_sum += cropped_current_frame.at<cv::Vec3b>(i, j)[0] +
cropped_current_frame.at<cv::Vec3b>(i, j)[1] +
cropped_current_frame.at<cv::Vec3b>(i, j)[2];
if (difference_frame.at<cv::Vec3b>(i, j)[0] == 0) {
if (difference_frame.at<cv::Vec3b>(i, j)[0] == BLACK_PIXEL) {
num_different_pixels++;
}
}
......
......@@ -4,7 +4,6 @@
#include <fstream>
#include <nlohmann/json.hpp>
using namespace cv;
using namespace std;
namespace fs = std::filesystem;
......
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