Skip to content
This repository has been archived by the owner on Nov 8, 2021. It is now read-only.

Commit

Permalink
Windows SDK GA release update (#21)
Browse files Browse the repository at this point in the history
* Add emotion support for SDK and Sample.
* Update Cognitive-Common-Windows submodule.
* Make userData as optional for CreateFaceListAsync
* Add facial hair and head pose in sample. (#15)
* Endpoint change. (#20)
* Bump version to 1.2.5
  • Loading branch information
wangjun-microsoft authored and huxuan committed Mar 30, 2017
1 parent ee61d4d commit 512f034
Show file tree
Hide file tree
Showing 17 changed files with 119 additions and 72 deletions.
2 changes: 0 additions & 2 deletions ClientLibrary/Contract/ClientError.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

using System;
using System.Net;
using System.Runtime.Serialization;

namespace Microsoft.ProjectOxford.Face.Contract
Expand Down
11 changes: 11 additions & 0 deletions ClientLibrary/Contract/FaceAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,17 @@ public FacialHair FacialHair
get; set;
}

/// <summary>
/// Gets or sets the emotion.
/// </summary>
/// <value>
/// The emotion.
/// </value>
public Microsoft.ProjectOxford.Common.Contract.EmotionScores Emotion
{
get; set;
}

/// <summary>
/// Gets or sets the glasses type.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions ClientLibrary/FaceClientSDK.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<description>Microsoft Cognitive Services Face API Client Library</description>
<summary>Use Face API Client Library to enrich your apps with Microsoft's state-of-the-art cloud-based face algorithms.</summary>
<releaseNotes>User-configurable hostname</releaseNotes>
<releaseNotes>Support emotion attributes in Face Detection.</releaseNotes>
<copyright>Copyright (c) 2016</copyright>
<tags>Face Oxford ProjectOxford Microsoft Cognitive</tags>
<tags>Face Oxford ProjectOxford Microsoft Cognitive CognitiveServices</tags>
<dependencies>
<dependency id="Newtonsoft.Json" version="9.0.1" />
</dependencies>
Expand Down
6 changes: 2 additions & 4 deletions ClientLibrary/FaceServiceClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;

using Microsoft.ProjectOxford.Face.Contract;

using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;

Expand Down Expand Up @@ -462,7 +460,7 @@ public async Task<PersonGroup[]> GetPersonGroupsAsync()
public async Task<PersonGroup[]> ListPersonGroupsAsync(string start = "", int top = 1000)
{
var requestUrl = string.Format(
"{0}/{1}?start={2}$top={3}",
"{0}/{1}?start={2}&top={3}",
ServiceHost,
PersonGroupsQuery,
start,
Expand Down Expand Up @@ -781,7 +779,7 @@ public async Task<GroupResult> GroupAsync(Guid[] faceIds)
/// <returns>
/// Task object.
/// </returns>
public async Task CreateFaceListAsync(string faceListId, string name, string userData)
public async Task CreateFaceListAsync(string faceListId, string name, string userData = null)
{
var requestUrl = string.Format("{0}/{1}/{2}", ServiceHost, FaceListsQuery, faceListId);

Expand Down
8 changes: 6 additions & 2 deletions ClientLibrary/IFaceServiceClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
using System.IO;
using System.Net.Http.Headers;
using System.Threading.Tasks;

using Microsoft.ProjectOxford.Face.Contract;

namespace Microsoft.ProjectOxford.Face
Expand Down Expand Up @@ -77,6 +76,11 @@ public enum FaceAttributeType
/// Analyses glasses type
/// </summary>
Glasses,

/// <summary>
/// Analyses emotion
/// </summary>
Emotion,
}

/// <summary>
Expand Down Expand Up @@ -173,7 +177,7 @@ HttpRequestHeaders DefaultRequestHeaders
/// <param name="name">The name.</param>
/// <param name="userData">The user data.</param>
/// <returns>Task object.</returns>
Task CreateFaceListAsync(string faceListId, string name, string userData);
Task CreateFaceListAsync(string faceListId, string name, string userData = null);

/// <summary>
/// Creates a person asynchronously.
Expand Down
4 changes: 4 additions & 0 deletions ClientLibrary/Microsoft.ProjectOxford.Face.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<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="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
Expand Down
2 changes: 1 addition & 1 deletion ClientLibrary/Microsoft.ProjectOxford.Face.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
VisualStudioVersion = 14.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.ProjectOxford.Face", "Microsoft.ProjectOxford.Face.csproj", "{25D58BA5-660F-407B-803C-22B4547C09DC}"
EndProject
Expand Down
6 changes: 3 additions & 3 deletions ClientLibrary/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
[assembly: AssemblyDescription("Microsoft.ProjectOxford.Face")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Microsoft ProjectOxford")]
[assembly: AssemblyCopyright("Copyright © 2015 Microsoft")]
[assembly: AssemblyCopyright("Copyright © 2016 Microsoft")]
[assembly: AssemblyTrademark("Microsoft")]
[assembly: NeutralResourcesLanguage("en")]

[assembly: AssemblyVersion("1.2.1.1")]
[assembly: AssemblyFileVersion("1.2.1.1")]
[assembly: AssemblyVersion("1.2.5")]
[assembly: AssemblyFileVersion("1.2.5")]
3 changes: 2 additions & 1 deletion ClientLibrary/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.ProjectOxford.Common" version="1.0.324" targetFramework="portable45-net45+win8+wpa81" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="portable45-net45+win8+wpa81" />
</packages>
</packages>
15 changes: 2 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,8 @@ You can reach out to us anytime with questions and suggestions using our communi
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.

## Updates
- **8/2016 update for [July 2016 Face API changes](https://www.microsoft.com/cognitive-services/en-us/face-api/documentation/overview#changes)**

*Client Library*
- `VerifyAsync` interface with `faceId`, `personGroupId` and `personId` as paramters.
- Optional user-specified `confidenceThreshold` paramter in `IdentifyAsync`.
- `FindSimilarMatchMode` enum declaration and adopted in `FindSimilarAsync`.
- New `ListPersonGroupsAsync` interface with `start` and `top` as paramters and recommend to use `ListPersonGroupsAsync` instead of `GetPersonGroupsAsync`.

*Sample*
- `Verfication` demo for face and person authentication.
- `FindSimilar` demo of `MatchFace` mode.


* [Face API Release Notes](https://www.microsoft.com/cognitive-services/en-us/face-api/documentation/ReleaseNotes)

## License
All Microsoft Cognitive Services SDKs and samples are licensed with the MIT License. For more details, see
[LICENSE](</LICENSE.md>).
Expand Down
8 changes: 4 additions & 4 deletions Sample-WPF/App.config
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Expand Down
37 changes: 15 additions & 22 deletions Sample-WPF/Controls/Face.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@ public class Face : INotifyPropertyChanged
/// </summary>
private string _facialHair;

/// <summary>
/// Indicates whether the face is smile or not
/// </summary>
private string _isSmiling;

/// <summary>
/// Indicates the glasses type
/// </summary>
Expand All @@ -103,6 +98,11 @@ public class Face : INotifyPropertyChanged
/// </summary>
private string _headPose;

/// <summary>
/// Indicates the emotion
/// </summary>
private string _emotion;

#endregion Fields

#region Events
Expand Down Expand Up @@ -298,23 +298,6 @@ public string FacialHair
}
}

/// <summary>
/// Gets or sets a value indicating whether the face is smile or not
/// </summary>
public string IsSmiling
{
get
{
return _isSmiling;
}

set
{
_isSmiling = value;
OnPropertyChanged<bool>();
}
}

/// <summary>
/// Gets or sets a value indicating the glasses type
/// </summary>
Expand Down Expand Up @@ -345,6 +328,16 @@ public string HeadPose
}
}

public string Emotion
{
get { return _emotion; }
set
{
_emotion = value;
OnPropertyChanged<string>();
}
}

#endregion Properties

#region Methods
Expand Down
8 changes: 4 additions & 4 deletions Sample-WPF/Controls/FaceDetectionPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@
</Image>
<TextBlock Grid.Column="2" Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Gender}" />
<TextBlock Grid.Column="2" Grid.Row="0" HorizontalAlignment="Right" VerticalAlignment="Top" Text="{Binding Age}" />
<TextBlock Grid.Column="2" Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding IsSmiling}" />
<TextBlock Grid.Column="2" Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Top" Text="{Binding Glasses}" TextWrapping="Wrap" />
<TextBlock Grid.Column="2" Grid.Row="2" VerticalAlignment="Top" Text="{Binding FacialHair}" TextWrapping="Wrap" />
<TextBlock Grid.Column="2" Grid.Row="3" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding HeadPose}" TextWrapping="Wrap" />
<TextBlock Grid.Column="2" Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Emotion}" />
<TextBlock Grid.Column="2" Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Top" Text="{Binding Glasses}"/>
<TextBlock Grid.Column="2" Grid.Row="2" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding FacialHair}" />
<TextBlock Grid.Column="2" Grid.Row="3" HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding HeadPose}"/>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
Expand Down
58 changes: 51 additions & 7 deletions Sample-WPF/Controls/FaceDetectionPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,12 @@
//

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;

namespace Microsoft.ProjectOxford.Face.Controls
{
Expand Down Expand Up @@ -204,7 +201,7 @@ private async void ImagePicker_Click(object sender, RoutedEventArgs e)
// Show file picker dialog
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
dlg.DefaultExt = ".jpg";
dlg.Filter = "Image files (*.jpg, *.png, *bmp, *.gif) | *.jpg; *.png; *.bmp; *.gif";
dlg.Filter = "Image files (*.jpg, *.png, *.bmp, *.gif) | *.jpg; *.png; *.bmp; *.gif";
var result = dlg.ShowDialog();

if (result.HasValue && result.Value)
Expand All @@ -230,7 +227,7 @@ private async void ImagePicker_Click(object sender, RoutedEventArgs e)
string subscriptionKey = mainWindow._scenariosControl.SubscriptionKey;

var faceServiceClient = new FaceServiceClient(subscriptionKey);
Contract.Face[] faces = await faceServiceClient.DetectAsync(fileStream, false, true, new FaceAttributeType[] { FaceAttributeType.Gender, FaceAttributeType.Age, FaceAttributeType.Smile, FaceAttributeType.Glasses, FaceAttributeType.HeadPose, FaceAttributeType.FacialHair });
Contract.Face[] faces = await faceServiceClient.DetectAsync(fileStream, false, true, new FaceAttributeType[] { FaceAttributeType.Gender, FaceAttributeType.Age, FaceAttributeType.Smile, FaceAttributeType.Glasses, FaceAttributeType.HeadPose, FaceAttributeType.FacialHair, FaceAttributeType.Emotion });
MainWindow.Log("Response: Success. Detected {0} face(s) in {1}", faces.Length, SelectedFile);

DetectedResultsInText = string.Format("{0} face(s) has been detected", faces.Length);
Expand All @@ -247,10 +244,10 @@ private async void ImagePicker_Click(object sender, RoutedEventArgs e)
FaceId = face.FaceId.ToString(),
Gender = face.FaceAttributes.Gender,
Age = string.Format("{0:#} years old", face.FaceAttributes.Age),
IsSmiling = face.FaceAttributes.Smile > 0.0 ? "Smile" : "Not Smile",
Glasses = face.FaceAttributes.Glasses.ToString(),
FacialHair = string.Format("Facial Hair: {0}", face.FaceAttributes.FacialHair.Moustache + face.FaceAttributes.FacialHair.Beard+face.FaceAttributes.FacialHair.Sideburns > 0 ? "Yes":"No"),
HeadPose = string.Format("Pitch: {0}, Roll: {1}, Yaw: {2}", Math.Round(face.FaceAttributes.HeadPose.Pitch, 2), Math.Round(face.FaceAttributes.HeadPose.Roll, 2), Math.Round(face.FaceAttributes.HeadPose.Yaw, 2))
HeadPose = string.Format("Pitch: {0}, Roll: {1}, Yaw: {2}", Math.Round(face.FaceAttributes.HeadPose.Pitch, 2), Math.Round(face.FaceAttributes.HeadPose.Roll, 2), Math.Round(face.FaceAttributes.HeadPose.Yaw, 2)),
Emotion = $"{GetEmotion(face.FaceAttributes.Emotion)}"
});
}

Expand All @@ -271,6 +268,53 @@ private async void ImagePicker_Click(object sender, RoutedEventArgs e)
}
}

private string GetEmotion(Microsoft.ProjectOxford.Common.Contract.EmotionScores emotion)
{
string emotionType = string.Empty;
double emotionValue = 0.0;
if (emotion.Anger > emotionValue)
{
emotionValue = emotion.Anger;
emotionType = "Anger";
}
if (emotion.Contempt > emotionValue)
{
emotionValue = emotion.Contempt;
emotionType = "Contempt";
}
if (emotion.Disgust > emotionValue)
{
emotionValue = emotion.Disgust;
emotionType = "Disgust";
}
if (emotion.Fear > emotionValue)
{
emotionValue = emotion.Fear;
emotionType = "Fear";
}
if (emotion.Happiness > emotionValue)
{
emotionValue = emotion.Happiness;
emotionType = "Happiness";
}
if (emotion.Neutral > emotionValue)
{
emotionValue = emotion.Neutral;
emotionType = "Neutral";
}
if (emotion.Sadness > emotionValue)
{
emotionValue = emotion.Sadness;
emotionType = "Sadness";
}
if (emotion.Surprise > emotionValue)
{
emotionValue = emotion.Surprise;
emotionType = "Surprise";
}
return $"{emotionType}";
}

#endregion Methods
}
}
10 changes: 7 additions & 3 deletions Sample-WPF/FaceAPI-WPF-Samples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<ApplicationVersion>1.2.5</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
Expand All @@ -52,8 +52,12 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.ProjectOxford.Face, Version=1.2.1.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.ProjectOxford.Face.1.2.1.2\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.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.ProjectOxford.Face.1.2.5\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">
Expand Down
Loading

0 comments on commit 512f034

Please sign in to comment.