diff --git a/gui/OpenFaceOffline/MainWindow.xaml.cs b/gui/OpenFaceOffline/MainWindow.xaml.cs index abe79a5..bf29e05 100644 --- a/gui/OpenFaceOffline/MainWindow.xaml.cs +++ b/gui/OpenFaceOffline/MainWindow.xaml.cs @@ -595,6 +595,7 @@ namespace OpenFaceOffline { video.OverlayLines.Clear(); video.OverlayPoints.Clear(); + video.OverlayEyePoints.Clear(); video.GazeLines.Clear(); } else @@ -607,8 +608,15 @@ namespace OpenFaceOffline landmark_points.Add(new Point(p.Item1, p.Item2)); } - video.OverlayPoints = landmark_points; + List eye_landmark_points = new List(); + foreach (var p in eye_landmarks) + { + eye_landmark_points.Add(new Point(p.Item1, p.Item2)); + } + + video.OverlayPoints = landmark_points; + video.OverlayEyePoints = eye_landmark_points; video.GazeLines = gaze_lines; } } diff --git a/gui/OpenFaceOffline/UI_items/OverlayImage.xaml.cs b/gui/OpenFaceOffline/UI_items/OverlayImage.xaml.cs index b7bce90..e452a10 100644 --- a/gui/OpenFaceOffline/UI_items/OverlayImage.xaml.cs +++ b/gui/OpenFaceOffline/UI_items/OverlayImage.xaml.cs @@ -75,6 +75,7 @@ namespace OpenFaceOffline InitializeComponent(); OverlayLines = new List>(); OverlayPoints = new List(); + OverlayEyePoints = new List(); GazeLines = new List>(); Progress = -1; @@ -90,6 +91,9 @@ namespace OpenFaceOffline if (OverlayPoints == null) OverlayPoints = new List(); + if (OverlayEyePoints == null) + OverlayEyePoints = new List(); + if (Source == null || !(Source is WriteableBitmap)) return; @@ -120,7 +124,34 @@ namespace OpenFaceOffline var q = new Point(ActualWidth * p.X / width, ActualHeight * p.Y / height); - dc.DrawEllipse(new SolidColorBrush(Color.FromArgb((byte)(200 * Confidence), 255, 255, 100)), null, q, 2, 2); + dc.DrawEllipse(new SolidColorBrush(Color.FromArgb((byte)(200 * Confidence), 255, 255, 100)), null, q, 1, 1); + } + + for (int id = 0; id < OverlayEyePoints.Count; id++) + { + + var q1 = new Point(ActualWidth * OverlayEyePoints[id].X / width, ActualHeight * OverlayEyePoints[id].Y / height); + + int next_point = id + 1; + + if (id == 7) next_point = 0; + if (id == 19) next_point = 8; + if (id == 27) next_point = 20; + + if (id == 35) next_point = 28; + if (id == 47) next_point = 36; + if (id == 55) next_point = 48; + + var q2 = new Point(ActualWidth * OverlayEyePoints[next_point].X / width, ActualHeight * OverlayEyePoints[next_point].Y / height); + + if (id < 28 && (id < 8 || id > 19) || (id>=28 &&(id-28<8 || id-28 >19))) + { + dc.DrawLine(new Pen(new SolidColorBrush(Color.FromArgb(200, (byte)(240), (byte)(30), (byte)100)), 1), q1, q2); + } + else + { + dc.DrawLine(new Pen(new SolidColorBrush(Color.FromArgb(200, (byte)(100), (byte)(30), (byte)240)), 1), q1, q2); + } } double scaling = ActualWidth / 400.0; @@ -156,6 +187,7 @@ namespace OpenFaceOffline public List> OverlayLines { get; set; } public List> GazeLines { get; set; } public List OverlayPoints { get; set; } + public List OverlayEyePoints { get; set; } public double Confidence { get; set; } public double FPS { get; set; } diff --git a/lib/local/LandmarkDetector/include/LandmarkDetectorUtils.h b/lib/local/LandmarkDetector/include/LandmarkDetectorUtils.h index daa16a3..18ee9df 100644 --- a/lib/local/LandmarkDetector/include/LandmarkDetectorUtils.h +++ b/lib/local/LandmarkDetector/include/LandmarkDetectorUtils.h @@ -115,6 +115,7 @@ namespace LandmarkDetector vector CalculateLandmarks(const cv::Mat_& shape2D, cv::Mat_& visibilities); vector CalculateLandmarks(CLNF& clnf_model); + vector CalculateEyeLandmarks(CLNF& clnf_model); void DrawLandmarks(cv::Mat img, vector landmarks); void Draw(cv::Mat img, const cv::Mat_& shape2D, const cv::Mat_& visibilities);