From 8ded025baf34f43d543288aadca2155ebda71c81 Mon Sep 17 00:00:00 2001 From: Tadas Baltrusaitis Date: Thu, 9 Nov 2017 18:37:26 +0000 Subject: [PATCH] More refactorization. --- exe/FeatureExtraction/FeatureExtraction.cpp | 8 ++++---- lib/local/Utilities/include/RecorderOpenFace.h | 6 +++--- lib/local/Utilities/src/RecorderOpenFace.cpp | 12 ++++++++++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/exe/FeatureExtraction/FeatureExtraction.cpp b/exe/FeatureExtraction/FeatureExtraction.cpp index 358ca3e..5943aaf 100644 --- a/exe/FeatureExtraction/FeatureExtraction.cpp +++ b/exe/FeatureExtraction/FeatureExtraction.cpp @@ -188,7 +188,7 @@ int main (int argc, char **argv) cv::Mat captured_image; Utilities::RecorderOpenFaceParameters recording_params(arguments, true, sequence_reader.fps); - Utilities::RecorderOpenFace open_face_rec(output_files[f_n], sequence_reader.name, recording_params); + Utilities::RecorderOpenFace open_face_rec(sequence_reader.name, recording_params, arguments); int frame_count = 0; @@ -211,8 +211,8 @@ int main (int argc, char **argv) if (det_parameters.track_gaze && detection_success && face_model.eye_model) { - GazeAnalysis::EstimateGaze(face_model, gazeDirection0, fx, fy, cx, cy, true); - GazeAnalysis::EstimateGaze(face_model, gazeDirection1, fx, fy, cx, cy, false); + GazeAnalysis::EstimateGaze(face_model, gazeDirection0, sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy, true); + GazeAnalysis::EstimateGaze(face_model, gazeDirection1, sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy, false); gazeAngle = GazeAnalysis::GetGazeAngle(gazeDirection0, gazeDirection1); } @@ -245,7 +245,7 @@ int main (int argc, char **argv) } // Work out the pose of the head from the tracked model - cv::Vec6d pose_estimate = LandmarkDetector::GetPose(face_model, fx, fy, cx, cy); + cv::Vec6d pose_estimate = LandmarkDetector::GetPose(face_model, sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy); // Drawing the visualization on the captured image if (recording_params.outputTrackedVideo() || (visualize_track && !det_parameters.quiet_mode)) diff --git a/lib/local/Utilities/include/RecorderOpenFace.h b/lib/local/Utilities/include/RecorderOpenFace.h index 5ecac8a..3c56de2 100644 --- a/lib/local/Utilities/include/RecorderOpenFace.h +++ b/lib/local/Utilities/include/RecorderOpenFace.h @@ -57,8 +57,8 @@ namespace Utilities public: // The constructor for the recorder, need to specify if we are recording a sequence or not - RecorderOpenFace(const std::string out_directory, const std::string in_filename, RecorderOpenFaceParameters parameters); - + RecorderOpenFace(const std::string in_filename, RecorderOpenFaceParameters parameters, std::vector arguments); + ~RecorderOpenFace(); // TODO copy, assignment and move operators? Do not allow @@ -104,7 +104,7 @@ namespace Utilities const RecorderOpenFaceParameters params; // Keep track of the file and output root location - std::string record_root; + std::string record_root = "processed"; // By default we are writing in the processed directory in the working directory std::string filename; std::string csv_filename; std::string aligned_output_directory; diff --git a/lib/local/Utilities/src/RecorderOpenFace.cpp b/lib/local/Utilities/src/RecorderOpenFace.cpp index 1eeb4ae..597c3fb 100644 --- a/lib/local/Utilities/src/RecorderOpenFace.cpp +++ b/lib/local/Utilities/src/RecorderOpenFace.cpp @@ -71,12 +71,20 @@ void CreateDirectory(std::string output_path) } -RecorderOpenFace::RecorderOpenFace(const std::string out_directory, const std::string in_filename, RecorderOpenFaceParameters parameters):video_writer(), params(parameters) +RecorderOpenFace::RecorderOpenFace(const std::string in_filename, RecorderOpenFaceParameters parameters, std::vector arguments):video_writer(), params(parameters) { // From the filename, strip out the name without directory and extension filename = path(in_filename).replace_extension("").filename().string(); - record_root = out_directory; + + // Determine output directory + for (size_t i = 0; i < arguments.size(); ++i) + { + if (arguments[i].compare("-out_dir") == 0) + { + record_root = arguments[i + 1]; + } + } // Construct the directories required for the output CreateDirectory(record_root);