Giter Club home page Giter Club logo

cognitive-face-windows's Introduction

This repository has been retired. Please visit the Face QuickStart to get started with the latest Face SDKs.

Microsoft Face API: Windows Client Library & Sample

This repo contains the Windows client library & sample for the Microsoft Face API, an offering within Microsoft Cognitive Services, formerly known as Project Oxford.

The Client Library

The client library is a thin C# client wrapper for Microsoft Face API. The easiest way to use this client library is to get microsoft.projectoxford.face package from nuget.

Please go to Face API Package in nuget for more details.

The Sample

This sample is a Windows WPF application to demonstrate the use of Face API. It demonstrates face detection, face verification, face grouping, finding similar faces, and face identification.

Build the Sample

  1. Starting in the folder where you clone the repository (this folder).
  2. In a git command line tool, type git submodule init (or do this through a UI).
  3. Pull in the shared Windows code by calling git submodule update.
  4. Start Microsoft Visual Studio 2015 and select File > Open > Project/Solution.
  5. Go to Sample-WPF Folder.
  6. Double-click the Visual Studio 2015 Solution (.sln) file FaceAPI-WPF-Samples.
  7. Press Ctrl+Shift+B, or select Build > Build Solution.

Run the Sample

After the build is complete, press F5 to run the sample.

First, you must obtain a Face API subscription key by following instructions on our website.

Locate the text edit box saying "Paste your subscription key here to start" on the top right corner. Paste your subscription key. You can choose to persist your subscription key in your machine by clicking "Save Key" button. When you want to delete the subscription key from the machine, click "Delete Key" to remove it from your machine.

Click on "Select Scenario" to use samples of different scenarios, and follow the instructions on screen.

Microsoft will receive the images you upload and may use them to improve Face API and related services. By submitting an image, you confirm you have consent from everyone in it.

There are sample images to be used with this sample application. You can find these images under Face > Windows > Data folder. Please note the use of these images is licensed under LICENSE-IMAGE.

Contributing

We welcome contributions. Feel free to file issues and pull requests on the repo and we'll address them as we can. Learn more about how you can help on our Contribution Rules & Guidelines.

You can reach out to us anytime with questions and suggestions using our communities below:

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Updates

License

All Microsoft Cognitive Services SDKs and samples are licensed with the MIT License. For more details, see LICENSE.

Sample images are licensed separately, please refer to LICENSE-IMAGE.

Developer Code of Conduct

Developers using Cognitive Services, including this client library & sample, are expected to follow the “Developer Code of Conduct for Microsoft Cognitive Services”, found at http://go.microsoft.com/fwlink/?LinkId=698895.

cognitive-face-windows's People

Contributors

cthrash avatar danzel avatar delfu avatar huxuan avatar lebronj avatar lightfrenzy avatar longli0 avatar msftgits avatar oyzh888 avatar ryanga avatar sldi-microsoft avatar wangjun-microsoft avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cognitive-face-windows's Issues

Anti-Spoofing

I want to use the API for face tagging on doors in my company, but I noticed that upon receiving a printed photo image api returns as valid, is there any Anti-Spoofing for the API not recognizing photos on camera?

FaceServiceClient(string subscriptionKey, string apiRoot) NOT Avaible in .NET SDK 1.2.1

I have upgraded my SDK to 1.2.1 via nuget. But I cannot find the construction method with apiRoot arg.

I have the one with subscriptionKey only. Could you please help to take a look?
public FaceServiceClient(string subscriptionKey)

Below is the meta data I get from visual studio, which shows I am with 1.2.1.

#region Assembly Microsoft.ProjectOxford.Face, Version=1.2.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// C:\Users\xingzhou\Desktop\VideoFace\packages\Microsoft.ProjectOxford.Face.1.2.1\lib\portable-net45+wp80+win8+wpa81+aspnetcore50\Microsoft.ProjectOxford.Face.dll
#endregion

using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Http.Headers;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Microsoft.ProjectOxford.Face.Contract;

namespace Microsoft.ProjectOxford.Face
{
    public class FaceServiceClient : IDisposable, IFaceServiceClient
    {
        public FaceServiceClient(string subscriptionKey);

        ~FaceServiceClient();
...
}
}

Error in Sample-WPF solution : Assembly 'SampleUserControlLibrary' was not found.

Hi,

I would like to thank all contributors and supporters.

I was trying to build the "FaceAPI-WPF-Samples.sln" under Cognitive-Face-Windows-master\Sample-WPF location. While building it was throwing "Assembly 'SampleUserControlLibrary' was not found".
Please check the screenshot for the same.
image

Could you please check and upload the new version build?
Thanks in Advance!!

Access denied due to invalid subscription key. Make sure you are subscribed to an API you are trying to call and provide the right key

I subscribed to Face API using the subscription key for the trial version. But I am unable to make the rest api call as I getting the following JSON :
{
"error": {
"code": "Unspecified",
"message": "Access denied due to invalid subscription key. Make sure you are subscribed to an API you are trying to call and provide the right key."
}
}
This was tried out in face api console in API reference. The same error is seen in the c# code as well. Kindly please help

PS: I used the correct subscription key that was assigned to me for this particular app.

Missing nuGet

Microsoft.ProjectOxford.Face cant be found anymore.

Handling transient failures

Would you consider a PR to handle temporary failures internally before throwing an exception?

Currently if a user calls Identify and the person group provided is being trained, that exception gets thrown out to the client app to handle.

Would it be worth handling this internally?
In EntityFramework they internally handle some errors and retry ref

We could do the same
torutek@8f4e043

SampleUserControlLibrary missing in solution

Opening the solution FaceAPI-WPF-Samples.sln has two projects. Project "FaceAPI-WPF-Samples" opens fine. Project "SampleUserControlLibrary" fails to load as it is not found in the respective location.

Please check the zip file or give right steps to use.

Image too small or too big?

Hello!
Trying to detect a face, I always get the same error. I have no clue on what I am doing wrong. When I google for this, I find nothing on the C# API.

Image too small or too big

I believe this is a bug in this client API

Some of my code:

private void DoSomething(SoftwareBitmap original, BitmapBounds bounds) 
{
	using (var inputStream = new InMemoryRandomAccessStream())
	{
		using (var converted = SoftwareBitmap.Convert(original, BitmapPixelFormat.Rgba16))
		{
			var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, inputStream);
			encoder.SetSoftwareBitmap(converted);
			// Comment this line, no difference
			encoder.BitmapTransform.Bounds = bounds;
			await encoder.FlushAsync();

			// Display the image in my window
			BitmapImage xamlImage = new BitmapImage();
			xamlImage.SetSource(inputStream);
			await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () => {
			    m_FacePreviewImage.Source = xamlImage;
			});

			// ============================================================
			// Here it is!
			// ============================================================
			var client = new FaceServiceClient("______KEY___HERE______");
			Face[] guids;
			try
			{
			    guids = await client.DetectAsync(inputStream.AsStream());
			} catch (FaceAPIException er)
			{
			    Debug.WriteLine("Exception: " + er.ErrorMessage);
			    return;
			}
			// More code...
		}
	}
}

exception of type 'Microsoft.ProjectOxford.Face.FaceApiException' was thrown

Hi,
I keep getting the error : exception of type 'Microsoft.ProjectOxford.Face.FaceApiException' was thrown.
I am using standard price tier and my code is :

Private Shared Function CreateFaceClient() As IFaceServiceClient
Return New FaceServiceClient("key", "https://eastus2.api.cognitive.microsoft.com/face/v1.0")
End Function

Private Async Sub Button4_ClickAsync(sender As Object, e As EventArgs) Handles Button4.Click
Button4.Enabled = False
Try
If CameraControl1.TakeSnapshot() Is Nothing Then
MsgBox("Take a Picture First")
Exit Sub
End If
Dim url As String = Path.Combine(My.Computer.FileSystem.SpecialDirectories.Temp, "faceapi.jpg") ' "C:\Users\Cisse\Desktop\08388022IJJSB.jpg"
CameraControl1.TakeSnapshot().Save(url, Imaging.ImageFormat.Jpeg)
Dim personGroupId As String = "1"
Dim faceServiceclient As IFaceServiceClient = CreateFaceClient()
Using fs As Stream = File.OpenRead(url)
Dim faces = Await faceServiceclient.DetectAsync(fs)
Dim faceIds = faces.Select(Function(face) face.FaceId).ToArray()
Dim results = Await faceServiceclient.IdentifyAsync(personGroupId, faceIds)
For Each identifyResult In results
' MsgBox(identifyResult.FaceId.ToString())
If identifyResult.Candidates.Length = 0 Then
MsgBox("No one identified")
Else
Dim candidateid = identifyResult.Candidates(0).PersonId
Dim person = Await faceServiceclient.GetPersonAsync(personGroupId, candidateid)
MsgBox("Welcome :" & person.Name & Space(2) & person.UserData)

                End If
            Next
        End Using
    Catch ex As Exception
        MsgBox(ex.Message)
    Finally
        Button4.Enabled = True
    End Try

End Sub

Face Detection Issue

When I am showing my face using the image stored in my phone to Web Camera. It still detects as a face.. Is there any way to avoid that.. Only detect 3D Faces, not from mobile phone

Misleading error message

Two suggestions in regards to the following error:
Access denied due to invalid subscription key. Make sure you are subscribed to an API you are trying to call and provide the right key.

  1. 'Subscription key' is easily mistaken for subscription ID, service key or API key might be better.

  2. The endpoint defaults to westus, and when a client is created with just the subsciption key the client will use the default endpoint. We should either not provide a default endpoint and instead require one when the client is instantiated, or at least suggest in the error message that the endpoint might be wrong

Cognitive services URL should be configurable

I was testing the WPF to see some sample code for a Xamarin App and I could not get my API key working. I noticed the different regions you could use and I saw on the Face Detection DLL (Microsoft.ProjectOxford.Face) you have the URL hardcoded on the file FaceServiceClient.cs.

I had to recreate the service on Azure and put it on westus to get the WPF app working.

It would be nice that this parameter could be configurable from the client.

Endpoint change

I have received an e-mail notification saying that the current endpoint will stop working tomorrow. I'm afraid that my application using Face API will stop working as well.

My application is using Face API through the client in this NuGet package: https://www.nuget.org/packages/Microsoft.ProjectOxford.Face/

What should I do to avoid problems with the upcoming change?

Thanks

Generic exception thrown when keys have expired

From @SaqibS on December 19, 2015 16:54

I have an Azure service which makes use of multiple Project Oxford APIs, and overnight calls to each of the services started failing.

I looked through the logs, and found that the client libraries for both Vision and Face were throwing a System.Exception, with message: "Transport error".

Eventually, I found that invoking the APIs using rest directly, I got a useful message back, saying that the keys had expired. Why this happened is a separate issue, along with why I didn't get any emails to say that the keys were going to expire (they still show as active on the website). But that's all separate - this bug relates to the fact that the client libraries shouldn't just throw a generic Exception with such a vague message. The message returned by the rest API should be wrapped in the client-specific exception.

Copied from original issue: microsoft/ProjectOxford-ClientSDK#13

When is this going to be unsupported?

According to the README and several other sources, this library (Project Oxford) is deprecated in place of Microsoft.Azure.CognitiveServices.Vision.Face, however, the CognitiveServices SDK is labeled as a prerelease according to the NuGet package listing.

Everything appears to function as normal using this SDK, which is great, but it would be nice to get a heads up before we are required to switch over to cognitive services (the Azure SDK) entirely.

When can we expect this library to be fully removed and/or unsupported?

C# SDK: FaceRectangle should inherit from Rectangle

From @SaqibS on November 24, 2015 18:35

I am using the C# client SDKs available from NuGet.

When using the face detection API, you get back an array of FaceRectangles. However, the Emotion Detection API requires an array of Rectangles (from the Common namespace). Both types have the same 4 fields one would expect.

These should be consolidated - either FaceDetection should return Common Rectangles, or else FaceRectangle should inherit from Rectangle. Or, just use System.Drawing.Rectangle.

Copied from original issue: microsoft/ProjectOxford-ClientSDK#6

Error

I am not able to build the project. Please check the error.

C:\Users\This PC\Desktop\Cognitive-Face-Windows-master\Cognitive-Common-Windows\SampleUserControlLibrary\SampleUserControlLibrary.csproj : error : The project file could not be loaded. Could not find a part of the path 'C:\Users\This PC\Desktop\Cognitive-Face-Windows-master\Cognitive-Common-Windows\SampleUserControlLibrary\SampleUserControlLibrary.csproj'. C:\Users\This PC\Desktop\Cognitive-Face-Windows-master\Cognitive-Common-Windows\SampleUserControlLibrary\SampleUserControlLibrary.csproj

System.net.http.httprequestexception

This error pops up whenever I try to run this application. The debugger points to the line of code below the line where we create a new faceserviceclient object.

Projectoxford.face.contract.face[] faces = await faceserviceclient.detectasync(fstream,false,true,new face attribute......

With a accompanying message that says
"Socket exception : an existing connection was forcibly closed by the remote host"

My internet is Preety fast

I can't install this nuget into a xamarin project

Could not install package 'Microsoft.ProjectOxford.Face 1.2.1.2'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v7.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author. 0

Cognitive service is not serializable

Hello Team,

I was consuming the face in a sample Bot project.
I was able to exploit the API but after the completion of process i,e face Analysis I am getting a Error "Sorry my bot have Issue." on checking with emulator for POST.500 Error it has the following description:
An error has occurred.",\r\n "exceptionMessage": "Type 'Microsoft.Azure.CognitiveServices.Vision.Face.Models.DetectedFace' in Assembly 'Microsoft.Azure.CognitiveServices.Vision.Face, Version=0.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not marked as serializable.",\r\n "exceptionType": "System.Runtime.Serialization.SerializationException",\r\n

Please help me with the way around for this error.

Regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.