diff --git a/exe/FaceLandmarkVid/FaceLandmarkVid.cpp b/exe/FaceLandmarkVid/FaceLandmarkVid.cpp index 3a1b75e..f394027 100644 --- a/exe/FaceLandmarkVid/FaceLandmarkVid.cpp +++ b/exe/FaceLandmarkVid/FaceLandmarkVid.cpp @@ -168,10 +168,8 @@ int main (int argc, char **argv) visualizer.SetObservationPose(pose_estimate, face_model.detection_certainty); visualizer.SetObservationGaze(gazeDirection0, gazeDirection1, LandmarkDetector::CalculateAllEyeLandmarks(face_model), LandmarkDetector::Calculate3DEyeLandmarks(face_model, sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy), face_model.detection_certainty); visualizer.SetFps(fps_tracker.GetFPS()); - visualizer.ShowObservation(); - - // detect key presses - char character_press = cv::waitKey(1); + // detect key presses (due to pecularities of OpenCV, you can get it when displaying images) + char character_press = visualizer.ShowObservation(); // restart the tracker if (character_press == 'r') diff --git a/exe/FaceLandmarkVidMulti/FaceLandmarkVidMulti.cpp b/exe/FaceLandmarkVidMulti/FaceLandmarkVidMulti.cpp index f0409f8..7398fb2 100644 --- a/exe/FaceLandmarkVidMulti/FaceLandmarkVidMulti.cpp +++ b/exe/FaceLandmarkVidMulti/FaceLandmarkVidMulti.cpp @@ -295,10 +295,9 @@ int main (int argc, char **argv) } } visualizer.SetFps(fps_tracker.GetFPS()); - visualizer.ShowObservation(); - // detect key presses - char character_press = cv::waitKey(1); + // show visualization and detect key presses + char character_press = visualizer.ShowObservation(); // restart the trackers if(character_press == 'r') @@ -312,7 +311,7 @@ int main (int argc, char **argv) // quit the application else if(character_press=='q') { - return(0); + return 0; } // Update the frame count @@ -332,6 +331,8 @@ int main (int argc, char **argv) active_models[model] = false; } + sequence_number++; + } return 0; diff --git a/exe/FeatureExtraction/FeatureExtraction.cpp b/exe/FeatureExtraction/FeatureExtraction.cpp index d90ce95..b507602 100644 --- a/exe/FeatureExtraction/FeatureExtraction.cpp +++ b/exe/FeatureExtraction/FeatureExtraction.cpp @@ -190,7 +190,15 @@ int main (int argc, char **argv) visualizer.SetObservationPose(pose_estimate, face_model.detection_certainty); visualizer.SetObservationGaze(gazeDirection0, gazeDirection1, LandmarkDetector::CalculateAllEyeLandmarks(face_model), LandmarkDetector::Calculate3DEyeLandmarks(face_model, sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy), face_model.detection_certainty); visualizer.SetFps(fps_tracker.GetFPS()); - visualizer.ShowObservation(); + + // detect key presses + char character_press = visualizer.ShowObservation(); + + // quit processing the current sequence (useful when in Webcam mode) + if (character_press == 'q') + { + break; + } // Setting up the recorder output open_face_rec.SetObservationHOG(detection_success, hog_descriptor, num_hog_rows, num_hog_cols, 31); // The number of channels in HOG is fixed at the moment, as using FHOG diff --git a/lib/local/Utilities/include/Visualizer.h b/lib/local/Utilities/include/Visualizer.h index 93f3b3e..787624d 100644 --- a/lib/local/Utilities/include/Visualizer.h +++ b/lib/local/Utilities/include/Visualizer.h @@ -82,7 +82,8 @@ namespace Utilities void SetFps(double fps); - void ShowObservation(); + // Return key-press that could have resulted in the open windows + char ShowObservation(); cv::Mat GetVisImage(); diff --git a/lib/local/Utilities/src/Visualizer.cpp b/lib/local/Utilities/src/Visualizer.cpp index 5448cb7..ae453ca 100644 --- a/lib/local/Utilities/src/Visualizer.cpp +++ b/lib/local/Utilities/src/Visualizer.cpp @@ -265,7 +265,7 @@ void Visualizer::SetFps(double fps) cv::putText(captured_image, fpsSt, cv::Point(10, 20), CV_FONT_HERSHEY_SIMPLEX, 0.5, CV_RGB(255, 0, 0), 1, CV_AA); } -void Visualizer::ShowObservation() +char Visualizer::ShowObservation() { if (vis_track) { @@ -280,7 +280,7 @@ void Visualizer::ShowObservation() { cv::imshow("hog", hog_image); } - cv::waitKey(1); + return cv::waitKey(1); } cv::Mat Visualizer::GetVisImage() diff --git a/matlab_runners/Demos/run_demo_images.m b/matlab_runners/Demos/run_demo_images.m index 8d8c408..0da3458 100644 --- a/matlab_runners/Demos/run_demo_images.m +++ b/matlab_runners/Demos/run_demo_images.m @@ -8,33 +8,17 @@ end in_dir = '../../samples/'; out_dir = './demo_img/'; -if(~exist(out_dir, 'file')) - mkdir(out_dir); -end +model = 'model/main_clnf_general.txt'; % Trained on in the wild and multi-pie data (a CLNF model) -% some parameters -verbose = true; +% Uncomment the below models if you want to try them +%model = 'model/main_clnf_wild.txt'; % Trained on in-the-wild data only -% Trained on in the wild and multi-pie data (less accurate CLM model) -% model = 'model/main_clm_general.txt'; -% Trained on in-the-wild -%model = 'model/main_clm_wild.txt'; +%model = 'model/main_clm_general.txt'; % Trained on in the wild and multi-pie data (less accurate SVR/CLM model) +%model = 'model/main_clm_wild.txt'; % Trained on in-the-wild -% Trained on in the wild and multi-pie data (more accurate CLNF model) -model = 'model/main_clnf_general.txt'; -% Trained on in-the-wild -%model = 'model/main_clnf_wild.txt'; - -command = executable; - -command = cat(2, command, [' -fdir "' in_dir '"']); - -if(verbose) - command = cat(2, command, [' -ofdir "' out_dir '"']); - command = cat(2, command, [' -oidir "' out_dir '"']); -end - -command = cat(2, command, [' -mloc "', model, '"']); +% Load images (-fdir), output images and all the features (-out_dir), use a +% user specified model (-mloc), and visualize everything (-verbose) +command = sprintf('%s -fdir "%s" -out_dir "%s" -verbose -mloc "%s" ', executable, in_dir, out_dir, model); % Demonstrates the multi-hypothesis slow landmark detection (more accurate % when dealing with non-frontal faces and less accurate face detections) diff --git a/matlab_runners/Demos/run_demo_video_multi.m b/matlab_runners/Demos/run_demo_video_multi.m index a77e042..b92e497 100644 --- a/matlab_runners/Demos/run_demo_video_multi.m +++ b/matlab_runners/Demos/run_demo_video_multi.m @@ -24,9 +24,8 @@ model = 'model/main_clnf_general.txt'; % Trained on in the wild and multi-pie da %model = 'model/main_clm_general.txt'; % Trained on in the wild and multi-pie data (less accurate SVR/CLM model) %model = 'model/main_clm_wild.txt'; % Trained on in-the-wild -% Create a command that will run the tracker on set of videos, -% and visualize the output (-verbose) -command = sprintf('%s -mloc "%s" -verbose', executable, model); +% Create a command that will run the tracker on set of videos and display the output +command = sprintf('%s -mloc "%s" ', executable, model); % add all videos to single argument list (so as not to load the model anew % for every video) diff --git a/matlab_runners/Demos/run_demo_videos.m b/matlab_runners/Demos/run_demo_videos.m index 6168eb2..97000a2 100644 --- a/matlab_runners/Demos/run_demo_videos.m +++ b/matlab_runners/Demos/run_demo_videos.m @@ -19,9 +19,8 @@ model = 'model/main_clnf_general.txt'; % Trained on in the wild and multi-pie da %model = 'model/main_clm_general.txt'; % Trained on in the wild and multi-pie data (less accurate SVR/CLM model) %model = 'model/main_clm_wild.txt'; % Trained on in-the-wild -% Create a command that will run the tracker on set of videos, -% and visualize the output (-verbose) -command = sprintf('%s -mloc "%s" -verbose', executable, model); +% Create a command that will run the tracker on set of videos and display the output +command = sprintf('%s -mloc "%s" ', executable, model); % add all videos to single argument list (so as not to load the model anew % for every video)