Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

NotificationsYou must be signed in to change notification settings

ishaanjav/Face_API_-_Visual_Studio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 

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.


Usage

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:

  1. definePeple(): Use this to create aCreatePersonResult object 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 containjpg images of each person.
  2. trainPersonGroup() is called totrain the Person Group on the people and their images. There are no parameters or specific directories required for this function.
  3. 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.

Setup

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.

1. Create the Visual Studio Project

  • 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.cs file and paste the code from this repository'sProgram.cs into your.cs file. Then, follow the steps below to get the Microsoft API Key, Add the API Key and Endpoint, and Specify the Directory of the Images.

2. Get the Microsoft Face API

  • 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:
      1. Click on"Create a resource" on the left side of the portal.
      2. Underneath"Azure Marketplace", click on the"AI + Machine Learning" section.
      3. Now, under"Featured" you should see"Face". Click on that.
      4. You should now be atthis page.Fill in the required information and press "Create" when done.
      5. Now, click on"All resources" on the left hand side of the Portal.
      6. Click on thename you gave the API.
      7. Underneath"Resource Management", click on"Manage Keys".

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.

3. Add the API Key and Endpoint

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.

4. Specify the Directories of the Images

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

Other Repositories

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

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp