跳过导航

Face Finder

John MacKenzie 提供
上次更新时间:2018/9/20
在 GitHub 上编辑

This sample searches a folder for image files containing a face. Selected attributes of the image and face are displayed. Searches can be filtered by age range, gender, and whether the face matches a specified person. The sample uses the Windows client libraries for the Computer Vision and Face services of Microsoft Cognitive Services.

Features

  • Parses a folder for image files of type bmp, gif, jpg, and png.
  • Processes the image files to detect images containing a face.
  • Displays thumbnails of each image that has a face, along with attributes associated with the image and face.
  • Available attributes are:
    • age and gender
    • caption (as a tool tip)
    • printed character recognition (OCR)
    • date image taken and title, if available
  • Image files can be filtered on:
    • age range
    • gender
    • matching person/face
  • Finds all images with a face that matches a specified person.

Getting Started

Prerequisites

  • You need subscription keys for the Computer Vision and Face services to run the sample. You can get free trial subscription keys from Try Cognitive Services.
  • Any edition of Visual Studio 2017 with the .NET Desktop application development workload installed.
  • A folder containing image files with faces.

Quickstart

  1. Clone or download the repository.
  2. Open the FaceFinder folder in the repository.
  3. Double-click the FaceFinder.sln file, which opens the project in Visual Studio.
  4. Build the project, which installs the Computer Vision and Face service NuGet packages.
  5. Run the program.

Walkthrough

Face Finder provides two modes of operation.

The first mode searches a folder for images that contain at least one face and displays information about these images and faces. Searches can be filtered by age range and gender.

To start:

  1. Click the expander button on the upper right of the screen.
  2. Enter your Computer Vision and Face subscription keys in the appropriate text boxes.
  3. Change the service endpoints to match the region associated with your subscription keys, if necessary. The keys and endpoints are stored in IsolatedStorage, which persist between program runs.
  4. Select the search criteria. The Match person checkbox is disabled until a person is specified in the bottom section of the pane (described below).
  5. Click Select Folder and browse to a local folder containing images that you want to search for faces.
    • Valid image file types are bmp, gif, jpg, and png.
    • An image can contain multiple people.
    • A face doesn't have to be prominent but must show both eyes to be detected.
  6. Click Find Faces, which searches the folder for image files and then analyzes these files for faces. If you want to stop the search early, click Cancel.

Note: When Get thumbnail is selected, a subfolder named FaceThumbnails is created under the selected folder to store the thumbnails created by the Computer Vision service.

The following screenshot shows the opening screen with the settings pane displayed.

The following screenshot shows the results after a search of the selected folder for males between the ages of 50 and 70. The thumbnails are generated by the Computer Vision service from the images that matched the search criteria. Note the tool tip on the third image of the first row showing the caption from Computer Vision's analysis of the image. The metrics displayed below the thumbnails show the

  • name of the selected folder
  • number of files in the folder
  • number of image files (bmp, gif, jpg, and png) in the folder
  • live processing count
  • number of image files containing a face (must show both eyes to be detected)
  • number of images with faces that match the search criteria
  • number of images with faces that match the search criteria and the selected person

The second mode additionally filters the images to those with a face that match a specified person.

To filter by person:

  1. Type a name for the person in the combo box and click Add Person.
  2. Select one or more images of this person, using the Ctrl and Shift keys for multiple selections. Each selected image should contain only one face.
  3. When selection is complete, click Add Faces, which associates the faces with the specified person.
  4. Click Display to see the selected images in the left pane.
  5. Select the Match person checkbox.
  6. Click Find Faces to start the search over again. This time, only images that match the person are displayed.

The following screenshot shows the results after searching for images that match the specified person. The left panel is open, which shows the images used to define the person. The bottom panel now shows the name you gave the person and the number of matched face images.

A person and their associated images are persisted. To delete a person and their images:

  1. Select the person in the combo box.
  2. Click Delete. A confirmation dialog appears for approval.

Images in these screenshots are from Labeled Faces in the Wild. For one list of datasets containing images of people, see CVonline: Image Databases, People.

Resources

更多示例由 John MacKenzie 提供