Fixes with eye landmark visualization and opening image directories.

This commit is contained in:
Tadas Baltrusaitis 2018-01-16 07:29:30 +00:00
parent 5261d6916b
commit 9161a88889
4 changed files with 52 additions and 43 deletions

View file

@ -29,7 +29,7 @@
</MenuItem> </MenuItem>
<MenuItem Header="Open image(s)" Click="individualImageFilesOpenClick"> <MenuItem Header="Open image(s)" Click="individualImageFilesOpenClick">
</MenuItem> </MenuItem>
<MenuItem Header="Open image directory" Click="imageFileOpenClick"> <MenuItem Header="Open image directory" Click="individualImageDirectoryOpenClick">
</MenuItem> </MenuItem>
</MenuItem> </MenuItem>
<MenuItem Name="RecordingMenu" Header="Record" > <MenuItem Name="RecordingMenu" Header="Record" >

View file

@ -51,6 +51,7 @@ using GazeAnalyser_Interop;
using FaceDetectorInterop; using FaceDetectorInterop;
using MediaReader; using MediaReader;
using Microsoft.WindowsAPICodePack.Dialogs; using Microsoft.WindowsAPICodePack.Dialogs;
using System.Windows.Forms;
namespace OpenFaceOffline namespace OpenFaceOffline
{ {
@ -198,7 +199,7 @@ namespace OpenFaceOffline
MessageBoxImage icon = MessageBoxImage.Warning; MessageBoxImage icon = MessageBoxImage.Warning;
// Display message box // Display message box
MessageBox.Show(messageBoxText, caption, button, icon); System.Windows.MessageBox.Show(messageBoxText, caption, button, icon);
} }
} }
else else
@ -230,7 +231,7 @@ namespace OpenFaceOffline
MessageBoxImage icon = MessageBoxImage.Warning; MessageBoxImage icon = MessageBoxImage.Warning;
// Display message box // 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)(() => 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.Multiselect = true;
d.Filter = "Video files|*.avi;*.wmv;*.mov;*.mpg;*.mpeg;*.mp4"; d.Filter = "Video files|*.avi;*.wmv;*.mov;*.mpg;*.mpeg;*.mp4";
@ -686,7 +687,7 @@ namespace OpenFaceOffline
string[] image_files = new string[0]; string[] image_files = new string[0];
Dispatcher.Invoke(DispatcherPriority.Render, new TimeSpan(0, 0, 0, 2, 0), (Action)(() => 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.Multiselect = true;
if(images) if(images)
{ {
@ -707,6 +708,33 @@ namespace OpenFaceOffline
return new ImageReader(img_files_list); 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) private void individualImageFilesOpenClick(object sender, RoutedEventArgs e)
{ {
// First clean up existing tracking // First clean up existing tracking
@ -719,57 +747,37 @@ namespace OpenFaceOffline
} }
// Selecting a directory containing images
private void individualImageDirectoryOpenClick(object sender, RoutedEventArgs e) private void individualImageDirectoryOpenClick(object sender, RoutedEventArgs e)
{ {
// First clean up existing tracking
StopTracking(); StopTracking();
// TODO open directory here string directory = openDirectory();
new Thread(() => imageOpen()).Start(); if(!string.IsNullOrWhiteSpace(directory))
}
// TODO old
private void imageFileOpenClick(object sender, RoutedEventArgs e)
{ {
ImageReader reader = new ImageReader(directory);
new Thread(() => imageOpen()).Start(); processing_thread = new Thread(() => ProcessIndividualImages(reader));
}
// TODO old
private void imageOpen()
{
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";
if (d.ShowDialog(this) == true)
{
string[] image_files = d.FileNames;
processing_thread = new Thread(() => ProcessingLoop(image_files, -3));
processing_thread.Start(); processing_thread.Start();
}
}
}
}));
}
private void imageSequenceFileOpenClick(object sender, RoutedEventArgs e) private void imageSequenceFileOpenClick(object sender, RoutedEventArgs e)
{ {
new Thread(() => imageSequenceOpen()).Start(); new Thread(() => imageSequenceOpen()).Start();
} }
// TODO this should be removed and replace with directory open
private void imageSequenceOpen() private void imageSequenceOpen()
{ {
StopTracking(); StopTracking();
Dispatcher.Invoke(DispatcherPriority.Render, new TimeSpan(0, 0, 0, 2, 0), (Action)(() => 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.Multiselect = true;
d.Filter = "Image files|*.jpg;*.jpeg;*.bmp;*.png;*.gif"; d.Filter = "Image files|*.jpg;*.jpeg;*.bmp;*.png;*.gif";

View file

@ -68,6 +68,7 @@
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />

View file

@ -146,13 +146,13 @@ namespace OpenFaceOffline
int next_point = id + 1; int next_point = id + 1;
if (id_internal == 7) next_point = 0 * multiplier; if (id_internal == 7) next_point = 0 + (multiplier * 56);
if (id_internal == 19) next_point = 8 * multiplier; if (id_internal == 19) next_point = 8 + (multiplier * 56);
if (id_internal == 27) next_point = 20 * multiplier; if (id_internal == 27) next_point = 20 + (multiplier * 56);
if (id_internal == 35) next_point = 28 * multiplier; if (id_internal == 35) next_point = 28 + (multiplier * 56);
if (id_internal == 47) next_point = 36 * multiplier; if (id_internal == 47) next_point = 36 + (multiplier * 56);
if (id_internal == 55) next_point = 48 * multiplier; 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); var q2 = new Point(ActualWidth * OverlayEyePoints[next_point].X / width, ActualHeight * OverlayEyePoints[next_point].Y / height);