Fix VideoFrameAnalysis project (#5)

* Fix VideoFrameAnalysis project

* Accept endpoint name, to accomodate new regions
* Update package dependencies
* Tidy up trailing whitespace

* Fix Vision API host label
This commit is contained in:
Chris Thrasher 2017-06-07 10:25:39 -07:00 committed by GitHub
parent 0aad9934ba
commit 6a5b59d1af
12 changed files with 166 additions and 84 deletions

View file

@ -36,8 +36,12 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.ProjectOxford.Face, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ProjectOxford.Face.1.1.0\lib\portable-net45+wp80+win8+wpa81+aspnetcore50\Microsoft.ProjectOxford.Face.dll</HintPath>
<Reference Include="Microsoft.ProjectOxford.Common, Version=1.0.324.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ProjectOxford.Common.1.0.324\lib\portable-net45+win+wpa81+wp80+MonoAndroid10+xamarinios10+MonoTouch10\Microsoft.ProjectOxford.Common.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.ProjectOxford.Face, Version=1.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ProjectOxford.Face.1.3.0\lib\portable-net45+wp80+win8+wpa81+aspnetcore50\Microsoft.ProjectOxford.Face.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
@ -64,6 +68,15 @@
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http.Extensions, Version=2.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Net.Http.Primitives, Version=4.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
@ -94,6 +107,11 @@
</PropertyGroup>
<Error Condition="!Exists('..\packages\OpenCvSharp3-AnyCPU.3.1.0.20160622\build\OpenCvSharp3-AnyCPU.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\OpenCvSharp3-AnyCPU.3.1.0.20160622\build\OpenCvSharp3-AnyCPU.props'))" />
</Target>
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
<Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">

View file

@ -1,6 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.ProjectOxford.Face" version="1.1.0" targetFramework="net452" />
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net452" />
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net452" />
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net452" />
<package id="Microsoft.ProjectOxford.Common" version="1.0.324" targetFramework="net452" />
<package id="Microsoft.ProjectOxford.Face" version="1.3.0" targetFramework="net452" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
<package id="OpenCvSharp3-AnyCPU" version="3.1.0.20160622" targetFramework="net452" />
</packages>

View file

@ -31,34 +31,22 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using Microsoft.ProjectOxford.Emotion.Contract;
using System.Linq;
using Microsoft.ProjectOxford.Face.Contract;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.ProjectOxford.Emotion.Contract;
using Microsoft.ProjectOxford.Face.Contract;
namespace LiveCameraSample
{
internal class Aggregation
{
public static Tuple<string, float> GetDominantEmotion(Scores scores)
public static Tuple<string, float> GetDominantEmotion(Microsoft.ProjectOxford.Common.Contract.EmotionScores scores)
{
float maxScore = 0;
string dominant = "";
if (scores.Anger > maxScore) { maxScore = scores.Anger; dominant = "Anger"; }
if (scores.Contempt > maxScore) { maxScore = scores.Contempt; dominant = "Contempt"; }
if (scores.Disgust > maxScore) { maxScore = scores.Disgust; dominant = "Disgust"; }
if (scores.Fear > maxScore) { maxScore = scores.Fear; dominant = "Fear"; }
if (scores.Happiness > maxScore) { maxScore = scores.Happiness; dominant = "Happiness"; }
if (scores.Neutral > maxScore) { maxScore = scores.Neutral; dominant = "Neutral"; }
if (scores.Sadness > maxScore) { maxScore = scores.Sadness; dominant = "Sadness"; }
if (scores.Surprise > maxScore) { maxScore = scores.Surprise; dominant = "Surprise"; }
return new Tuple<string, float>(dominant, maxScore);
return scores.ToRankedList().Select(kv => new Tuple<string, float>(kv.Key, kv.Value)).First();
}
public static string SummarizeEmotion(Scores scores)
public static string SummarizeEmotion(Microsoft.ProjectOxford.Common.Contract.EmotionScores scores)
{
var bestEmotion = Aggregation.GetDominantEmotion(scores);
return string.Format("{0}: {1:N1}", bestEmotion.Item1, bestEmotion.Item2);

View file

@ -31,19 +31,13 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LiveCameraSample
{
// Class to hold all possible result types.
public class LiveCameraResult
{
public Microsoft.ProjectOxford.Face.Contract.Face[] Faces { get; set; } = null;
public Microsoft.ProjectOxford.Emotion.Contract.Scores[] EmotionScores { get; set; } = null;
public Microsoft.ProjectOxford.Common.Contract.EmotionScores[] EmotionScores { get; set; } = null;
public string[] CelebrityNames { get; set; } = null;
public Microsoft.ProjectOxford.Vision.Contract.Tag[] Tags { get; set; } = null;
}

View file

@ -38,20 +38,20 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.ProjectOxford.Common, Version=1.0.308.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ProjectOxford.Common.1.0.308\lib\portable-net45+win+wpa81+wp80+MonoAndroid10+xamarinios10+MonoTouch10\Microsoft.ProjectOxford.Common.dll</HintPath>
<Reference Include="Microsoft.ProjectOxford.Common, Version=1.0.324.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ProjectOxford.Common.1.0.324\lib\portable-net45+win+wpa81+wp80+MonoAndroid10+xamarinios10+MonoTouch10\Microsoft.ProjectOxford.Common.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.ProjectOxford.Emotion, Version=1.0.310.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ProjectOxford.Emotion.1.0.310\lib\portable-net45+win+wpa81+wp80+MonoAndroid10+xamarinios10+MonoTouch10\Microsoft.ProjectOxford.Emotion.dll</HintPath>
<Reference Include="Microsoft.ProjectOxford.Emotion, Version=1.0.336.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ProjectOxford.Emotion.1.0.336\lib\portable-net45+win+wpa81+wp80+MonoAndroid10+xamarinios10+MonoTouch10\Microsoft.ProjectOxford.Emotion.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.ProjectOxford.Face, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ProjectOxford.Face.1.1.0\lib\portable-net45+wp80+win8+wpa81+aspnetcore50\Microsoft.ProjectOxford.Face.dll</HintPath>
<Reference Include="Microsoft.ProjectOxford.Face, Version=1.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ProjectOxford.Face.1.3.0\lib\portable-net45+wp80+win8+wpa81+aspnetcore50\Microsoft.ProjectOxford.Face.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.ProjectOxford.Vision, Version=1.0.354.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ProjectOxford.Vision.1.0.354\lib\portable-net45+win+wpa81+wp80+MonoAndroid10+xamarinios10+MonoTouch10\Microsoft.ProjectOxford.Vision.dll</HintPath>
<Reference Include="Microsoft.ProjectOxford.Vision, Version=1.0.393.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.ProjectOxford.Vision.1.0.393\lib\portable-net45+win+wpa81+wp80+MonoAndroid10+xamarinios10+MonoTouch10\Microsoft.ProjectOxford.Vision.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
@ -108,6 +108,7 @@
<Compile Include="Aggregation.cs" />
<Compile Include="CelebritiesResult.cs" />
<Compile Include="LiveCameraResult.cs" />
<Compile Include="Settings.cs" />
<Compile Include="Visualization.cs" />
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>

View file

@ -41,17 +41,26 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Margin="5" Grid.Row="0" Grid.Column="0" Text="Face API Key:" />
<TextBox Margin="5" Grid.Row="0" Grid.Column="1" Text="{Binding Source={StaticResource Settings}, Path=Default.FaceAPIKey, Mode=TwoWay}" />
<TextBlock Margin="5" Grid.Row="1" Grid.Column="0" Text="Emotion API Key:" />
<TextBox Margin="5" Grid.Row="1" Grid.Column="1" Text="{Binding Source={StaticResource Settings}, Path=Default.EmotionAPIKey, Mode=TwoWay}" />
<TextBlock Margin="5" Grid.Row="2" Grid.Column="0" Text="Vision API Key:" />
<TextBox Margin="5" Grid.Row="2" Grid.Column="1" Text="{Binding Source={StaticResource Settings}, Path=Default.VisionAPIKey, Mode=TwoWay}" />
<TextBlock Margin="5" Grid.Row="3" Grid.ColumnSpan="2" TextWrapping="Wrap"><Run Text="Get API keys at "/><Hyperlink NavigateUri="http://www.microsoft.com/cognitive" RequestNavigate="Hyperlink_RequestNavigate"><Run Text="microsoft.com/cognitive"/></Hyperlink></TextBlock>
<TextBlock Margin="5" Grid.Row="4" Grid.Column="0" Text="API Call Interval:" />
<TextBox Margin="5" Grid.Row="4" Grid.Column="1" Text="{Binding Source={StaticResource Settings}, Path=Default.AnalysisInterval, Mode=TwoWay}" />
<TextBlock Margin="5" Grid.Row="5" Grid.ColumnSpan="2" TextWrapping="Wrap"><Run FontWeight="Bold" Text="Caution"/><Run Text=": Each video frame submitted to an API will count towards your transaction limit."/></TextBlock>
<TextBlock Margin="5" Grid.Row="1" Grid.Column="0" Text="Face API Host:" />
<TextBox Margin="5" Grid.Row="1" Grid.Column="1" Text="{Binding Source={StaticResource Settings}, Path=Default.FaceAPIHost, Mode=TwoWay}" />
<TextBlock Margin="5" Grid.Row="2" Grid.Column="0" Text="Emotion API Key:" />
<TextBox Margin="5" Grid.Row="2" Grid.Column="1" Text="{Binding Source={StaticResource Settings}, Path=Default.EmotionAPIKey, Mode=TwoWay}" />
<TextBlock Margin="5" Grid.Row="3" Grid.Column="0" Text="Emotion API Host:" />
<TextBox Margin="5" Grid.Row="3" Grid.Column="1" Text="{Binding Source={StaticResource Settings}, Path=Default.EmotionAPIHost, Mode=TwoWay}" />
<TextBlock Margin="5" Grid.Row="4" Grid.Column="0" Text="Vision API Key:" />
<TextBox Margin="5" Grid.Row="4" Grid.Column="1" Text="{Binding Source={StaticResource Settings}, Path=Default.VisionAPIKey, Mode=TwoWay}" />
<TextBlock Margin="5" Grid.Row="5" Grid.Column="0" Text="Vision API Host:" />
<TextBox Margin="5" Grid.Row="5" Grid.Column="1" Text="{Binding Source={StaticResource Settings}, Path=Default.VisionAPIHost, Mode=TwoWay}" />
<TextBlock Margin="5" Grid.Row="6" Grid.ColumnSpan="2" TextWrapping="Wrap"><Run Text="Get API keys at "/><Hyperlink NavigateUri="http://www.microsoft.com/cognitive" RequestNavigate="Hyperlink_RequestNavigate"><Run Text="microsoft.com/cognitive"/></Hyperlink></TextBlock>
<TextBlock Margin="5" Grid.Row="7" Grid.Column="0" Text="API Call Interval:" />
<TextBox Margin="5" Grid.Row="7" Grid.Column="1" Text="{Binding Source={StaticResource Settings}, Path=Default.AnalysisInterval, Mode=TwoWay}" />
<TextBlock Margin="5" Grid.Row="8" Grid.ColumnSpan="2" TextWrapping="Wrap"><Run FontWeight="Bold" Text="Caution"/><Run Text=": Each video frame submitted to an API will count towards your transaction limit."/></TextBlock>
</Grid>
<TextBlock Margin="5,0,5,5">
<Run Text="Face API calls made = "/><Run Text="{Binding Source={StaticResource Settings}, Path=Default.FaceAPICallCount}"/><LineBreak />

View file

@ -31,29 +31,23 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
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;
using System.Diagnostics;
using Newtonsoft.Json;
using OpenCvSharp;
using OpenCvSharp.Extensions;
using Microsoft.ProjectOxford.Emotion;
using Microsoft.ProjectOxford.Emotion.Contract;
using Microsoft.ProjectOxford.Face;
using Microsoft.ProjectOxford.Face.Contract;
using Microsoft.ProjectOxford.Vision;
using Newtonsoft.Json;
using OpenCvSharp;
using OpenCvSharp.Extensions;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using VideoFrameAnalyzer;
namespace LiveCameraSample
@ -386,9 +380,9 @@ namespace LiveCameraSample
Properties.Settings.Default.VisionAPIKey = Properties.Settings.Default.VisionAPIKey.Trim();
// Create API clients.
_faceClient = new FaceServiceClient(Properties.Settings.Default.FaceAPIKey);
_emotionClient = new EmotionServiceClient(Properties.Settings.Default.EmotionAPIKey);
_visionClient = new VisionServiceClient(Properties.Settings.Default.VisionAPIKey);
_faceClient = new FaceServiceClient(Properties.Settings.Default.FaceAPIKey, Properties.Settings.Default.FaceAPIHost);
_emotionClient = new EmotionServiceClient(Properties.Settings.Default.EmotionAPIKey, Properties.Settings.Default.EmotionAPIHost);
_visionClient = new VisionServiceClient(Properties.Settings.Default.VisionAPIKey, Properties.Settings.Default.VisionAPIHost);
// How often to analyze.
_grabber.TriggerAnalysisOnInterval(Properties.Settings.Default.AnalysisInterval);

View file

@ -9,8 +9,8 @@
//------------------------------------------------------------------------------
namespace LiveCameraSample.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
@ -22,7 +22,7 @@ namespace LiveCameraSample.Properties {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
@ -34,7 +34,7 @@ namespace LiveCameraSample.Properties {
this["FaceAPIKey"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
@ -46,7 +46,7 @@ namespace LiveCameraSample.Properties {
this["EmotionAPIKey"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
@ -58,7 +58,7 @@ namespace LiveCameraSample.Properties {
this["VisionAPIKey"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Visible")]
@ -70,7 +70,7 @@ namespace LiveCameraSample.Properties {
this["SettingsPanelVisibility"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("00:00:03")]
@ -82,7 +82,7 @@ namespace LiveCameraSample.Properties {
this["AnalysisInterval"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("0")]
@ -94,7 +94,7 @@ namespace LiveCameraSample.Properties {
this["FaceAPICallCount"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("0")]
@ -106,7 +106,7 @@ namespace LiveCameraSample.Properties {
this["EmotionAPICallCount"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("0")]
@ -118,7 +118,7 @@ namespace LiveCameraSample.Properties {
this["VisionAPICallCount"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
@ -130,7 +130,7 @@ namespace LiveCameraSample.Properties {
this["AutoStopEnabled"] = value;
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("00:05:00")]
@ -139,5 +139,41 @@ namespace LiveCameraSample.Properties {
return ((global::System.TimeSpan)(this["AutoStopTime"]));
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("https://westus.api.cognitive.microsoft.com/face/v1.0")]
public string FaceAPIHost {
get {
return ((string)(this["FaceAPIHost"]));
}
set {
this["FaceAPIHost"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("https://westus.api.cognitive.microsoft.com/emotion/v1.0")]
public string EmotionAPIHost {
get {
return ((string)(this["EmotionAPIHost"]));
}
set {
this["EmotionAPIHost"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("https://westus.api.cognitive.microsoft.com/vision/v1.0")]
public string VisionAPIHost {
get {
return ((string)(this["VisionAPIHost"]));
}
set {
this["VisionAPIHost"] = value;
}
}
}
}

View file

@ -32,5 +32,14 @@
<Setting Name="AutoStopTime" Type="System.TimeSpan" Scope="Application">
<Value Profile="(Default)">00:05:00</Value>
</Setting>
<Setting Name="FaceAPIHost" Type="System.String" Scope="User">
<Value Profile="(Default)">https://westus.api.cognitive.microsoft.com/face/v1.0</Value>
</Setting>
<Setting Name="EmotionAPIHost" Type="System.String" Scope="User">
<Value Profile="(Default)">https://westus.api.cognitive.microsoft.com/emotion/v1.0</Value>
</Setting>
<Setting Name="VisionAPIHost" Type="System.String" Scope="User">
<Value Profile="(Default)">https://westus.api.cognitive.microsoft.com/vision/v1.0</Value>
</Setting>
</Settings>
</SettingsFile>

View file

@ -0,0 +1,28 @@
namespace LiveCameraSample.Properties {
// This class allows you to handle specific events on the settings class:
// The SettingChanging event is raised before a setting's value is changed.
// The PropertyChanged event is raised after a setting's value is changed.
// The SettingsLoaded event is raised after the setting values are loaded.
// The SettingsSaving event is raised before the setting values are saved.
internal sealed partial class Settings {
public Settings() {
// // To add event handlers for saving and changing settings, uncomment the lines below:
//
// this.SettingChanging += this.SettingChangingEventHandler;
//
// this.SettingsSaving += this.SettingsSavingEventHandler;
//
}
private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
// Add code to handle the SettingChangingEvent event here.
}
private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
// Add code to handle the SettingsSaving event here.
}
}
}

View file

@ -40,6 +40,7 @@ using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Microsoft.ProjectOxford.Common.Contract;
using Microsoft.ProjectOxford.Emotion.Contract;
using Microsoft.ProjectOxford.Face.Contract;
using Microsoft.ProjectOxford.Vision.Contract;
@ -91,7 +92,7 @@ namespace LiveCameraSample
42 * annotationScale, Brushes.Black);
// Instead of calling DrawText (which can only draw the text in a solid colour), we
// convert to geometry and use DrawGeometry, which allows us to add an outline.
var geom = ft.BuildGeometry(new Point(10 * annotationScale, y));
var geom = ft.BuildGeometry(new System.Windows.Point(10 * annotationScale, y));
drawingContext.DrawGeometry(s_lineBrush, new Pen(Brushes.Black, 2 * annotationScale), geom);
// Move line down
y += 42 * annotationScale;
@ -101,7 +102,7 @@ namespace LiveCameraSample
return DrawOverlay(baseImage, drawAction);
}
public static BitmapSource DrawFaces(BitmapSource baseImage, Microsoft.ProjectOxford.Face.Contract.Face[] faces, Scores[] emotionScores, string[] celebName)
public static BitmapSource DrawFaces(BitmapSource baseImage, Microsoft.ProjectOxford.Face.Contract.Face[] faces, EmotionScores[] emotionScores, string[] celebName)
{
if (faces == null)
{
@ -154,7 +155,7 @@ namespace LiveCameraSample
var ypad = pad;
var xpad = pad + 4 * annotationScale;
var origin = new Point(
var origin = new System.Windows.Point(
faceRect.Left + xpad - lineThickness / 2,
faceRect.Top - ft.Height - ypad + lineThickness / 2);
var rect = ft.BuildHighlightGeometry(origin).GetRenderBounds(null);

View file

@ -3,10 +3,10 @@
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net452" />
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net452" />
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net452" />
<package id="Microsoft.ProjectOxford.Common" version="1.0.308" targetFramework="net452" />
<package id="Microsoft.ProjectOxford.Emotion" version="1.0.310" targetFramework="net452" />
<package id="Microsoft.ProjectOxford.Face" version="1.1.0" targetFramework="net452" />
<package id="Microsoft.ProjectOxford.Vision" version="1.0.354" targetFramework="net452" />
<package id="Microsoft.ProjectOxford.Common" version="1.0.324" targetFramework="net452" />
<package id="Microsoft.ProjectOxford.Emotion" version="1.0.336" targetFramework="net452" />
<package id="Microsoft.ProjectOxford.Face" version="1.3.0" targetFramework="net452" />
<package id="Microsoft.ProjectOxford.Vision" version="1.0.393" targetFramework="net452" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
<package id="OpenCvSharp3-AnyCPU" version="3.1.0.20160622" targetFramework="net452" />
</packages>