Face - Find Similar

Given query face's faceId, to search the similar-looking faces from a faceId array, a face list or a large face list. faceId array contains the faces created by Face - Detect With Url or Face - Detect With Stream, which will expire at the time specified by faceIdTimeToLive after creation. A "faceListId" is created by FaceList - Create containing persistedFaceIds that will not expire. And a "largeFaceListId" is created by LargeFaceList - Create containing persistedFaceIds that will also not expire. Depending on the input the returned similar faces list contains faceIds or persistedFaceIds ranked by similarity.
Find similar has two working modes, "matchPerson" and "matchFace". "matchPerson" is the default mode that it tries to find faces of the same person as possible by using internal same-person thresholds. It is useful to find a known person's other photos. Note that an empty list will be returned if no faces pass the internal thresholds. "matchFace" mode ignores same-person thresholds and returns ranked similar faces anyway, even the similarity is low. It can be used in the cases like searching celebrity-looking faces.
The 'recognitionModel' associated with the query face's faceId should be the same as the 'recognitionModel' used by the target faceId array, face list or large face list.

POST {Endpoint}/face/v1.0/findsimilars

URI Parameters

Name In Required Type Description
Endpoint
path True

string

Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com).

Request Header

Name Required Type Description
Ocp-Apim-Subscription-Key True

string

Request Body

Name Required Type Description
faceId True

string

FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire at the time specified by faceIdTimeToLive after the detection call

faceIds

string[]

An array of candidate faceIds. All of them are created by Face - Detect and the faceIds will expire at the time specified by faceIdTimeToLive after the detection call. The number of faceIds is limited to 1000. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time.

faceListId

string

An existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time.

largeFaceListId

string

An existing user-specified unique candidate large face list, created in LargeFaceList - Create. Large face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time.

maxNumOfCandidatesReturned

integer

The number of top similar faces returned. The valid range is [1, 1000].

mode

FindSimilarMatchMode

Similar face searching mode. It can be "matchPerson" or "matchFace".

Responses

Name Type Description
200 OK

SimilarFace[]

A successful call returns an array of the most similar faces represented in faceId if the input parameter is faceIds or persistedFaceId if the input parameter is faceListId.

Other Status Codes

APIError

Error response.

Security

Ocp-Apim-Subscription-Key

Type: apiKey
In: header

Examples

Find similar results example

Sample Request

POST {Endpoint}/face/v1.0/findsimilars


{
  "faceId": "c5c24a82-6845-4031-9d5d-978df9175426",
  "largeFaceListId": "sample_list",
  "maxNumOfCandidatesReturned": 1,
  "mode": "matchPerson"
}

Sample Response

[
  {
    "persistedFaceId": "015839fb-fbd9-4f79-ace9-7675fc2f1dd9",
    "confidence": 0.82
  }
]

Definitions

Name Description
APIError

Error information returned by the API

Error

Error body.

FindSimilarMatchMode

Similar face searching mode. It can be "matchPerson" or "matchFace".

FindSimilarRequest

Request body for find similar operation.

SimilarFace

Response body for find similar face operation.

APIError

Error information returned by the API

Name Type Description
error

Error

Error body.

Error

Error body.

Name Type Description
code

string

message

string

FindSimilarMatchMode

Similar face searching mode. It can be "matchPerson" or "matchFace".

Name Type Description
matchFace

string

matchPerson

string

FindSimilarRequest

Request body for find similar operation.

Name Type Default Value Description
faceId

string

FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire at the time specified by faceIdTimeToLive after the detection call

faceIds

string[]

An array of candidate faceIds. All of them are created by Face - Detect and the faceIds will expire at the time specified by faceIdTimeToLive after the detection call. The number of faceIds is limited to 1000. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time.

faceListId

string

An existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time.

largeFaceListId

string

An existing user-specified unique candidate large face list, created in LargeFaceList - Create. Large face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time.

maxNumOfCandidatesReturned

integer

20

The number of top similar faces returned. The valid range is [1, 1000].

mode

FindSimilarMatchMode

matchPerson

Similar face searching mode. It can be "matchPerson" or "matchFace".

SimilarFace

Response body for find similar face operation.

Name Type Description
confidence

number

Similarity confidence of the candidate face. The higher confidence, the more similar. Range between [0,1].

faceId

string

FaceId of candidate face when find by faceIds. faceId is created by Face - Detect and will expire at the time specified by faceIdTimeToLive after the detection call

persistedFaceId

string

PersistedFaceId of candidate face when find by faceListId. persistedFaceId in face list is persisted and will not expire. As showed in below response