什麼是 Azure 臉部 API?What is the Azure Face API?

Azure 認知服務的臉部 API 提供相關的演算法,用來偵測、辨識和分析影像中的人臉。The Azure Cognitive Services Face API provides algorithms that are used to detect, recognize, and analyze human faces in images. 處理人臉資訊在許多不同的軟體案例中都是重要的能力。The ability to process human face information is important in many different software scenarios. 舉例來說,這些案例包括安全性、自然使用者介面、影像內容分析和管理、行動應用程式及機器人。Example scenarios are security, natural user interface, image content analysis and management, mobile apps, and robotics.

臉部 API 提供了幾項不同的功能。The Face API provides several different functions. 以下幾節會有各項功能的相關概述。Each function is outlined in the following sections. 請繼續閱讀以深入了解各項功能。Read on to learn more about them.

臉部偵測Face detection

臉部 API 可偵測影像中的人臉,並傳回其位置的矩形座標。The Face API detects human faces in an image and returns the rectangle coordinates of their locations. 臉部偵測也可以擷取一連串與臉部相關的屬性。Optionally, face detection can extract a series of face-related attributes. 例如,姿勢、性別、年齡、頭部姿勢、臉部汗毛和眼鏡等。Examples are head pose, gender, age, emotion, facial hair, and glasses.


電腦視覺 API 也提供臉部偵測功能。The face detection feature is also available through the Computer Vision API. 如果您想要以臉部資料執行進一步的作業,請使用臉部 API,這是本文所討論的服務。If you want to do further operations with face data, use the Face API, which is the service discussed in this article.


如需臉部偵測的詳細資訊,請參閱臉部偵測概念文章。For more information on face detection, see the Face detection concepts article. 另請參閱偵測 API 參考文件。Also see the Detect API reference documentation.

臉部驗證Face verification

驗證 API 會對兩個偵測到的臉部執行驗證,或從一個偵測到的臉部向一個人員物件執行驗證。The Verify API performs an authentication against two detected faces or from one detected face to one person object. 實際上,它會評估兩張臉孔是否屬於同一人。Practically, it evaluates whether two faces belong to the same person. 此功能在安全性案例中可能有其效用。This capability is potentially useful in security scenarios. 如需詳細資訊,請參閱臉部辨識概念指南或驗證 API 參考文件。For more information, see the Face recognition concepts guide or the Verify API reference documentation.

尋找類似臉部Find similar faces

「尋找類似項目 API」會比較目標臉部和一組候選臉部,以尋找看起來與目標臉部相似的一小組臉部。The Find Similar API compares a target face with a set of candidate faces to find a smaller set of faces that look similar to the target face. 目前支援 matchPerson 和 matchFace 兩種工作模式。Two working modes, matchPerson and matchFace, are supported. matchPerson 模式會在使用驗證 API 篩選出相同人員後,傳回類似的臉部。The matchPerson mode returns similar faces after it filters for the same person by using the Verify API. matchFace 模式會忽略相同人員的篩選。The matchFace mode ignores the same-person filter. 它會傳回不一定屬於同一人的類似候選臉部清單。It returns a list of similar candidate faces that might or might not belong to the same person.

下列範例顯示目標臉部:The following example shows the target face:


而這些是候選臉部:And these are the candidate faces:


在尋找四個相似的臉部時,matchPerson 模式會傳回 a 和 b,因為它們顯示的是與目標臉部相同的人員。To find four similar faces, the matchPerson mode returns a and b, which show the same person as the target face. matchFace 模式會傳回 a、b、c 和 d 四個候選項目,不過某些項目不是與目標相同的人員,或是相似度較低。The matchFace mode returns a, b, c, and d, exactly four candidates, even if some aren't the same person as the target or have low similarity. 如需詳細資訊,請參閱臉部辨識概念指南或尋找類似項目 API 參考文件。For more information, see the Face recognition concepts guide or the Find Similar API reference documentation.

臉部分組Face grouping

群組 API 會根據相似度將一組陌生臉部分成數個群組。The Group API divides a set of unknown faces into several groups based on similarity. 每個群組都是與原始臉部集合不相連的適當子集。Each group is a disjoint proper subset of the original set of faces. 一個群組中的所有臉部很可能屬於相同的人員。All of the faces in a group are likely to belong to the same person. 一個人可以有多個不同的群組。There can be several different groups for a single person. 群組可由另一個因素來區分,例如表情。The groups are differentiated by another factor, such as expression, for example. 如需詳細資訊,請參閱臉部辨識概念指南或群組 API 參考文件。For more information, see the Face recognition concepts guide or the Group API reference documentation.

人員識別Person identification

識別 API 可用來識別對人員資料庫偵測出來的臉部。The Identify API is used to identify a detected face against a database of people. 對於相片管理軟體中的自動影像標記功能來說,此功能可能很實用。This feature might be useful for automatic image tagging in photo management software. 您可以事先建立資料庫,然後隨著時間加以編輯。You create the database in advance, and you can edit it over time.

下圖說明資料庫 "myfriends" 的範例。The following image shows an example of a database named "myfriends". 每個群組最多可包含一百萬個不同的人員物件。Each group can contain up to 1 million different person objects. 每個人員物件最多可以註冊 248 張臉。Each person object can have up to 248 faces registered.


建立及訓練資料庫之後,您即可對新偵測到臉部的群組執行識別作業。After you create and train a database, you can perform identification against the group with a new detected face. 如果臉部識別為群組中的人員,則會傳回人員物件。If the face is identified as a person in the group, the person object is returned.

如需人員識別的詳細資訊,請參閱臉部辨識概念指南或識別 API 參考文件。For more information about person identification, see the Face recognition concepts guide or the Identify API reference documentation.

使用容器Use containers

藉由在更接近資料的位置安裝標準化的 Docker 容器,從而使用臉部容器來偵測、辨識和識別臉部。Use the Face container to detect, recognize, and identify faces by installing a standardized Docker container closer to your data.

範例應用程式Sample apps

下列應用程式範例說明幾種使用「臉部 API」的方式:The following sample applications show a few ways to use the Face API:

資料隱私權和安全性Data privacy and security

和所有認知服務資源一樣,使用臉部服務的開發人員必須了解 Microsoft 對於客戶資料的政策。As with all of the Cognitive Services resources, developers who use the Face service must be aware of Microsoft's policies on customer data. 如需詳細資訊,請參閱 Microsoft 信任中心的認知服務頁面For more information, see the Cognitive Services page on the Microsoft Trust Center.

後續步驟Next steps

請依照快速入門實作程式碼中的臉部偵測案例:Follow a quickstart to implement a face-detection scenario in code: