- Notifications
You must be signed in to change notification settings - Fork1
This repository contains the code for a Console Application that uses the Microsoft Azure Face API to add people to Person Groups and identify people. The code is in C# and is meant to be used in Visual Studio.
License
ishaanjav/Face_API_-_Visual_Studio
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
The purpose of this repository is to provide code for a Console Application in C# that uses the Microsoft Azure Face API to add people to Person Groups and then identify people given images. Below, you can find the instructions for setting up the app and using and modifying the code for your own purposes.
You simply have to give the program an image of a person's face for it to recognize. I also have a relevantAndroid app repository which can be used for face identification after adding people to Person Groups in C# below.
If you have not already done so, refer to theSetup Section to setup the Console Application using your own Microsoft Face API Key and images of people.
Using the application is simple once it is setup. Simplyrun each of the functions inProgram.cs to do different tasks:
definePeple(): Use this to create aCreatePersonResultobject for each person. Inside,definePeople, the functiondetectRegisterFace()is called toadd images for each face in an image and add it to the corresponding person.IMPORTANT: It is indetectRegisterFace(), lines 122, 139, and 151 that you must specify the directory of a folder containjpgimages of each person.trainPersonGroup()is called totrain the Person Group on the people and their images. There are no parameters or specific directories required for this function.identifyFace()is called toidentify a face. It acceptsone parameter: the directory containing an image of a person. It then gets the best match of the person in the image and prints their name in the Console. If it is not able to identify the person in the image, then it doesn't display anything.
Microsoft Azure has documentation onDetecting Faces andIdentifying Faces from images. Below are the steps to setup the Console App from theProgram.cs file in this repository.
- In Visual Studio create anew Console App from the .Net Framework.
- Get the requiredNuGet Packages -
- In the Solution Explorer, right-click on your project.
- Select "Manage NuGet Packages"
- Click the "Browse" tab and select "Include prerelease"
- Find and install this package or a similar package,(if there has been an update):
Microsoft.Azure.CognitiveServices.Vision.Face 2.2.0-preview
- After creating the project, open the
.csfile and paste the code from this repository'sProgram.csinto your.csfile. Then, follow the steps below to get the Microsoft API Key, Add the API Key and Endpoint, and Specify the Directory of the Images.
- Making the Azure Account:In order to use the Face API, you must get an API Subscription Key from the Azure Portal.This page by Microsoft provides the features and capabilities of the Face API.You can create a free Azure account that doesn't expire atthis link here by clicking on the "Get API Key" button and choosing the option to create an Azure account.
- Getting the Face API Key from Azure Portal:
- Once you have created your account, head to theAzure Portal. Follow these steps:
- Click on"Create a resource" on the left side of the portal.
- Underneath"Azure Marketplace", click on the"AI + Machine Learning" section.
- Now, under"Featured" you should see"Face". Click on that.
- You should now be atthis page.Fill in the required information and press "Create" when done.
- Now, click on"All resources" on the left hand side of the Portal.
- Click on thename you gave the API.
- Underneath"Resource Management", click on"Manage Keys".
- Once you have created your account, head to theAzure Portal. Follow these steps:
You should now be able to see two different subscription keys that you can use. Follow the additional instructions to see how to use the API Key in the application.
InProgram.cs, on Line 17 you may see:
FaceServiceClient faceServiceClient = new FaceServiceClient("<YOUR API KEY HERE>", "<YOUR API ENDPOINT HERE>");<YOUR API KEY HERE> should be replaced with theAPI Key that you got from theAzure Portal.<YOUR ENDPOINT HERE> should be replaced with one of the following examples fromthis API Documentation link. The format should be similar to:
"https://<LOCATION>/face/v1.0"where<LOCATION> should be replaced with something likeuksouth.api.cognitive.microsoft.com orjapaneast.api.cognitive.microsoft.com. All of these can be found, listed atthis link.
Now that you have gotten your API Key and Endpoint and used them as the constructors ofFaceServiceClient on Line 17, you have tospecify the directories of the images for the people that will be identified. TheidentifyFace() function accepts a String as a parameter with the directory of an image containing a face, but the other functions,such asaddIndividual anddefinePeople, require you to change the directory in the function itself.
Where it says:
@"<Directory with images of person>" //Line 40.//OR:@"<Directory with images of Person #>" //Lines 122, 139, 151.replace the<Directory with images of person> with the directory of an images folder on your computer. Images have been provided in this repository which you can download to test the Console Application. Once you have replaced<Directory with images of Person 1 with the actual directories of images, you can run the functions one by one,starting withdefinePeople() to:
- add people to Person Groups
- train the Person Groups
- and identify people
While this is a simple Console Application that can be used for facial identification, I also have repositories for Android apps that use the Microsoft Face API for facial analysis and Kairos's API to do facial recognition. Below is a list of some of those repositories:
- Face API - Identification in Android: A closely-related repository for an Android app that also uses the Microsoft Face API for facial detection and identification.README
- Face Analyzer: The purpose of this Android app is to utilize the Microsoft Face API to not only detect individual faces in an image, but also for each face provide information such as emotions, the estimated age, gender, and more.README
- Kairos Face Recognition: The purpose of this Android app is to use Kairos's SDK for Android in order to implement facial recognition. Features of this app include: registering and identifying users when given an image.README
About
This repository contains the code for a Console Application that uses the Microsoft Azure Face API to add people to Person Groups and identify people. The code is in C# and is meant to be used in Visual Studio.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.