diff --git a/gui/OpenFaceOffline/MainWindow.xaml.cs b/gui/OpenFaceOffline/MainWindow.xaml.cs index 3990730..eb3e9b8 100644 --- a/gui/OpenFaceOffline/MainWindow.xaml.cs +++ b/gui/OpenFaceOffline/MainWindow.xaml.cs @@ -85,7 +85,6 @@ namespace OpenFaceOffline // Some members for displaying the results private Capture capture; - private FaceDetector face_detector; private WriteableBitmap latest_img; private WriteableBitmap latest_aligned_face; private WriteableBitmap latest_HOG_descriptor; @@ -100,11 +99,15 @@ namespace OpenFaceOffline FpsTracker processing_fps = new FpsTracker(); volatile bool detectionSucceeding = false; - + // For tracking + private FaceDetector face_detector; FaceModelParameters face_model_params; CLNF clnf_model; - FaceAnalyserManaged face_analyser; + + // For face analysis + FaceAnalyserManaged face_analyser_sequence; + FaceAnalyserManaged face_analyser_image; GazeAnalyserManaged gaze_analyser; // Recording parameters (default values) @@ -150,7 +153,8 @@ namespace OpenFaceOffline face_model_params = new FaceModelParameters(root, false); clnf_model = new CLNF(face_model_params); - face_analyser = new FaceAnalyserManaged(root, DynamicAUModels, image_output_size); + face_analyser_sequence = new FaceAnalyserManaged(root, true, image_output_size); // TODO how to deal with dynamic and static models here + face_analyser_image = new FaceAnalyserManaged(root, false, image_output_size); gaze_analyser = new GazeAnalyserManaged(); @@ -302,14 +306,17 @@ namespace OpenFaceOffline List confidences = new List(); face_detector.DetectFacesHOG(face_detections, grayFrame, confidences); - //Rectangle - var landmark_detections = clnf_model.DetectMultiFaceLandmarksInImage(grayFrame, face_model_params); - - // Go over all detected faces - for (int i = 0; i < landmark_detections.Count; ++i) + for (int i = 0; i < face_detections.Count; ++i) { + bool success = clnf_model.DetectFaceLandmarksInImage(grayFrame, face_model_params); + // Predict action units - var au_preds = face_analyser.PredictStaticAUs(grayFrame, landmark_detections[i]); + // TODO face analyser should be optimized for single images + var au_preds = face_analyser.PredictStaticAUs(grayFrame, clnf_model.CalculateAllLandmarks()); + + // Predic eye gaze + gaze_analyser.AddNextFrame(clnf_model, success, fx, fy, cx, cy); // TODO fx should be from reader + } List landmark_points = new List(); diff --git a/lib/local/CppInerop/FaceAnalyserInterop.h b/lib/local/CppInerop/FaceAnalyserInterop.h index 74d5433..2566984 100644 --- a/lib/local/CppInerop/FaceAnalyserInterop.h +++ b/lib/local/CppInerop/FaceAnalyserInterop.h @@ -102,6 +102,12 @@ public: { string root_std = msclr::interop::marshal_as(root); FaceAnalysis::FaceAnalyserParameters params(root_std); + + if (!dynamic) + { + params.OptimizeForImages(); + } + params.setAlignedOutput(output_width); face_analyser = new FaceAnalysis::FaceAnalyser(params); diff --git a/lib/local/CppInerop/LandmarkDetectorInterop.h b/lib/local/CppInerop/LandmarkDetectorInterop.h index 20fbcc3..7e8abdf 100644 --- a/lib/local/CppInerop/LandmarkDetectorInterop.h +++ b/lib/local/CppInerop/LandmarkDetectorInterop.h @@ -204,6 +204,7 @@ namespace CppInterop { return ::LandmarkDetector::DetectLandmarksInImage(image->Mat, *clnf, *modelParams->getParams()); } + // TODO rem old List^>^>^ DetectMultiFaceLandmarksInImage(OpenCVWrappers::RawImage^ image, FaceModelParameters^ modelParams) { auto all_landmarks = gcnew List^>^>(); diff --git a/lib/local/Utilities/src/ImageCapture.cpp b/lib/local/Utilities/src/ImageCapture.cpp index 0ec7154..714b824 100644 --- a/lib/local/Utilities/src/ImageCapture.cpp +++ b/lib/local/Utilities/src/ImageCapture.cpp @@ -68,7 +68,6 @@ bool ImageCapture::Open(std::vector& arguments) // Some default values std::string input_root = ""; fx = -1; fy = -1; cx = -1; cy = -1; - frame_num = 0; std::string separator = std::string(1, boost::filesystem::path::preferred_separator); @@ -179,7 +178,8 @@ bool ImageCapture::Open(std::vector& arguments) bool ImageCapture::OpenImageFiles(const std::vector& image_files, float fx, float fy, float cx, float cy) { - + // Setting some defaults + frame_num = 0; no_input_specified = false; latest_frame = cv::Mat(); @@ -218,6 +218,8 @@ bool ImageCapture::OpenDirectory(std::string directory, std::string bbox_directo { INFO_STREAM("Attempting to read from directory: " << directory); + // Setup some defaults + frame_num = 0; no_input_specified = false; image_files.clear();