From 408d695f399b76b3bd5e80a3e283b330313454d7 Mon Sep 17 00:00:00 2001 From: Tadas Baltrusaitis Date: Sat, 13 Jan 2018 16:34:03 +0000 Subject: [PATCH] More work on the GUI --- gui/OpenFaceOffline/MainWindow.xaml.cs | 53 +++---------------- .../UI_items/MultiBarGraphHorz.xaml.cs | 4 +- 2 files changed, 9 insertions(+), 48 deletions(-) diff --git a/gui/OpenFaceOffline/MainWindow.xaml.cs b/gui/OpenFaceOffline/MainWindow.xaml.cs index 802ea28..e38b85f 100644 --- a/gui/OpenFaceOffline/MainWindow.xaml.cs +++ b/gui/OpenFaceOffline/MainWindow.xaml.cs @@ -261,7 +261,11 @@ namespace OpenFaceOffline // Initialize the face analyser face_analyser = new FaceAnalyserManaged(AppDomain.CurrentDomain.BaseDirectory, DynamicAUModels, image_output_size); - // Loading an image file (or a number of them) + // Loading an image file + var frame = new RawImage(reader.GetNextImage()); + var grayFrame = new RawImage(reader.GetCurrentFrameGray()); + + // This will be false when the image is not available while (reader.isOpened()) { if (!thread_running) @@ -269,14 +273,8 @@ namespace OpenFaceOffline continue; } - // Start the actual processing, TODO this should change? - Thread.CurrentThread.IsBackground = true; - clnf_model.Reset(); - var frame = new RawImage(reader.GetNextImage()); - var grayFrame = new RawImage(reader.GetCurrentFrameGray()); - double progress = reader.GetProgress(); // Detect faces here and return bounding boxes @@ -284,9 +282,6 @@ namespace OpenFaceOffline List confidences = new List(); face_detector.DetectFacesHOG(face_detections, grayFrame, confidences); - // For visualizing landmarks, TODO rem - List landmark_points = new List(); - for (int i = 0; i < face_detections.Count; ++i) { detectionSucceeding = clnf_model.DetectFaceLandmarksInImage(grayFrame, face_detections[i], face_model_params); @@ -302,44 +297,12 @@ namespace OpenFaceOffline // Only the final face will contain the details VisualizeFeatures(frame, landmarks, reader.GetFx(), reader.GetFy(), reader.GetCx(), reader.GetCy(), progress); - // TODO rem - //foreach (var p in landmarks) - //{ - // landmark_points.Add(new Point(p.Item1, p.Item2)); - //} - } - // Visualisation TODO this should be lifted out? and actually be grabbed from the visualizer? rather than drawing points ourselves? - //if (ShowTrackedVideo) - //{ - - // Dispatcher.Invoke(DispatcherPriority.Render, new TimeSpan(0, 0, 0, 0, 200), (Action)(() => - // { - // if (latest_img == null) - // { - // latest_img = frame.CreateWriteableBitmap(); - // } - - // frame.UpdateWriteableBitmap(latest_img); - - // video.Source = latest_img; - // video.Confidence = 1; - // video.FPS = processing_fps.GetFPS(); - // video.Progress = progress; - - // video.OverlayLines = new List>(); - - // video.OverlayPoints = landmark_points; - - // // TODO unify with other visualization - - // })); - //} - - // TODO is this needed - //latest_img = null; + latest_img = null; + frame = new RawImage(reader.GetNextImage()); + grayFrame = new RawImage(reader.GetCurrentFrameGray()); // TODO how to report errors from the reader here? exceptions? logging? Problem for future versions? } diff --git a/gui/OpenFaceOffline/UI_items/MultiBarGraphHorz.xaml.cs b/gui/OpenFaceOffline/UI_items/MultiBarGraphHorz.xaml.cs index 519d447..c0bf035 100644 --- a/gui/OpenFaceOffline/UI_items/MultiBarGraphHorz.xaml.cs +++ b/gui/OpenFaceOffline/UI_items/MultiBarGraphHorz.xaml.cs @@ -141,9 +141,7 @@ namespace OpenFaceOffline // Update the bars foreach (var value in data) { - double old_value = graphs[value.Key].GetTarget(); - // some smoothing as well - graphs[value.Key].SetValue(old_value * 0.15 + 0.85 * value.Value); + graphs[value.Key].SetValue(value.Value); } } }