From 550b3250950305885521c89af276ef9515cbbeaf Mon Sep 17 00:00:00 2001 From: Tadas Baltrusaitis Date: Wed, 1 Nov 2017 20:03:31 +0000 Subject: [PATCH] Bit more on HOG recording. --- lib/local/Recorder/include/RecorderHOG.h | 7 ++----- lib/local/Recorder/include/RecorderOpenFace.h | 2 +- lib/local/Recorder/src/RecorderHOG.cpp | 4 ++-- lib/local/Recorder/src/RecorderOpenFace.cpp | 12 ++++++++++-- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/local/Recorder/include/RecorderHOG.h b/lib/local/Recorder/include/RecorderHOG.h index 7971eb2..4a21451 100644 --- a/lib/local/Recorder/include/RecorderHOG.h +++ b/lib/local/Recorder/include/RecorderHOG.h @@ -50,10 +50,10 @@ namespace Recorder public: // The constructor for the recorder, by default does not do anything - RecorderHOG(int num_rows, int num_cols, int num_channels); + RecorderHOG(); // Adding observations to the recorder - void AddObservationHOG(bool success, const cv::Mat_& hog_descriptor); + void AddObservationHOG(bool success, const cv::Mat_& hog_descriptor, int num_cols, int num_rows, int num_channels); bool Open(std::string filename); @@ -64,9 +64,6 @@ namespace Recorder std::ofstream hog_file; - int num_rows; - int num_cols; - const int num_channels; }; } #endif \ No newline at end of file diff --git a/lib/local/Recorder/include/RecorderOpenFace.h b/lib/local/Recorder/include/RecorderOpenFace.h index 451b9db..befd083 100644 --- a/lib/local/Recorder/include/RecorderOpenFace.h +++ b/lib/local/Recorder/include/RecorderOpenFace.h @@ -75,7 +75,7 @@ namespace Recorder void AddObservationGaze(const cv::Point3f& gazeDirection0, const cv::Point3f& gazeDirection1, const cv::Vec2d& gaze_angle, const cv::Mat_& eye_landmarks); void AddObservationFaceAlign(const cv::Mat& aligned_face); - void AddObservationHOG(const cv::Mat_& aligned_HOG); + void AddObservationHOG(bool good_frame, const cv::Mat_& hog_descriptor, int num_cols, int num_rows, int num_channels); void AddObservationSuccess(double confidence, bool success); void AddObservationTimestamp(double timestamp); diff --git a/lib/local/Recorder/src/RecorderHOG.cpp b/lib/local/Recorder/src/RecorderHOG.cpp index fb75b29..8d56800 100644 --- a/lib/local/Recorder/src/RecorderHOG.cpp +++ b/lib/local/Recorder/src/RecorderHOG.cpp @@ -38,7 +38,7 @@ using namespace Recorder; // Default constructor initializes the variables -RecorderHOG::RecorderHOG(int num_rows, int num_cols, int num_channels) :hog_file(),num_rows(num_rows), num_cols(num_cols), num_channels(num_channels) {}; +RecorderHOG::RecorderHOG() :hog_file() {}; // TODO the other 4 constructors + destructors? @@ -56,7 +56,7 @@ void RecorderHOG::Close() } // Writing to a HOG file -void RecorderHOG::AddObservationHOG(bool good_frame, const cv::Mat_& hog_descriptor) +void RecorderHOG::AddObservationHOG(bool good_frame, const cv::Mat_& hog_descriptor, int num_cols, int num_rows, int num_channels) { hog_file.write((char*)(&num_cols), 4); diff --git a/lib/local/Recorder/src/RecorderOpenFace.cpp b/lib/local/Recorder/src/RecorderOpenFace.cpp index 144c895..1ff51c7 100644 --- a/lib/local/Recorder/src/RecorderOpenFace.cpp +++ b/lib/local/Recorder/src/RecorderOpenFace.cpp @@ -89,8 +89,11 @@ RecorderOpenFace::RecorderOpenFace(const std::string out_directory, const std::s output_AUs, output_gaze, num_face_landmarks, num_model_modes, num_eye_landmarks, au_names_class, au_names_reg); // Consruct HOG recorder here - std::string hog_filename = (path(record_root) / path(filename).replace_extension(".hog")).string(); - hog_recorder.Open(hog_filename); + if(output_hog) + { + std::string hog_filename = (path(record_root) / path(filename).replace_extension(".hog")).string(); + hog_recorder.Open(hog_filename); + } // TODO construct a video recorder @@ -98,5 +101,10 @@ RecorderOpenFace::RecorderOpenFace(const std::string out_directory, const std::s } +void RecorderOpenFace::AddObservationHOG(bool good_frame, const cv::Mat_& hog_descriptor, int num_cols, int num_rows, int num_channels) +{ + hog_recorder.AddObservationHOG(good_frame, hog_descriptor, num_cols, num_rows, num_channels); +} + // TODO the other 4 constructors + destructors?