diff --git a/gui/OpenFaceOffline/MainWindow.xaml b/gui/OpenFaceOffline/MainWindow.xaml index 00f0e36..a29caff 100644 --- a/gui/OpenFaceOffline/MainWindow.xaml +++ b/gui/OpenFaceOffline/MainWindow.xaml @@ -29,7 +29,7 @@ - + diff --git a/gui/OpenFaceOffline/MainWindow.xaml.cs b/gui/OpenFaceOffline/MainWindow.xaml.cs index 0597924..fa2a63b 100644 --- a/gui/OpenFaceOffline/MainWindow.xaml.cs +++ b/gui/OpenFaceOffline/MainWindow.xaml.cs @@ -51,6 +51,7 @@ using GazeAnalyser_Interop; using FaceDetectorInterop; using MediaReader; using Microsoft.WindowsAPICodePack.Dialogs; +using System.Windows.Forms; namespace OpenFaceOffline { @@ -198,7 +199,7 @@ namespace OpenFaceOffline MessageBoxImage icon = MessageBoxImage.Warning; // Display message box - MessageBox.Show(messageBoxText, caption, button, icon); + System.Windows.MessageBox.Show(messageBoxText, caption, button, icon); } } else @@ -230,7 +231,7 @@ namespace OpenFaceOffline MessageBoxImage icon = MessageBoxImage.Warning; // Display message box - MessageBox.Show(messageBoxText, caption, button, icon); + System.Windows.MessageBox.Show(messageBoxText, caption, button, icon); } } } @@ -664,7 +665,7 @@ namespace OpenFaceOffline Dispatcher.Invoke(DispatcherPriority.Render, new TimeSpan(0, 0, 0, 2, 0), (Action)(() => { - var d = new OpenFileDialog(); + var d = new Microsoft.Win32.OpenFileDialog(); d.Multiselect = true; d.Filter = "Video files|*.avi;*.wmv;*.mov;*.mpg;*.mpeg;*.mp4"; @@ -686,7 +687,7 @@ namespace OpenFaceOffline string[] image_files = new string[0]; Dispatcher.Invoke(DispatcherPriority.Render, new TimeSpan(0, 0, 0, 2, 0), (Action)(() => { - var d = new OpenFileDialog(); + var d = new Microsoft.Win32.OpenFileDialog(); d.Multiselect = true; if(images) { @@ -706,7 +707,34 @@ namespace OpenFaceOffline List img_files_list = new List(image_files); return new ImageReader(img_files_list); } + + private string openDirectory() + { + string to_return = ""; + using (var fbd = new FolderBrowserDialog()) + { + DialogResult result = fbd.ShowDialog(); + if (result == System.Windows.Forms.DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath)) + { + to_return = fbd.SelectedPath; + } + else + { + // TODO warning message here + string messageBoxText = "Could not open the directory."; + string caption = "Invalid directory"; + MessageBoxButton button = MessageBoxButton.OK; + MessageBoxImage icon = MessageBoxImage.Warning; + // Display message box + System.Windows.MessageBox.Show(messageBoxText, caption, button, icon); + + } + } + return to_return; + } + + // Selecting one or more images in a directory private void individualImageFilesOpenClick(object sender, RoutedEventArgs e) { // First clean up existing tracking @@ -719,57 +747,37 @@ namespace OpenFaceOffline } + // Selecting a directory containing images private void individualImageDirectoryOpenClick(object sender, RoutedEventArgs e) - { - - StopTracking(); - - // TODO open directory here - new Thread(() => imageOpen()).Start(); - } - - // TODO old - private void imageFileOpenClick(object sender, RoutedEventArgs e) { - new Thread(() => imageOpen()).Start(); - } - - // TODO old - private void imageOpen() - { + // First clean up existing tracking StopTracking(); - Dispatcher.Invoke(DispatcherPriority.Render, new TimeSpan(0, 0, 0, 2, 0), (Action)(() => - { - var d = new OpenFileDialog(); - d.Multiselect = true; - d.Filter = "Image files|*.jpg;*.jpeg;*.bmp;*.png;*.gif"; + string directory = openDirectory(); + if(!string.IsNullOrWhiteSpace(directory)) + { + ImageReader reader = new ImageReader(directory); - if (d.ShowDialog(this) == true) - { - - string[] image_files = d.FileNames; - - processing_thread = new Thread(() => ProcessingLoop(image_files, -3)); - processing_thread.Start(); - - } - })); + processing_thread = new Thread(() => ProcessIndividualImages(reader)); + processing_thread.Start(); + } } + private void imageSequenceFileOpenClick(object sender, RoutedEventArgs e) { new Thread(() => imageSequenceOpen()).Start(); } + // TODO this should be removed and replace with directory open private void imageSequenceOpen() { StopTracking(); Dispatcher.Invoke(DispatcherPriority.Render, new TimeSpan(0, 0, 0, 2, 0), (Action)(() => { - var d = new OpenFileDialog(); + var d = new Microsoft.Win32.OpenFileDialog(); d.Multiselect = true; d.Filter = "Image files|*.jpg;*.jpeg;*.bmp;*.png;*.gif"; diff --git a/gui/OpenFaceOffline/OpenFaceOffline.csproj b/gui/OpenFaceOffline/OpenFaceOffline.csproj index 4a26cbf..1b20fa3 100644 --- a/gui/OpenFaceOffline/OpenFaceOffline.csproj +++ b/gui/OpenFaceOffline/OpenFaceOffline.csproj @@ -68,6 +68,7 @@ + diff --git a/gui/OpenFaceOffline/UI_items/OverlayImage.xaml.cs b/gui/OpenFaceOffline/UI_items/OverlayImage.xaml.cs index 64c7a33..16cce83 100644 --- a/gui/OpenFaceOffline/UI_items/OverlayImage.xaml.cs +++ b/gui/OpenFaceOffline/UI_items/OverlayImage.xaml.cs @@ -146,13 +146,13 @@ namespace OpenFaceOffline int next_point = id + 1; - if (id_internal == 7) next_point = 0 * multiplier; - if (id_internal == 19) next_point = 8 * multiplier; - if (id_internal == 27) next_point = 20 * multiplier; + if (id_internal == 7) next_point = 0 + (multiplier * 56); + if (id_internal == 19) next_point = 8 + (multiplier * 56); + if (id_internal == 27) next_point = 20 + (multiplier * 56); - if (id_internal == 35) next_point = 28 * multiplier; - if (id_internal == 47) next_point = 36 * multiplier; - if (id_internal == 55) next_point = 48 * multiplier; + if (id_internal == 35) next_point = 28 + (multiplier * 56); + if (id_internal == 47) next_point = 36 + (multiplier * 56); + if (id_internal == 55) next_point = 48 + (multiplier * 56); var q2 = new Point(ActualWidth * OverlayEyePoints[next_point].X / width, ActualHeight * OverlayEyePoints[next_point].Y / height);