diff --git a/lib/local/Utilities/include/SequenceCapture.h b/lib/local/Utilities/include/SequenceCapture.h index 8995b7b..874a254 100644 --- a/lib/local/Utilities/include/SequenceCapture.h +++ b/lib/local/Utilities/include/SequenceCapture.h @@ -95,6 +95,9 @@ namespace Utilities double time_stamp; + std::string input_name_relative; + std::string input_name_full; + // Name of the video file, image directory, or the webcam std::string name; diff --git a/lib/local/Utilities/src/RecorderOpenFace.cpp b/lib/local/Utilities/src/RecorderOpenFace.cpp index 38458e0..bece441 100644 --- a/lib/local/Utilities/src/RecorderOpenFace.cpp +++ b/lib/local/Utilities/src/RecorderOpenFace.cpp @@ -76,7 +76,7 @@ RecorderOpenFace::RecorderOpenFace(const std::string in_filename, RecorderOpenFa { // From the filename, strip out the name without directory and extension - filename = path(in_filename).replace_extension("").filename().string(); + filename = path(string(in_filename)).replace_extension("").filename().string(); // Consuming the input arguments bool* valid = new bool[arguments.size()]; diff --git a/lib/local/Utilities/src/SequenceCapture.cpp b/lib/local/Utilities/src/SequenceCapture.cpp index 3925e1e..cf74a81 100644 --- a/lib/local/Utilities/src/SequenceCapture.cpp +++ b/lib/local/Utilities/src/SequenceCapture.cpp @@ -156,17 +156,28 @@ bool SequenceCapture::Open(std::vector& arguments) no_input_specified = !file_found; + // Based on what was read in open the sequence TODO if (device != -1) { + input_name_relative = "webcam"; + input_name_full = "webcam"; return OpenWebcam(device, 640, 480, fx, fy, cx, cy); } if (!input_video_file.empty()) { + input_name_relative = input_video_file; + if (boost::filesystem::path(input_name_relative).is_absolute()) + { + input_name_full = input_name_relative; + } + + boost::filesystem::path(input_name_full).is_absolute(); return OpenVideoFile(input_video_file, fx, fy, cx, cy); } if (!input_sequence_directory.empty()) { + input_name_relative = input_sequence_directory; return OpenImageSequence(input_sequence_directory, fx, fy, cx, cy); } @@ -176,6 +187,20 @@ bool SequenceCapture::Open(std::vector& arguments) return false; } +// 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); + + return buf; +} + + bool SequenceCapture::OpenWebcam(int device, int image_width, int image_height, float fx, float fy, float cx, float cy) { INFO_STREAM("Attempting to read from webcam: " << device); @@ -224,9 +249,9 @@ bool SequenceCapture::OpenWebcam(int device, int image_width, int image_height, } SetCameraIntrinsics(fx, fy, cx, cy); + std::string time = currentDateTime(); + this->name = "webcam_" + time; - this->name = "webcam"; // TODO number - start_time = cv::getTickCount(); return true;