From b4dd338a865443275464fbc83046ff2adec681e1 Mon Sep 17 00:00:00 2001 From: Tadas Baltrusaitis Date: Sun, 17 Dec 2017 12:59:55 +0000 Subject: [PATCH] Some cross-platform fixes. --- lib/local/Utilities/src/RecorderOpenFace.cpp | 12 +++++----- lib/local/Utilities/src/SequenceCapture.cpp | 25 +++++++++++++------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/lib/local/Utilities/src/RecorderOpenFace.cpp b/lib/local/Utilities/src/RecorderOpenFace.cpp index 9356d830..d8ff2227 100644 --- a/lib/local/Utilities/src/RecorderOpenFace.cpp +++ b/lib/local/Utilities/src/RecorderOpenFace.cpp @@ -132,7 +132,7 @@ RecorderOpenFace::RecorderOpenFace(const std::string in_filename, RecorderOpenFa // Create the filename for the general output file that contains all of the meta information about the recording path of_det_name(filename); - of_det_name = path(record_root) / of_det_name.concat("_of_details.txt"); + of_det_name = path(record_root) / path(filename + "_of_details.txt"); // Write in the of file what we are outputing what is the input etc. metadata_file.open(of_det_name.string(), std::ios_base::out); @@ -163,13 +163,13 @@ RecorderOpenFace::RecorderOpenFace(const std::string in_filename, RecorderOpenFa metadata_file << "Camera parameters:" << parameters.getFx() << "," << parameters.getFy() << "," << parameters.getCx() << "," << parameters.getCy() << endl; // Create the required individual recorders, CSV, HOG, aligned, video - csv_filename = path(filename).concat(".csv").string(); + csv_filename = filename + ".csv"; // Consruct HOG recorder here if(params.outputHOG()) { // Output the data based on record_root, but do not include record_root in the meta file, as it is also in that directory - std::string hog_filename = path(filename).concat(".hog").string(); + std::string hog_filename = filename + ".hog"; metadata_file << "Output HOG:" << hog_filename << endl; hog_filename = (path(record_root) / hog_filename).string(); hog_recorder.Open(hog_filename); @@ -181,13 +181,13 @@ RecorderOpenFace::RecorderOpenFace(const std::string in_filename, RecorderOpenFa if(parameters.isSequence()) { // Output the data based on record_root, but do not include record_root in the meta file, as it is also in that directory - this->media_filename = path(filename).concat(".avi").string(); + this->media_filename = filename + ".avi"; metadata_file << "Output video:" << this->media_filename << endl; this->media_filename = (path(record_root) / this->media_filename).string(); } else { - this->media_filename = path(filename).concat(".jpg").string(); + this->media_filename = filename + ".jpg"; metadata_file << "Output image:" << this->media_filename << endl; this->media_filename = (path(record_root) / this->media_filename).string(); } @@ -196,7 +196,7 @@ RecorderOpenFace::RecorderOpenFace(const std::string in_filename, RecorderOpenFa // Prepare image recording if (params.outputAlignedFaces()) { - aligned_output_directory = path(filename + "_aligned").string(); + aligned_output_directory = filename + "_aligned"; metadata_file << "Output aligned directory:" << this->aligned_output_directory << endl; this->aligned_output_directory = (path(record_root) / this->aligned_output_directory).string(); CreateDirectory(aligned_output_directory); diff --git a/lib/local/Utilities/src/SequenceCapture.cpp b/lib/local/Utilities/src/SequenceCapture.cpp index c839a965..74825757 100644 --- a/lib/local/Utilities/src/SequenceCapture.cpp +++ b/lib/local/Utilities/src/SequenceCapture.cpp @@ -44,6 +44,10 @@ // OpenCV includes #include +// For timing +#include +#include + using namespace Utilities; #define INFO_STREAM( stream ) \ @@ -179,16 +183,19 @@ bool SequenceCapture::Open(std::vector& arguments) } // Get current date/time, format is YYYY-MM-DD.HH:mm, useful for saving data from webcam -const std::string currentDateTime() { - time_t now = time(0); - struct tm tstruct; - char buf[200]; - localtime_s(&tstruct, &now); - // Visit http://www.cplusplus.com/reference/clibrary/ctime/strftime/ - // for more information about date/time format - strftime(buf, sizeof(buf), "%Y-%m-%d-%H-%M", &tstruct); +const std::string currentDateTime() +{ - return buf; + time_t rawtime; + struct tm * timeinfo; + char buffer[80]; + + time(&rawtime); + timeinfo = localtime(&rawtime); + + strftime(buffer, sizeof(buffer), "%Y-%m-%d-%H-%M", timeinfo); + + return buffer; }