diff --git a/gui/OpenFaceOffline/MainWindow.xaml.cs b/gui/OpenFaceOffline/MainWindow.xaml.cs index ad0e7220..612a8160 100644 --- a/gui/OpenFaceOffline/MainWindow.xaml.cs +++ b/gui/OpenFaceOffline/MainWindow.xaml.cs @@ -208,6 +208,14 @@ namespace OpenFaceOffline // Reload the face landmark detector if needed ReloadLandmarkDetector(); + if(!landmark_detector.isLoaded()) + { + DetectorNotFoundWarning(); + EndMode(); + thread_running = false; + return; + } + // Set the face detector face_model_params.SetFaceDetector(DetectorHaar, DetectorHOG, DetectorCNN); face_model_params.optimiseForVideo(); @@ -302,10 +310,18 @@ namespace OpenFaceOffline // Reload the face landmark detector if needed ReloadLandmarkDetector(); + + if (!landmark_detector.isLoaded()) + { + DetectorNotFoundWarning(); + EndMode(); + thread_running = false; + return; + } + // Setup the parameters optimized for working on individual images rather than sequences face_model_params.optimiseForImages(); - // Setup the visualization Visualizer visualizer_of = new Visualizer(ShowTrackedVideo || RecordTracked, ShowAppearance, ShowAppearance, false); @@ -425,7 +441,17 @@ namespace OpenFaceOffline } } + private void DetectorNotFoundWarning() + { + string messageBoxText = "Could not open the landmark detector model file. For instructions of how to download them, see https://github.com/TadasBaltrusaitis/OpenFace/wiki/Model-download"; + string caption = "Model file not found or corrupt"; + MessageBoxButton button = MessageBoxButton.OK; + MessageBoxImage icon = MessageBoxImage.Warning; + // Display message box + System.Windows.MessageBox.Show(messageBoxText, caption, button, icon); + + } private void RecordObservation(RecorderOpenFace recorder, RawImage vis_image, int face_id, bool success, float fx, float fy, float cx, float cy, double timestamp, int frame_number) { diff --git a/lib/local/CppInerop/LandmarkDetectorInterop.h b/lib/local/CppInerop/LandmarkDetectorInterop.h index af0a58a3..b1ba4019 100644 --- a/lib/local/CppInerop/LandmarkDetectorInterop.h +++ b/lib/local/CppInerop/LandmarkDetectorInterop.h @@ -152,17 +152,17 @@ namespace CppInterop { bool IsCECLM() { - return params->curr_face_detector == ::LandmarkDetector::FaceModelParameters::CECLM_DETECTOR; + return params->curr_landmark_detector == ::LandmarkDetector::FaceModelParameters::CECLM_DETECTOR; } bool IsCLNF() { - return params->curr_face_detector == ::LandmarkDetector::FaceModelParameters::CLNF_DETECTOR; + return params->curr_landmark_detector == ::LandmarkDetector::FaceModelParameters::CLNF_DETECTOR; } bool IsCLM() { - return params->curr_face_detector == ::LandmarkDetector::FaceModelParameters::CLM_DETECTOR; + return params->curr_landmark_detector == ::LandmarkDetector::FaceModelParameters::CLM_DETECTOR; } System::String^ GetMTCNNLocation() @@ -259,6 +259,11 @@ namespace CppInterop { this->!CLNF(); } + bool isLoaded() + { + return clnf->loaded_successfully; + } + ::LandmarkDetector::CLNF* getCLNF() { return clnf;