Fixes with eye landmark visualization and opening image directories.
This commit is contained in:
parent
5261d6916b
commit
9161a88889
4 changed files with 52 additions and 43 deletions
|
@ -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" >
|
||||||
|
|
|
@ -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)
|
|
||||||
{
|
|
||||||
|
|
||||||
new Thread(() => imageOpen()).Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO old
|
|
||||||
private void imageOpen()
|
|
||||||
{
|
|
||||||
StopTracking();
|
|
||||||
|
|
||||||
Dispatcher.Invoke(DispatcherPriority.Render, new TimeSpan(0, 0, 0, 2, 0), (Action)(() =>
|
|
||||||
{
|
{
|
||||||
var d = new OpenFileDialog();
|
ImageReader reader = new ImageReader(directory);
|
||||||
d.Multiselect = true;
|
|
||||||
d.Filter = "Image files|*.jpg;*.jpeg;*.bmp;*.png;*.gif";
|
|
||||||
|
|
||||||
if (d.ShowDialog(this) == true)
|
processing_thread = new Thread(() => ProcessIndividualImages(reader));
|
||||||
{
|
processing_thread.Start();
|
||||||
|
}
|
||||||
string[] image_files = d.FileNames;
|
|
||||||
|
|
||||||
processing_thread = new Thread(() => ProcessingLoop(image_files, -3));
|
|
||||||
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";
|
||||||
|
|
||||||
|
|
|
@ -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" />
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue