From 05c7d4710ccee2023b0e5e11fbd1d26b3e707ae5 Mon Sep 17 00:00:00 2001 From: Tadas Baltrusaitis Date: Thu, 6 Oct 2016 10:05:25 -0400 Subject: [PATCH] Gaze visualization changes. --- gui/OpenFaceDemo/MainWindow.xaml.cs | 7 ++++--- lib/local/CppInerop/FaceAnalyserInterop.h | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/gui/OpenFaceDemo/MainWindow.xaml.cs b/gui/OpenFaceDemo/MainWindow.xaml.cs index 38cea10..4ff6b03 100644 --- a/gui/OpenFaceDemo/MainWindow.xaml.cs +++ b/gui/OpenFaceDemo/MainWindow.xaml.cs @@ -258,6 +258,7 @@ namespace OpenFaceDemo List pose = new List(); clnf_model.GetCorrectedPoseCamera(pose, fx, fy, cx, cy); List non_rigid_params = clnf_model.GetNonRigidParams(); + double scale = clnf_model.GetRigidParams()[0]; double time_stamp = (DateTime.Now - (DateTime)startTime).TotalMilliseconds; // The face analysis step (only done if recording AUs, HOGs or video) @@ -274,7 +275,7 @@ namespace OpenFaceDemo { landmarks = clnf_model.CalculateLandmarks(); lines = clnf_model.CalculateBox((float)fx, (float)fy, (float)cx, (float)cy); - gaze_lines = face_analyser.CalculateGazeLines((float)fx, (float)fy, (float)cx, (float)cy); + gaze_lines = face_analyser.CalculateGazeLines(scale, (float)fx, (float)fy, (float)cx, (float)cy); } // Visualisation @@ -303,8 +304,8 @@ namespace OpenFaceDemo browPlot.AddDataPoint(new DataPoint() { Time = CurrentTime, values = browDict, Confidence = confidence }); Dictionary eyeDict = new Dictionary(); - eyeDict[0] = 0.5 * widen_cumm + 0.5 * eye_widen; - eyeDict[1] = 0.5 * wrinkle_cumm + 0.5 * nose_wrinkle; + eyeDict[0] = 0.7 * widen_cumm + 0.3 * eye_widen; + eyeDict[1] = 0.7 * wrinkle_cumm + 0.3 * nose_wrinkle; eyePlot.AddDataPoint(new DataPoint() { Time = CurrentTime, values = eyeDict, Confidence = confidence }); smile_cumm = smileDict[0]; diff --git a/lib/local/CppInerop/FaceAnalyserInterop.h b/lib/local/CppInerop/FaceAnalyserInterop.h index 84531df..e71b58d 100644 --- a/lib/local/CppInerop/FaceAnalyserInterop.h +++ b/lib/local/CppInerop/FaceAnalyserInterop.h @@ -327,18 +327,18 @@ public: } - System::Collections::Generic::List^>^ CalculateGazeLines(float fx, float fy, float cx, float cy) + System::Collections::Generic::List^>^ CalculateGazeLines(double scale, float fx, float fy, float cx, float cy) { cv::Mat_ cameraMat = (cv::Mat_(3, 3) << fx, 0, cx, 0, fy, cy, 0, 0, 0); vector points_left; points_left.push_back(cv::Point3f(*pupil_left)); - points_left.push_back(cv::Point3f(*pupil_left + *gazeDirection0*40.0)); + points_left.push_back(cv::Point3f(*pupil_left + *gazeDirection0 * 40.0 * scale)); vector points_right; points_right.push_back(cv::Point3f(*pupil_right)); - points_right.push_back(cv::Point3f(*pupil_right + *gazeDirection1*40.0)); + points_right.push_back(cv::Point3f(*pupil_right + *gazeDirection1 * 40.0 * scale)); // Perform manual projection of points vector imagePoints_left;