From 7addeffdea8415c54475f3f16a5763a7254ce57f Mon Sep 17 00:00:00 2001 From: Tadas Baltrusaitis Date: Wed, 24 Jan 2018 18:58:12 +0000 Subject: [PATCH] A couple of bug fixes: - progress reporting in sequence capture when not opening from command line arguments - stop button and closing the app works when multiple videos have been opened --- gui/OpenFaceOffline/MainWindow.xaml.cs | 18 ++++++++++++------ lib/local/CppInerop/RecorderInterop.h | 5 +++++ lib/local/Utilities/src/SequenceCapture.cpp | 10 ++++++++-- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/gui/OpenFaceOffline/MainWindow.xaml.cs b/gui/OpenFaceOffline/MainWindow.xaml.cs index c7acd29..026861a 100644 --- a/gui/OpenFaceOffline/MainWindow.xaml.cs +++ b/gui/OpenFaceOffline/MainWindow.xaml.cs @@ -161,6 +161,12 @@ namespace OpenFaceOffline { SequenceReader reader = new SequenceReader(filenames[i], false); ProcessSequence(reader); + + // Before continuing to next video make sure the user did not stop the processing + if(!thread_running) + { + break; + } } } @@ -206,11 +212,10 @@ namespace OpenFaceOffline { if(!thread_running) { - continue; + break; } double progress = reader.GetProgress(); - bool detection_succeeding = clnf_model.DetectLandmarksInVideo(gray_frame, face_model_params); // The face analysis step (for AUs and eye gaze) @@ -240,8 +245,8 @@ namespace OpenFaceOffline processing_fps.AddFrame(); } - // Post-process the AU recordings, TODO - //recorder.FinishRecording(clnf_model, face_analyser); + // Post-process the AU recordings + face_analyser.PostProcessOutputFile(recorder.GetCSVFile()); EndMode(); @@ -283,7 +288,7 @@ namespace OpenFaceOffline { if (!thread_running) { - continue; + break; } // Setup recording @@ -337,7 +342,6 @@ namespace OpenFaceOffline // TODO how to report errors from the reader here? exceptions? logging? Problem for future versions? } - // TODO is this still needed? EndMode(); } @@ -700,6 +704,7 @@ namespace OpenFaceOffline SequenceReader reader = new SequenceReader(directory, true); processing_thread = new Thread(() => ProcessSequence(reader)); + processing_thread.Name = "Image sequence processing"; processing_thread.Start(); } @@ -712,6 +717,7 @@ namespace OpenFaceOffline var video_files = openMediaDialog(false); processing_thread = new Thread(() => ProcessSequences(video_files)); + processing_thread.Name = "Video processing"; processing_thread.Start(); } diff --git a/lib/local/CppInerop/RecorderInterop.h b/lib/local/CppInerop/RecorderInterop.h index f344bac..faba7ba 100644 --- a/lib/local/CppInerop/RecorderInterop.h +++ b/lib/local/CppInerop/RecorderInterop.h @@ -142,6 +142,11 @@ namespace UtilitiesOF { m_recorder->SetObservationGaze(gaze_direction0_cv, gaze_direction1_cv, gaze_angle_cv, landmarks_2D_cv, landmarks_3D_cv); } + System::String^ GetCSVFile() + { + return gcnew System::String(m_recorder->GetCSVFile().c_str()); + } + // Setting the observations void SetObservationPose(List^ pose) { diff --git a/lib/local/Utilities/src/SequenceCapture.cpp b/lib/local/Utilities/src/SequenceCapture.cpp index 7482575..9bec750 100644 --- a/lib/local/Utilities/src/SequenceCapture.cpp +++ b/lib/local/Utilities/src/SequenceCapture.cpp @@ -73,8 +73,6 @@ bool SequenceCapture::Open(std::vector& arguments) // Some default values std::string input_root = ""; fx = -1; fy = -1; cx = -1; cy = -1; - frame_num = 0; - time_stamp = 0; std::string separator = std::string(1, boost::filesystem::path::preferred_separator); @@ -204,6 +202,8 @@ bool SequenceCapture::OpenWebcam(int device, int image_width, int image_height, INFO_STREAM("Attempting to read from webcam: " << device); no_input_specified = false; + frame_num = 0; + time_stamp = 0; if (device < 0) { @@ -268,6 +268,8 @@ bool SequenceCapture::OpenVideoFile(std::string video_file, float fx, float fy, INFO_STREAM("Attempting to read from file: " << video_file); no_input_specified = false; + frame_num = 0; + time_stamp = 0; latest_frame = cv::Mat(); latest_gray_frame = cv::Mat(); @@ -310,6 +312,8 @@ bool SequenceCapture::OpenImageSequence(std::string directory, float fx, float f INFO_STREAM("Attempting to read from directory: " << directory); no_input_specified = false; + frame_num = 0; + time_stamp = 0; image_files.clear(); @@ -443,6 +447,8 @@ double SequenceCapture::GetProgress() } else { + //TODO test here + std::cout << frame_num << " " << vid_length << std::endl; return (double)frame_num / (double)vid_length; } }