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 Header="Open image(s)" Click="individualImageFilesOpenClick">
|
||||
</MenuItem>
|
||||
<MenuItem Header="Open image directory" Click="imageFileOpenClick">
|
||||
<MenuItem Header="Open image directory" Click="individualImageDirectoryOpenClick">
|
||||
</MenuItem>
|
||||
</MenuItem>
|
||||
<MenuItem Name="RecordingMenu" Header="Record" >
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
@ -707,6 +708,33 @@ namespace OpenFaceOffline
|
|||
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)
|
||||
{
|
||||
|
||||
// First clean up existing tracking
|
||||
StopTracking();
|
||||
|
||||
// TODO open directory here
|
||||
new Thread(() => imageOpen()).Start();
|
||||
}
|
||||
|
||||
// TODO old
|
||||
private void imageFileOpenClick(object sender, RoutedEventArgs e)
|
||||
string directory = openDirectory();
|
||||
if(!string.IsNullOrWhiteSpace(directory))
|
||||
{
|
||||
ImageReader reader = new ImageReader(directory);
|
||||
|
||||
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();
|
||||
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 = 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";
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue