open source pkg v1

This commit is contained in:
Vijay Yadev
2020-08-04 19:12:31 -04:00
parent bef213dba9
commit c389fc2c47
3708 changed files with 1624220 additions and 1 deletions

View File

@@ -0,0 +1,17 @@
<UserControl x:Class="OpenFaceOffline.BarGraph"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="100" d:DesignWidth="100">
<StackPanel HorizontalAlignment="Center" >
<Border Name="barContainerPos" Background="PowderBlue" Width="32" DockPanel.Dock="Top" MinHeight="50">
<Rectangle Name="barPos" Fill="CadetBlue" Height="0" VerticalAlignment="Bottom"/>
</Border>
<Border Name="barContainerNeg" Background="PowderBlue" Width="32" MinHeight="50">
<Rectangle Name="barNeg" Fill="CadetBlue" Height="0" VerticalAlignment="Top"/>
</Border>
</StackPanel>
</UserControl>

View File

@@ -0,0 +1,97 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016, Carnegie Mellon University and University of Cambridge,
// all rights reserved.
//
// THIS SOFTWARE IS PROVIDED “AS IS” FOR ACADEMIC USE ONLY AND ANY EXPRESS
// OR IMPLIED WARRANTIES WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
// BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY.
// OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// Notwithstanding the license granted herein, Licensee acknowledges that certain components
// of the Software may be covered by so-called “open source” software licenses (“Open Source
// Components”), which means any software licenses approved as open source licenses by the
// Open Source Initiative or any substantially similar licenses, including without limitation any
// license that, as a condition of distribution of the software licensed under such license,
// requires that the distributor make the software available in source code format. Licensor shall
// provide a list of Open Source Components for a particular version of the Software upon
// Licensees request. Licensee will comply with the applicable terms of such licenses and to
// the extent required by the licenses covering Open Source Components, the terms of such
// licenses will apply in lieu of the terms of this Agreement. To the extent the terms of the
// licenses applicable to Open Source Components prohibit any of the restrictions in this
// License Agreement with respect to such Open Source Component, such restrictions will not
// apply to such Open Source Component. To the extent the terms of the licenses applicable to
// Open Source Components require Licensor to make an offer to provide source code or
// related information in connection with the Software, such offer is hereby made. Any request
// for source code or related information should be directed to cl-face-tracker-distribution@lists.cam.ac.uk
// Licensee acknowledges receipt of notices for the Open Source Components for the initial
// delivery of the Software.
// * Any publications arising from the use of this software, including but
// not limited to academic journal and conference publications, technical
// reports and manuals, must cite at least one of the following works:
//
// OpenFace: an open source facial behavior analysis toolkit
// Tadas Baltrušaitis, Peter Robinson, and Louis-Philippe Morency
// in IEEE Winter Conference on Applications of Computer Vision, 2016
//
// Rendering of Eyes for Eye-Shape Registration and Gaze Estimation
// Erroll Wood, Tadas Baltrušaitis, Xucong Zhang, Yusuke Sugano, Peter Robinson, and Andreas Bulling
// in IEEE International. Conference on Computer Vision (ICCV), 2015
//
// Cross-dataset learning and person-speci?c normalisation for automatic Action Unit detection
// Tadas Baltrušaitis, Marwa Mahmoud, and Peter Robinson
// in Facial Expression Recognition and Analysis Challenge,
// IEEE International Conference on Automatic Face and Gesture Recognition, 2015
//
// Constrained Local Neural Fields for robust facial landmark detection in the wild.
// Tadas Baltrušaitis, Peter Robinson, and Louis-Philippe Morency.
// in IEEE Int. Conference on Computer Vision Workshops, 300 Faces in-the-Wild Challenge, 2013.
//
///////////////////////////////////////////////////////////////////////////////
using System.Windows.Controls;
namespace OpenFaceOffline
{
/// <summary>
/// Interaction logic for BarGraph.xaml
/// </summary>
public partial class BarGraph : UserControl
{
private double targetValue = 0;
public BarGraph()
{
InitializeComponent();
}
public void SetValue(double value)
{
targetValue = 1.5 * value;
if (targetValue > 0)
{
if (targetValue > barContainerPos.ActualHeight)
targetValue = barContainerPos.ActualHeight;
barPos.Height = targetValue;
barNeg.Height = 0;
}
if (targetValue < 0)
{
if (-targetValue > barContainerNeg.ActualHeight)
targetValue = -barContainerNeg.ActualHeight;
barPos.Height = 0;
barNeg.Height = -targetValue;
}
}
}
}

View File

@@ -0,0 +1,14 @@
<UserControl x:Class="OpenFaceOffline.BarGraphHorizontal"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="30" d:DesignWidth="200">
<StackPanel VerticalAlignment="Center" Orientation="Horizontal" HorizontalAlignment="Left" >
<Label Name="Label" FontSize="10" Width="120">AU name</Label>
<Border Name="barContainerPos" Background="PowderBlue" Height="12" DockPanel.Dock="Left" MinWidth="60">
<Rectangle Name="barPos" Fill="CadetBlue" Width="0" HorizontalAlignment="Left"/>
</Border>
</StackPanel>
</UserControl>

View File

@@ -0,0 +1,100 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016, Carnegie Mellon University and University of Cambridge,
// all rights reserved.
//
// THIS SOFTWARE IS PROVIDED “AS IS” FOR ACADEMIC USE ONLY AND ANY EXPRESS
// OR IMPLIED WARRANTIES WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
// BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY.
// OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// Notwithstanding the license granted herein, Licensee acknowledges that certain components
// of the Software may be covered by so-called “open source” software licenses (“Open Source
// Components”), which means any software licenses approved as open source licenses by the
// Open Source Initiative or any substantially similar licenses, including without limitation any
// license that, as a condition of distribution of the software licensed under such license,
// requires that the distributor make the software available in source code format. Licensor shall
// provide a list of Open Source Components for a particular version of the Software upon
// Licensees request. Licensee will comply with the applicable terms of such licenses and to
// the extent required by the licenses covering Open Source Components, the terms of such
// licenses will apply in lieu of the terms of this Agreement. To the extent the terms of the
// licenses applicable to Open Source Components prohibit any of the restrictions in this
// License Agreement with respect to such Open Source Component, such restrictions will not
// apply to such Open Source Component. To the extent the terms of the licenses applicable to
// Open Source Components require Licensor to make an offer to provide source code or
// related information in connection with the Software, such offer is hereby made. Any request
// for source code or related information should be directed to cl-face-tracker-distribution@lists.cam.ac.uk
// Licensee acknowledges receipt of notices for the Open Source Components for the initial
// delivery of the Software.
// * Any publications arising from the use of this software, including but
// not limited to academic journal and conference publications, technical
// reports and manuals, must cite at least one of the following works:
//
// OpenFace: an open source facial behavior analysis toolkit
// Tadas Baltrušaitis, Peter Robinson, and Louis-Philippe Morency
// in IEEE Winter Conference on Applications of Computer Vision, 2016
//
// Rendering of Eyes for Eye-Shape Registration and Gaze Estimation
// Erroll Wood, Tadas Baltrušaitis, Xucong Zhang, Yusuke Sugano, Peter Robinson, and Andreas Bulling
// in IEEE International. Conference on Computer Vision (ICCV), 2015
//
// Cross-dataset learning and person-speci?c normalisation for automatic Action Unit detection
// Tadas Baltrušaitis, Marwa Mahmoud, and Peter Robinson
// in Facial Expression Recognition and Analysis Challenge,
// IEEE International Conference on Automatic Face and Gesture Recognition, 2015
//
// Constrained Local Neural Fields for robust facial landmark detection in the wild.
// Tadas Baltrušaitis, Peter Robinson, and Louis-Philippe Morency.
// in IEEE Int. Conference on Computer Vision Workshops, 300 Faces in-the-Wild Challenge, 2013.
//
///////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace OpenFaceOffline
{
/// <summary>
/// Interaction logic for BarGraphHorizontal.xaml
/// </summary>
public partial class BarGraphHorizontal : UserControl
{
double targetValue = 0;
public BarGraphHorizontal(String label)
{
InitializeComponent();
Label.Content = label;
}
public void SetValue(double value)
{
targetValue = value;
barPos.Width = targetValue * barContainerPos.ActualWidth;
}
public double GetTarget()
{
return targetValue;
}
}
}

View File

@@ -0,0 +1,47 @@
<Window x:Class="OpenFaceOffline.CameraParametersEntry"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="Input camera parameters" Height="180" Width="300" ResizeMode="NoResize">
<Grid Background="WhiteSmoke">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.7*"/>
<ColumnDefinition Width="0.25*"/>
<ColumnDefinition Width="0.25*"/>
<ColumnDefinition Width="0.25*"/>
<ColumnDefinition Width="0.25*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="5" HorizontalAlignment="Left" Text="Enter camera parameters manually:" FontSize="13" VerticalAlignment="Center"/>
<Label Grid.Row="1" Grid.Column="0">Focal lengths</Label>
<Label Grid.Row="1" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center">fx=</Label>
<TextBox Grid.Row="1" Grid.Column="2" VerticalContentAlignment="Center" IsEnabled="False" x:Name="fxTextBox" />
<Label Grid.Row="1" Grid.Column="3" HorizontalAlignment="Right">fy=</Label>
<TextBox Grid.Row="1" Grid.Column="4" VerticalContentAlignment="Center" IsEnabled="False" x:Name="fyTextBox" />
<Label Grid.Row="2" Grid.Column="0">Optical centre lengths</Label>
<Label Grid.Row="2" Grid.Column="1" HorizontalAlignment="Right">cx=</Label>
<TextBox Grid.Row="2" Grid.Column="2" VerticalContentAlignment="Center" IsEnabled="False" x:Name="cxTextBox" />
<Label Grid.Row="2" Grid.Column="3" HorizontalAlignment="Right">cy=</Label>
<TextBox Grid.Row="2" Grid.Column="4" VerticalContentAlignment="Center" IsEnabled="False" x:Name="cyTextBox"/>
<Label Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="5" Name="warningLabel" Visibility="Hidden" FontStyle="Italic" Foreground="Red" HorizontalAlignment="Center">Parameters have to be a non negative reals</Label>
<Label Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="4" FontSize="13">Infer parameters automatically</Label>
<Separator Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="5" VerticalAlignment="Top"></Separator>
<CheckBox Name="automaticCheckBox" Grid.Row="4" Grid.Column="3" HorizontalAlignment="Center" VerticalAlignment="Center" IsChecked="True" Click="CheckBox_Click"></CheckBox>
<Button Grid.Row="5" Grid.Column="5" Content="OK" Click="OKButton_Click" Width="40" VerticalAlignment="Bottom" HorizontalAlignment="Right"/>
</Grid>
</Window>

View File

@@ -0,0 +1,219 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016, Carnegie Mellon University and University of Cambridge,
// all rights reserved.
//
// THIS SOFTWARE IS PROVIDED “AS IS” FOR ACADEMIC USE ONLY AND ANY EXPRESS
// OR IMPLIED WARRANTIES WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
// BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY.
// OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// Notwithstanding the license granted herein, Licensee acknowledges that certain components
// of the Software may be covered by so-called “open source” software licenses (“Open Source
// Components”), which means any software licenses approved as open source licenses by the
// Open Source Initiative or any substantially similar licenses, including without limitation any
// license that, as a condition of distribution of the software licensed under such license,
// requires that the distributor make the software available in source code format. Licensor shall
// provide a list of Open Source Components for a particular version of the Software upon
// Licensees request. Licensee will comply with the applicable terms of such licenses and to
// the extent required by the licenses covering Open Source Components, the terms of such
// licenses will apply in lieu of the terms of this Agreement. To the extent the terms of the
// licenses applicable to Open Source Components prohibit any of the restrictions in this
// License Agreement with respect to such Open Source Component, such restrictions will not
// apply to such Open Source Component. To the extent the terms of the licenses applicable to
// Open Source Components require Licensor to make an offer to provide source code or
// related information in connection with the Software, such offer is hereby made. Any request
// for source code or related information should be directed to cl-face-tracker-distribution@lists.cam.ac.uk
// Licensee acknowledges receipt of notices for the Open Source Components for the initial
// delivery of the Software.
// * Any publications arising from the use of this software, including but
// not limited to academic journal and conference publications, technical
// reports and manuals, must cite at least one of the following works:
//
// OpenFace: an open source facial behavior analysis toolkit
// Tadas Baltrušaitis, Peter Robinson, and Louis-Philippe Morency
// in IEEE Winter Conference on Applications of Computer Vision, 2016
//
// Rendering of Eyes for Eye-Shape Registration and Gaze Estimation
// Erroll Wood, Tadas Baltrušaitis, Xucong Zhang, Yusuke Sugano, Peter Robinson, and Andreas Bulling
// in IEEE International. Conference on Computer Vision (ICCV), 2015
//
// Cross-dataset learning and person-speci?c normalisation for automatic Action Unit detection
// Tadas Baltrušaitis, Marwa Mahmoud, and Peter Robinson
// in Facial Expression Recognition and Analysis Challenge,
// IEEE International Conference on Automatic Face and Gesture Recognition, 2015
//
// Constrained Local Neural Fields for robust facial landmark detection in the wild.
// Tadas Baltrušaitis, Peter Robinson, and Louis-Philippe Morency.
// in IEEE Int. Conference on Computer Vision Workshops, 300 Faces in-the-Wild Challenge, 2013.
//
///////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace OpenFaceOffline
{
/// <summary>
/// Interaction logic for TextEntryWindow.xaml
/// </summary>
public partial class CameraParametersEntry : Window
{
public CameraParametersEntry(float fx, float fy, float cx, float cy)
{
InitializeComponent();
this.KeyDown += new KeyEventHandler(TextEntry_KeyDown);
if(fx == -1 || fy == -1 || cx == -1 || cy == -1)
{
this.fx = 500; this.fy = 500; this.cx = 320; this.cy = 240;
}
else
{
this.fx = fx; this.fy = fy; this.cx = cx; this.cy = cy;
automaticCheckBox.IsChecked = false;
fxTextBox.IsEnabled = true;
fyTextBox.IsEnabled = true;
cxTextBox.IsEnabled = true;
cyTextBox.IsEnabled = true;
}
fxTextBox.Text = this.fx.ToString();
fyTextBox.Text = this.fy.ToString();
cxTextBox.Text = this.cx.ToString();
cyTextBox.Text = this.cy.ToString();
fxTextBox.TextChanged += ResponseTextBox_TextChanged;
fyTextBox.TextChanged += ResponseTextBox_TextChanged;
cxTextBox.TextChanged += ResponseTextBox_TextChanged;
cyTextBox.TextChanged += ResponseTextBox_TextChanged;
}
private void OKButton_Click(object sender, System.Windows.RoutedEventArgs e)
{
DialogResult = true;
}
private void TextEntry_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
DialogResult = true;
}
}
private float fx = -1, fy = -1, cx = -1, cy = -1;
public bool IsAutomatic
{
get { return automaticCheckBox.IsChecked == true; }
}
public float Fx
{
get { return automaticCheckBox.IsChecked == true ? -1 : fx; }
}
public float Fy
{
get { return automaticCheckBox.IsChecked == true ? -1 : fy; }
}
public float Cx
{
get { return automaticCheckBox.IsChecked == true ? -1 : cx; }
}
public float Cy
{
get { return automaticCheckBox.IsChecked == true ? -1 : cy; }
}
private void CheckBox_Click(object sender, RoutedEventArgs e)
{
if(automaticCheckBox.IsChecked == true)
{
fxTextBox.IsEnabled = false;
fyTextBox.IsEnabled = false;
cxTextBox.IsEnabled = false;
cyTextBox.IsEnabled = false;
}
else
{
fxTextBox.IsEnabled = true;
fyTextBox.IsEnabled = true;
cxTextBox.IsEnabled = true;
cyTextBox.IsEnabled = true;
}
}
// Do not allow illegal characters like
private void ResponseTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
try
{
float fx_n = (float)Double.Parse(fxTextBox.Text);
float fy_n = (float)Double.Parse(fyTextBox.Text);
float cx_n = (float)Double.Parse(cxTextBox.Text);
float cy_n = (float)Double.Parse(cyTextBox.Text);
if (fx_n > 0 && fy_n > 0 && cx_n > 0 && cy_n > 0)
{
fx = fx_n;
fy = fy_n;
cx = cx_n;
cy = cy_n;
warningLabel.Visibility = System.Windows.Visibility.Hidden;
}
else
{
warningLabel.Visibility = System.Windows.Visibility.Visible;
fxTextBox.Text = fx.ToString();
fyTextBox.Text = fy.ToString();
cxTextBox.Text = cx.ToString();
cyTextBox.Text = cy.ToString();
fxTextBox.SelectionStart = fxTextBox.Text.Length;
fyTextBox.SelectionStart = fyTextBox.Text.Length;
cxTextBox.SelectionStart = cxTextBox.Text.Length;
cyTextBox.SelectionStart = cyTextBox.Text.Length;
}
}
catch (FormatException except)
{
fxTextBox.Text = fx.ToString();
fyTextBox.Text = fy.ToString();
cxTextBox.Text = cx.ToString();
cyTextBox.Text = cy.ToString();
fxTextBox.SelectionStart = fxTextBox.Text.Length;
fyTextBox.SelectionStart = fyTextBox.Text.Length;
cxTextBox.SelectionStart = cxTextBox.Text.Length;
cyTextBox.SelectionStart = cyTextBox.Text.Length;
warningLabel.Visibility = System.Windows.Visibility.Visible;
}
}
}
}

View File

@@ -0,0 +1,43 @@
<Window x:Class="OpenFaceOffline.CameraSelection"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:OpenFaceOffline"
mc:Ignorable="d"
Title="Camera selection" Height="460" Width="600" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" Closing="Window_Closing">
<Grid>
<Grid Name="camerasPanel" Visibility="Hidden">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="320" />
<RowDefinition Height="*" />
<RowDefinition Height="40" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.ColumnSpan="10" HorizontalContentAlignment="Center" FontSize="20">Choose Video Source</Label>
<Grid Grid.Row="1" Grid.Column="0" Name="ThumbnailPanel" HorizontalAlignment="Center">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="25" />
</Grid.RowDefinitions>
</Grid>
<!-- Click="OpenFile_Click" -->
<Button Width="150" Grid.Row="3" Height="35" Grid.ColumnSpan="10" FontSize="20" Click="Button_Click">Select camera</Button>
</Grid>
<Grid Name="LoadingGrid" Visibility="Visible">
<StackPanel Grid.Row="1" Name="ProgressBar" Margin="20">
<Label HorizontalAlignment="Center" FontSize="18">Loading Webcams</Label>
<ProgressBar Height="20" Minimum="0" Maximum="100" Name="pbStatus" IsIndeterminate="True" />
<Label HorizontalAlignment="Center" FontSize="18">Might take some time the first time</Label>
</StackPanel>
</Grid>
</Grid>
</Window>

View File

@@ -0,0 +1,244 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using CppInterop;
using System.Windows.Threading;
using System.Threading;
namespace OpenFaceOffline
{
/// <summary>
/// Interaction logic for CameraSelection.xaml
/// </summary>
public partial class CameraSelection : Window
{
List<Border> sample_images;
List<ComboBox> combo_boxes;
// id, width, height
public Tuple<int, int, int> selected_camera;
List<List<Tuple<int, int>>> resolutions_all;
int selected_camera_idx = -1;
// indicate if user clicked on camera
public bool camera_selected = false;
public bool no_cameras_found = false;
public List<Tuple<int, String, List<Tuple<int, int>>, OpenCVWrappers.RawImage>> cams;
public void PopulateCameraSelections()
{
this.KeyDown += new KeyEventHandler(CameraSelection_KeyDown);
// Finding the cameras here
if (cams == null)
{
String root = AppDomain.CurrentDomain.BaseDirectory;
//cams = CameraInterop.Capture.GetCameras(root);
cams = UtilitiesOF.SequenceReader.GetCameras(root);
}
int i = 0;
sample_images = new List<Border>();
// Each cameras corresponding resolutions
resolutions_all = new List<List<Tuple<int, int>>>();
combo_boxes = new List<ComboBox>();
foreach (var s in cams)
{
var b = s.Item4.CreateWriteableBitmap();
s.Item4.UpdateWriteableBitmap(b);
b.Freeze();
Dispatcher.Invoke(() =>
{
int idx = i;
Image img = new Image();
img.Source = b;
img.Margin = new Thickness(5);
ColumnDefinition col_def = new ColumnDefinition();
ThumbnailPanel.ColumnDefinitions.Add(col_def);
Border img_border = new Border();
img_border.SetValue(Grid.ColumnProperty, i);
img_border.SetValue(Grid.RowProperty, 0);
img_border.CornerRadius = new CornerRadius(5);
StackPanel img_panel = new StackPanel();
Label camera_name_label = new Label();
camera_name_label.Content = s.Item2;
camera_name_label.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
img_panel.Children.Add(camera_name_label);
img.Height = 200;
img_panel.Children.Add(img);
img_border.Child = img_panel;
sample_images.Add(img_border);
ThumbnailPanel.Children.Add(img_border);
ComboBox resolutions = new ComboBox();
resolutions.Width = 80;
combo_boxes.Add(resolutions);
resolutions_all.Add(new List<Tuple<int, int>>());
foreach (var r in s.Item3)
{
resolutions.Items.Add(r.Item1 + "x" + r.Item2);
resolutions_all[resolutions_all.Count - 1].Add(new Tuple<int, int>(r.Item1, r.Item2));
}
resolutions.SelectedIndex = 0;
for (int res = 0; res < s.Item3.Count; ++res)
{
if (s.Item3[res].Item1 >= 640 && s.Item3[res].Item2 >= 480)
{
resolutions.SelectedIndex = res;
break;
}
}
resolutions.SetValue(Grid.ColumnProperty, i);
resolutions.SetValue(Grid.RowProperty, 2);
ThumbnailPanel.Children.Add(resolutions);
img_panel.MouseDown += (sender, e) =>
{
ChooseCamera(idx);
};
resolutions.DropDownOpened += (sender, e) =>
{
ChooseCamera(idx);
};
});
i++;
}
if (cams.Count > 0)
{
no_cameras_found = false;
Dispatcher.Invoke(DispatcherPriority.Render, new TimeSpan(0, 0, 0, 0, 200), (Action)(() =>
{
ChooseCamera(0);
}));
}
else
{
string messageBoxText = "No cameras detected, please connect a webcam";
string caption = "Camera error!";
MessageBoxButton button = MessageBoxButton.OK;
MessageBoxImage icon = MessageBoxImage.Warning;
MessageBox.Show(messageBoxText, caption, button, icon);
selected_camera_idx = -1;
no_cameras_found = true;
Dispatcher.Invoke(DispatcherPriority.Render, new TimeSpan(0, 0, 0, 0, 200), (Action)(() =>
{
this.Close();
}));
}
}
public CameraSelection()
{
InitializeComponent();
// We want to display the loading screen first
Thread load_cameras = new Thread(LoadCameras);
load_cameras.Start();
}
public void LoadCameras()
{
Thread.CurrentThread.IsBackground = true;
PopulateCameraSelections();
Dispatcher.Invoke(DispatcherPriority.Render, new TimeSpan(0, 0, 0, 0, 200), (Action)(() =>
{
LoadingGrid.Visibility = System.Windows.Visibility.Hidden;
camerasPanel.Visibility = System.Windows.Visibility.Visible;
}));
}
public CameraSelection(List<Tuple<int, String, List<Tuple<int, int>>, OpenCVWrappers.RawImage>> cams)
{
InitializeComponent();
this.cams = cams;
PopulateCameraSelections();
Dispatcher.Invoke(DispatcherPriority.Render, new TimeSpan(0, 0, 0, 0, 200), (Action)(() =>
{
LoadingGrid.Visibility = System.Windows.Visibility.Hidden;
camerasPanel.Visibility = System.Windows.Visibility.Visible;
}));
}
private void ChooseCamera(int idx)
{
selected_camera_idx = idx;
foreach (var img in sample_images)
{
img.BorderThickness = new Thickness(1);
img.BorderBrush = Brushes.Gray;
}
sample_images[idx].BorderThickness = new Thickness(4);
sample_images[idx].BorderBrush = Brushes.Green;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Select();
}
private void CameraSelection_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
Select();
}
}
private void Select()
{
camera_selected = true;
int selected_res = combo_boxes[selected_camera_idx].SelectedIndex;
Tuple<int, int> resolution_selected = resolutions_all[selected_camera_idx][selected_res];
selected_camera = new Tuple<int, int, int>(selected_camera_idx, resolution_selected.Item1, resolution_selected.Item2);
this.Close();
}
// Do not close it as user might want to open it again
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
}
}
}

View File

@@ -0,0 +1,11 @@
<UserControl x:Class="OpenFaceOffline.MultiBarGraph"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="100" d:DesignWidth="300">
<Grid Name="barGrid">
</Grid>
</UserControl>

View File

@@ -0,0 +1,120 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016, Carnegie Mellon University and University of Cambridge,
// all rights reserved.
//
// THIS SOFTWARE IS PROVIDED “AS IS” FOR ACADEMIC USE ONLY AND ANY EXPRESS
// OR IMPLIED WARRANTIES WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
// BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY.
// OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// Notwithstanding the license granted herein, Licensee acknowledges that certain components
// of the Software may be covered by so-called “open source” software licenses (“Open Source
// Components”), which means any software licenses approved as open source licenses by the
// Open Source Initiative or any substantially similar licenses, including without limitation any
// license that, as a condition of distribution of the software licensed under such license,
// requires that the distributor make the software available in source code format. Licensor shall
// provide a list of Open Source Components for a particular version of the Software upon
// Licensees request. Licensee will comply with the applicable terms of such licenses and to
// the extent required by the licenses covering Open Source Components, the terms of such
// licenses will apply in lieu of the terms of this Agreement. To the extent the terms of the
// licenses applicable to Open Source Components prohibit any of the restrictions in this
// License Agreement with respect to such Open Source Component, such restrictions will not
// apply to such Open Source Component. To the extent the terms of the licenses applicable to
// Open Source Components require Licensor to make an offer to provide source code or
// related information in connection with the Software, such offer is hereby made. Any request
// for source code or related information should be directed to cl-face-tracker-distribution@lists.cam.ac.uk
// Licensee acknowledges receipt of notices for the Open Source Components for the initial
// delivery of the Software.
// * Any publications arising from the use of this software, including but
// not limited to academic journal and conference publications, technical
// reports and manuals, must cite at least one of the following works:
//
// OpenFace: an open source facial behavior analysis toolkit
// Tadas Baltrušaitis, Peter Robinson, and Louis-Philippe Morency
// in IEEE Winter Conference on Applications of Computer Vision, 2016
//
// Rendering of Eyes for Eye-Shape Registration and Gaze Estimation
// Erroll Wood, Tadas Baltrušaitis, Xucong Zhang, Yusuke Sugano, Peter Robinson, and Andreas Bulling
// in IEEE International. Conference on Computer Vision (ICCV), 2015
//
// Cross-dataset learning and person-speci?c normalisation for automatic Action Unit detection
// Tadas Baltrušaitis, Marwa Mahmoud, and Peter Robinson
// in Facial Expression Recognition and Analysis Challenge,
// IEEE International Conference on Automatic Face and Gesture Recognition, 2015
//
// Constrained Local Neural Fields for robust facial landmark detection in the wild.
// Tadas Baltrušaitis, Peter Robinson, and Louis-Philippe Morency.
// in IEEE Int. Conference on Computer Vision Workshops, 300 Faces in-the-Wild Challenge, 2013.
//
///////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace OpenFaceOffline
{
/// <summary>
/// Interaction logic for MultiBarGraph.xaml
/// </summary>
public partial class MultiBarGraph : UserControl
{
int num_bars = 0;
List<BarGraph> graphs;
public MultiBarGraph()
{
InitializeComponent();
graphs = new List<BarGraph>();
}
public void Update(List<float> data)
{
// Create new bars if necessary
if (num_bars != data.Count)
{
graphs = new List<BarGraph>();
num_bars = data.Count;
barGrid.Children.Clear();
barGrid.ColumnDefinitions.Clear();
foreach (var value in data)
{
BarGraph newBar = new BarGraph();
newBar.SetValue(value);
graphs.Add(newBar);
barGrid.ColumnDefinitions.Add(new ColumnDefinition());
Grid.SetColumn(newBar, graphs.Count);
barGrid.Children.Add(newBar);
}
}
// Update the bars
for (int i = 0; i < data.Count; ++i)
{
graphs[i].SetValue(data[i]);
}
}
}
}

View File

@@ -0,0 +1,13 @@
<UserControl x:Class="OpenFaceOffline.MultiBarGraphHorz"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid Name="barGrid">
</Grid>
</UserControl>

View File

@@ -0,0 +1,150 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016, Carnegie Mellon University and University of Cambridge,
// all rights reserved.
//
// THIS SOFTWARE IS PROVIDED “AS IS” FOR ACADEMIC USE ONLY AND ANY EXPRESS
// OR IMPLIED WARRANTIES WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
// BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY.
// OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// Notwithstanding the license granted herein, Licensee acknowledges that certain components
// of the Software may be covered by so-called “open source” software licenses (“Open Source
// Components”), which means any software licenses approved as open source licenses by the
// Open Source Initiative or any substantially similar licenses, including without limitation any
// license that, as a condition of distribution of the software licensed under such license,
// requires that the distributor make the software available in source code format. Licensor shall
// provide a list of Open Source Components for a particular version of the Software upon
// Licensees request. Licensee will comply with the applicable terms of such licenses and to
// the extent required by the licenses covering Open Source Components, the terms of such
// licenses will apply in lieu of the terms of this Agreement. To the extent the terms of the
// licenses applicable to Open Source Components prohibit any of the restrictions in this
// License Agreement with respect to such Open Source Component, such restrictions will not
// apply to such Open Source Component. To the extent the terms of the licenses applicable to
// Open Source Components require Licensor to make an offer to provide source code or
// related information in connection with the Software, such offer is hereby made. Any request
// for source code or related information should be directed to cl-face-tracker-distribution@lists.cam.ac.uk
// Licensee acknowledges receipt of notices for the Open Source Components for the initial
// delivery of the Software.
// * Any publications arising from the use of this software, including but
// not limited to academic journal and conference publications, technical
// reports and manuals, must cite at least one of the following works:
//
// OpenFace: an open source facial behavior analysis toolkit
// Tadas Baltrušaitis, Peter Robinson, and Louis-Philippe Morency
// in IEEE Winter Conference on Applications of Computer Vision, 2016
//
// Rendering of Eyes for Eye-Shape Registration and Gaze Estimation
// Erroll Wood, Tadas Baltrušaitis, Xucong Zhang, Yusuke Sugano, Peter Robinson, and Andreas Bulling
// in IEEE International. Conference on Computer Vision (ICCV), 2015
//
// Cross-dataset learning and person-speci?c normalisation for automatic Action Unit detection
// Tadas Baltrušaitis, Marwa Mahmoud, and Peter Robinson
// in Facial Expression Recognition and Analysis Challenge,
// IEEE International Conference on Automatic Face and Gesture Recognition, 2015
//
// Constrained Local Neural Fields for robust facial landmark detection in the wild.
// Tadas Baltrušaitis, Peter Robinson, and Louis-Philippe Morency.
// in IEEE Int. Conference on Computer Vision Workshops, 300 Faces in-the-Wild Challenge, 2013.
//
///////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace OpenFaceOffline
{
/// <summary>
/// Interaction logic for MultiBarGraphHorz.xaml
/// </summary>
public partial class MultiBarGraphHorz : UserControl
{
int num_bars = 0;
Dictionary<String, BarGraphHorizontal> graphs;
// Name mapping
Dictionary<String, String> mapping;
public MultiBarGraphHorz()
{
InitializeComponent();
graphs = new Dictionary<string, BarGraphHorizontal>();
mapping = new Dictionary<string, string>();
mapping["AU01"] = "Inner Brow raiser";
mapping["AU02"] = "Outer Brow raiser";
mapping["AU04"] = "Brow lowerer";
mapping["AU05"] = "Upper lid raiser";
mapping["AU06"] = "Cheek raiser";
mapping["AU07"] = "Lid tightener";
mapping["AU09"] = "Nose wrinkler";
mapping["AU10"] = "Upper lip raiser";
mapping["AU12"] = "Lip corner puller (smile)";
mapping["AU14"] = "Dimpler";
mapping["AU15"] = "Lip corner depressor";
mapping["AU17"] = "Chin Raiser";
mapping["AU20"] = "Lip Stretcher";
mapping["AU23"] = "Lip tightener";
mapping["AU25"] = "Lips part";
mapping["AU26"] = "Jaw drop";
mapping["AU28"] = "Lip suck";
mapping["AU45"] = "Blink";
}
public void Update(Dictionary<String, double> data)
{
// Create new bars if necessary
if (num_bars != data.Count)
{
num_bars = data.Count;
barGrid.Children.Clear();
barGrid.RowDefinitions.Clear();
graphs.Clear();
// Make sure AUs are sorted
var data_labels = data.Keys.ToList();
data_labels.Sort();
foreach (var label in data_labels)
{
BarGraphHorizontal newBar = new BarGraphHorizontal(label + " - " + mapping[label]);
newBar.SetValue(data[label]);
barGrid.RowDefinitions.Add(new RowDefinition());
Grid.SetRow(newBar, graphs.Count);
graphs.Add(label, newBar);
barGrid.Children.Add(newBar);
}
}
// Update the bars
foreach (var value in data)
{
graphs[value.Key].SetValue(value.Value);
}
}
}
}

View File

@@ -0,0 +1,20 @@
<Window x:Class="OpenFaceOffline.NumberEntryWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="Output image size" Height="110" Width="250" ResizeMode="NoResize">
<Grid Background="WhiteSmoke">
<StackPanel>
<StackPanel FocusManager.FocusedElement="{Binding ElementName=ResponseTextBox}" Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock HorizontalAlignment="Center" Text="Output image size:" FontSize="12" VerticalAlignment="Center" Margin="0,0,10,0"/>
<TextBox Margin="0,4,0,0" x:Name="ResponseTextBox_x" FontSize="12" Width="50" TextChanged="ResponseTextBox_TextChanged" />
<Label>x</Label>
<TextBox Margin="0,4,0,0" x:Name="ResponseTextBox_y" FontSize="12" Width="50" TextChanged="ResponseTextBox_TextChanged" IsEnabled="False" />
</StackPanel>
<Label Name="warningLabel" Visibility="Hidden" FontStyle="Italic" Foreground="Red" HorizontalAlignment="Center" VerticalAlignment="Center">Has to be a non negative integer</Label>
<Button Content="OK" Click="OKButton_Click" Width="50" VerticalAlignment="Bottom" HorizontalAlignment="Right"/>
</StackPanel>
</Grid>
</Window>

View File

@@ -0,0 +1,149 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016, Carnegie Mellon University and University of Cambridge,
// all rights reserved.
//
// THIS SOFTWARE IS PROVIDED “AS IS” FOR ACADEMIC USE ONLY AND ANY EXPRESS
// OR IMPLIED WARRANTIES WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
// BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY.
// OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// Notwithstanding the license granted herein, Licensee acknowledges that certain components
// of the Software may be covered by so-called “open source” software licenses (“Open Source
// Components”), which means any software licenses approved as open source licenses by the
// Open Source Initiative or any substantially similar licenses, including without limitation any
// license that, as a condition of distribution of the software licensed under such license,
// requires that the distributor make the software available in source code format. Licensor shall
// provide a list of Open Source Components for a particular version of the Software upon
// Licensees request. Licensee will comply with the applicable terms of such licenses and to
// the extent required by the licenses covering Open Source Components, the terms of such
// licenses will apply in lieu of the terms of this Agreement. To the extent the terms of the
// licenses applicable to Open Source Components prohibit any of the restrictions in this
// License Agreement with respect to such Open Source Component, such restrictions will not
// apply to such Open Source Component. To the extent the terms of the licenses applicable to
// Open Source Components require Licensor to make an offer to provide source code or
// related information in connection with the Software, such offer is hereby made. Any request
// for source code or related information should be directed to cl-face-tracker-distribution@lists.cam.ac.uk
// Licensee acknowledges receipt of notices for the Open Source Components for the initial
// delivery of the Software.
// * Any publications arising from the use of this software, including but
// not limited to academic journal and conference publications, technical
// reports and manuals, must cite at least one of the following works:
//
// OpenFace: an open source facial behavior analysis toolkit
// Tadas Baltrušaitis, Peter Robinson, and Louis-Philippe Morency
// in IEEE Winter Conference on Applications of Computer Vision, 2016
//
// Rendering of Eyes for Eye-Shape Registration and Gaze Estimation
// Erroll Wood, Tadas Baltrušaitis, Xucong Zhang, Yusuke Sugano, Peter Robinson, and Andreas Bulling
// in IEEE International. Conference on Computer Vision (ICCV), 2015
//
// Cross-dataset learning and person-speci?c normalisation for automatic Action Unit detection
// Tadas Baltrušaitis, Marwa Mahmoud, and Peter Robinson
// in Facial Expression Recognition and Analysis Challenge,
// IEEE International Conference on Automatic Face and Gesture Recognition, 2015
//
// Constrained Local Neural Fields for robust facial landmark detection in the wild.
// Tadas Baltrušaitis, Peter Robinson, and Louis-Philippe Morency.
// in IEEE Int. Conference on Computer Vision Workshops, 300 Faces in-the-Wild Challenge, 2013.
//
///////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace OpenFaceOffline
{
/// <summary>
/// Interaction logic for TextEntryWindow.xaml
/// </summary>
public partial class NumberEntryWindow : Window
{
public NumberEntryWindow(int initValue)
{
InitializeComponent();
ResponseTextBox_x.Text = initValue.ToString();
ResponseTextBox_y.Text = initValue.ToString();
OutputInt = initValue;
this.KeyDown += new KeyEventHandler(TextEntry_KeyDown);
}
//private string ResponseText_x
//{
// get { return ResponseTextBox_x.Text; }
// set { ResponseTextBox_x.Text = value; }
//}
//private string ResponseText_y
//{
// get { return ResponseTextBox_y.Text; }
// set { ResponseTextBox_y.Text = value; }
//}
public int OutputInt;
private void OKButton_Click(object sender, System.Windows.RoutedEventArgs e)
{
DialogResult = true;
}
private void TextEntry_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
DialogResult = true;
}
}
// Do not allow illegal characters like
private void ResponseTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
try
{
int OutputIntNew = Int32.Parse(ResponseTextBox_x.Text);
if(OutputIntNew > 0)
{
OutputInt = OutputIntNew;
warningLabel.Visibility = System.Windows.Visibility.Hidden;
}
else
{
warningLabel.Visibility = System.Windows.Visibility.Visible;
ResponseTextBox_x.Text = OutputInt.ToString();
ResponseTextBox_x.SelectionStart = ResponseTextBox_x.Text.Length;
}
}
catch (FormatException except)
{
ResponseTextBox_x.Text = OutputInt.ToString();
ResponseTextBox_x.SelectionStart = ResponseTextBox_x.Text.Length;
warningLabel.Visibility = System.Windows.Visibility.Visible;
}
ResponseTextBox_y.Text = OutputInt.ToString();
}
}
}

View File

@@ -0,0 +1,8 @@
<Image x:Class="OpenFaceOffline.OverlayImage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300" >
</Image>

View File

@@ -0,0 +1,256 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016, Carnegie Mellon University and University of Cambridge,
// all rights reserved.
//
// THIS SOFTWARE IS PROVIDED “AS IS” FOR ACADEMIC USE ONLY AND ANY EXPRESS
// OR IMPLIED WARRANTIES WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
// BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY.
// OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// Notwithstanding the license granted herein, Licensee acknowledges that certain components
// of the Software may be covered by so-called “open source” software licenses (“Open Source
// Components”), which means any software licenses approved as open source licenses by the
// Open Source Initiative or any substantially similar licenses, including without limitation any
// license that, as a condition of distribution of the software licensed under such license,
// requires that the distributor make the software available in source code format. Licensor shall
// provide a list of Open Source Components for a particular version of the Software upon
// Licensees request. Licensee will comply with the applicable terms of such licenses and to
// the extent required by the licenses covering Open Source Components, the terms of such
// licenses will apply in lieu of the terms of this Agreement. To the extent the terms of the
// licenses applicable to Open Source Components prohibit any of the restrictions in this
// License Agreement with respect to such Open Source Component, such restrictions will not
// apply to such Open Source Component. To the extent the terms of the licenses applicable to
// Open Source Components require Licensor to make an offer to provide source code or
// related information in connection with the Software, such offer is hereby made. Any request
// for source code or related information should be directed to cl-face-tracker-distribution@lists.cam.ac.uk
// Licensee acknowledges receipt of notices for the Open Source Components for the initial
// delivery of the Software.
// * Any publications arising from the use of this software, including but
// not limited to academic journal and conference publications, technical
// reports and manuals, must cite at least one of the following works:
//
// OpenFace: an open source facial behavior analysis toolkit
// Tadas Baltrušaitis, Peter Robinson, and Louis-Philippe Morency
// in IEEE Winter Conference on Applications of Computer Vision, 2016
//
// Rendering of Eyes for Eye-Shape Registration and Gaze Estimation
// Erroll Wood, Tadas Baltrušaitis, Xucong Zhang, Yusuke Sugano, Peter Robinson, and Andreas Bulling
// in IEEE International. Conference on Computer Vision (ICCV), 2015
//
// Cross-dataset learning and person-speci?c normalisation for automatic Action Unit detection
// Tadas Baltrušaitis, Marwa Mahmoud, and Peter Robinson
// in Facial Expression Recognition and Analysis Challenge,
// IEEE International Conference on Automatic Face and Gesture Recognition, 2015
//
// Constrained Local Neural Fields for robust facial landmark detection in the wild.
// Tadas Baltrušaitis, Peter Robinson, and Louis-Philippe Morency.
// in IEEE Int. Conference on Computer Vision Workshops, 300 Faces in-the-Wild Challenge, 2013.
//
///////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace OpenFaceOffline
{
/// <summary>
/// Interaction logic for OverlayImage.xaml
/// </summary>
public partial class OverlayImage : Image
{
public OverlayImage()
{
InitializeComponent();
OverlayLines = new List<List<Tuple<Point, Point>>>();
OverlayPoints = new List<List<Point>>();
OverlayPointsVisibility = new List<List<bool>>();
OverlayEyePoints = new List<List<Point>>();
GazeLines = new List<List<Tuple<Point, Point>>>();
Confidence = new List<double>();
FaceScale = new List<double>();
Progress = -1;
}
public void Clear()
{
OverlayLines.Clear();
OverlayPoints.Clear();
OverlayPointsVisibility.Clear();
OverlayEyePoints.Clear();
GazeLines.Clear();
Confidence.Clear();
FaceScale.Clear();
}
protected override void OnRender(DrawingContext dc)
{
base.OnRender(dc);
if (OverlayLines == null)
OverlayLines = new List<List<Tuple<Point, Point>>>();
if (OverlayPoints == null)
OverlayPoints = new List<List<Point>>();
if (OverlayPointsVisibility == null)
OverlayPointsVisibility = new List<List<bool>>();
if (OverlayEyePoints == null)
OverlayEyePoints = new List<List<Point>>();
if (Source == null || !(Source is WriteableBitmap))
return;
var width = ((WriteableBitmap)Source).PixelWidth;
var height = ((WriteableBitmap)Source).PixelHeight;
// Go over all faces
for (int i = 0; i < OverlayPoints.Count; i++)
{
// The point and line size should be proportional to the face size and the image scaling
double scaling_p = 0.88 * FaceScale[i] * ActualWidth / width;
// Low confidence leads to more transparent visualization
double confidence = Confidence[i];
if (confidence < 0.4)
{
confidence = 0.4;
}
// Don't let it get too small
if (scaling_p < 0.6)
scaling_p = 0.6;
foreach (var line in OverlayLines[i])
{
var p1 = new Point(ActualWidth * line.Item1.X / width, ActualHeight * line.Item1.Y / height);
var p2 = new Point(ActualWidth * line.Item2.X / width, ActualHeight * line.Item2.Y / height);
dc.DrawLine(new Pen(new SolidColorBrush(Color.FromArgb(200, (byte)(100 + (155 * (1 - confidence))), (byte)(100 + (155 * confidence)), 100)), 2.0 * scaling_p), p1, p2);
}
foreach (var line in GazeLines[i])
{
var p1 = new Point(ActualWidth * line.Item1.X / width, ActualHeight * line.Item1.Y / height);
var p2 = new Point(ActualWidth * line.Item2.X / width, ActualHeight * line.Item2.Y / height);
var dir = p2 - p1;
p2 = p1 + dir * scaling_p * 2;
dc.DrawLine(new Pen(new SolidColorBrush(Color.FromArgb(200, (byte)(240), (byte)(30), (byte)100)), 5.0 * scaling_p), p1, p2);
}
for (int j = 0; j < OverlayPoints[i].Count; j++)
{
var p = OverlayPoints[i][j];
var q = new Point(ActualWidth * p.X / width, ActualHeight * p.Y / height);
if(OverlayPointsVisibility[i].Count == 0 || OverlayPointsVisibility[i][j])
{
dc.DrawEllipse(new SolidColorBrush(Color.FromArgb((byte)(230 * confidence), 255, 50, 50)), null, q, 2.75 * scaling_p, 3.0 * scaling_p);
dc.DrawEllipse(new SolidColorBrush(Color.FromArgb((byte)(230 * confidence), 255, 255, 100)), null, q, 1.75 * scaling_p, 2.0 * scaling_p);
}
else
{
// Draw fainter if landmark not visible
dc.DrawEllipse(new SolidColorBrush(Color.FromArgb((byte)(125 * confidence), 255, 50, 50)), null, q, 2.75 * scaling_p, 3.0 * scaling_p);
dc.DrawEllipse(new SolidColorBrush(Color.FromArgb((byte)(125 * confidence), 255, 255, 100)), null, q, 1.75 * scaling_p, 2.0 * scaling_p);
}
}
for (int id = 0; id < OverlayEyePoints[i].Count; id++)
{
var q1 = new Point(ActualWidth * OverlayEyePoints[i][id].X / width, ActualHeight * OverlayEyePoints[i][id].Y / height);
// The the eye points can be defined for multiple faces, turn id's to be relevant to one face
int next_point = id + 1;
if (id == 7) next_point = 0;
if (id == 19) next_point = 8;
if (id == 27) next_point = 20;
if (id == 35) next_point = 28;
if (id == 47) next_point = 36;
if (id == 55) next_point = 48;
var q2 = new Point(ActualWidth * OverlayEyePoints[i][next_point].X / width, ActualHeight * OverlayEyePoints[i][next_point].Y / height);
if (id < 28 && (id < 8 || id > 19) || (id >= 28 &&(id - 28<8 || id - 28 >19)))
{
dc.DrawLine(new Pen(new SolidColorBrush(Color.FromArgb(200, (byte)(240), (byte)(30), (byte)100)), 1.5 * scaling_p), q1, q2);
}
else
{
dc.DrawLine(new Pen(new SolidColorBrush(Color.FromArgb(200, (byte)(100), (byte)(30), (byte)240)), 2.5 * scaling_p), q1, q2);
}
}
}
// Only display the confidence of the last face
double scaling = ActualWidth / 400.0;
int confidence_width = (int)(107.0 * scaling);
int confidence_height = (int)(18.0 * scaling);
int final_id = Confidence.Count - 1;
Brush conf_brush = new SolidColorBrush(Color.FromRgb((byte)((1 - Confidence[final_id]) * 255), (byte)(Confidence[final_id] * 255), (byte)40));
dc.DrawRoundedRectangle(conf_brush, new Pen(Brushes.Black, 0.5 * scaling), new Rect(ActualWidth - confidence_width - 1, 0, confidence_width, confidence_height), 3.0 * scaling, 3.0 * scaling);
FormattedText txt = new FormattedText("Confidence: " + (int)(100 * Confidence[final_id]) + "%", System.Globalization.CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, new Typeface("Verdana"), 12.0 * scaling, Brushes.Black);
dc.DrawText(txt, new Point(ActualWidth - confidence_width + 2, 2));
int fps_width = (int)(52.0 * scaling);
int fps_height = (int)(18.0 * scaling);
dc.DrawRoundedRectangle(Brushes.WhiteSmoke, new Pen(Brushes.Black, 0.5 * scaling), new Rect(0, 0, fps_width, fps_height), 3.0 * scaling, 3.0 * scaling);
FormattedText fps_txt = new FormattedText("FPS: " + (int)FPS, System.Globalization.CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, new Typeface("Verdana"), 12.0 * scaling, Brushes.Black);
dc.DrawText(fps_txt, new Point(2.0 * scaling, 0));
old_width = width;
old_height = height;
// Drawing a progress bar at the bottom of the image
if (Progress > 0)
{
int progress_bar_height = (int)(6.0 * scaling);
dc.DrawRectangle(Brushes.GreenYellow, new Pen(Brushes.Black, 0.5 * scaling), new Rect(0, ActualHeight - progress_bar_height, Progress * ActualWidth, progress_bar_height));
}
}
// To allow for visualizing multiple faces use a List of Lists
public List<List<Tuple<Point, Point>>> OverlayLines { get; set; }
public List<List<Tuple<Point, Point>>> GazeLines { get; set; }
public List<List<Point>> OverlayPoints { get; set; }
public List<List<bool>> OverlayPointsVisibility { get; set; }
public List<List<Point>> OverlayEyePoints { get; set; }
public List<double> FaceScale { get; set; }
public List<double> Confidence { get; set; }
public double FPS { get; set; }
// 0 to 1 indicates how much video has been processed so far
public double Progress { get; set; }
int old_width;
int old_height;
}
}

View File

@@ -0,0 +1,8 @@
<Image x:Class="OpenFaceOffline.SimpleImage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300" >
</Image>

View File

@@ -0,0 +1,94 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016, Carnegie Mellon University and University of Cambridge,
// all rights reserved.
//
// THIS SOFTWARE IS PROVIDED “AS IS” FOR ACADEMIC USE ONLY AND ANY EXPRESS
// OR IMPLIED WARRANTIES WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
// BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY.
// OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// Notwithstanding the license granted herein, Licensee acknowledges that certain components
// of the Software may be covered by so-called “open source” software licenses (“Open Source
// Components”), which means any software licenses approved as open source licenses by the
// Open Source Initiative or any substantially similar licenses, including without limitation any
// license that, as a condition of distribution of the software licensed under such license,
// requires that the distributor make the software available in source code format. Licensor shall
// provide a list of Open Source Components for a particular version of the Software upon
// Licensees request. Licensee will comply with the applicable terms of such licenses and to
// the extent required by the licenses covering Open Source Components, the terms of such
// licenses will apply in lieu of the terms of this Agreement. To the extent the terms of the
// licenses applicable to Open Source Components prohibit any of the restrictions in this
// License Agreement with respect to such Open Source Component, such restrictions will not
// apply to such Open Source Component. To the extent the terms of the licenses applicable to
// Open Source Components require Licensor to make an offer to provide source code or
// related information in connection with the Software, such offer is hereby made. Any request
// for source code or related information should be directed to cl-face-tracker-distribution@lists.cam.ac.uk
// Licensee acknowledges receipt of notices for the Open Source Components for the initial
// delivery of the Software.
// * Any publications arising from the use of this software, including but
// not limited to academic journal and conference publications, technical
// reports and manuals, must cite at least one of the following works:
//
// OpenFace: an open source facial behavior analysis toolkit
// Tadas Baltrušaitis, Peter Robinson, and Louis-Philippe Morency
// in IEEE Winter Conference on Applications of Computer Vision, 2016
//
// Rendering of Eyes for Eye-Shape Registration and Gaze Estimation
// Erroll Wood, Tadas Baltrušaitis, Xucong Zhang, Yusuke Sugano, Peter Robinson, and Andreas Bulling
// in IEEE International. Conference on Computer Vision (ICCV), 2015
//
// Cross-dataset learning and person-speci?c normalisation for automatic Action Unit detection
// Tadas Baltrušaitis, Marwa Mahmoud, and Peter Robinson
// in Facial Expression Recognition and Analysis Challenge,
// IEEE International Conference on Automatic Face and Gesture Recognition, 2015
//
// Constrained Local Neural Fields for robust facial landmark detection in the wild.
// Tadas Baltrušaitis, Peter Robinson, and Louis-Philippe Morency.
// in IEEE Int. Conference on Computer Vision Workshops, 300 Faces in-the-Wild Challenge, 2013.
//
///////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace OpenFaceOffline
{
/// <summary>
/// Interaction logic for OverlayImage.xaml
/// </summary>
public partial class SimpleImage : Image
{
public SimpleImage()
{
InitializeComponent();
}
protected override void OnRender(DrawingContext dc)
{
base.OnRender(dc);
if (Source == null || !(Source is WriteableBitmap))
return;
}
}
}