Face class

Class representing a Face.

Constructors

Face(FaceClientContext)

Create a Face.

Methods

detectWithStream(HttpRequestBody, FaceDetectWithStreamOptionalParams)

Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, and attributes.

  • No image will be stored. Only the extracted face feature will be stored on server. The faceId is an identifier of the face feature and will be used in Face - Identify, Face - Verify, and Face - Find Similar. The stored face feature(s) will expire and be deleted at the time specified by faceIdTimeToLive after the original detection call.
  • Optional parameters include faceId, landmarks, and attributes. Attributes include age, gender, headPose, smile, facialHair, glasses, emotion, hair, makeup, occlusion, accessories, blur, exposure, noise, mask, and qualityForRecognition. Some of the results returned for specific attributes may not be highly accurate.
  • JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed image file size is from 1KB to 6MB.
  • Up to 100 faces can be returned for an image. Faces are ranked by face rectangle size from large to small.
  • For optimal results when querying Face - Identify, Face - Verify, and Face - Find Similar ('returnFaceId' is true), please use faces that are: frontal, clear, and with a minimum size of 200x200 pixels (100 pixels between eyes).
  • The minimum detectable face size is 36x36 pixels in an image no larger than 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will need a proportionally larger minimum face size.
  • Different 'detectionModel' values can be provided. To use and compare different detection models, please refer to How to specify a detection model
  • Different 'recognitionModel' values are provided. If follow-up operations like Verify, Identify, Find Similar are needed, please specify the recognition model with 'recognitionModel' parameter. The default value for 'recognitionModel' is 'recognition_01', if latest model needed, please explicitly specify the model you need in this parameter. Once specified, the detected faceIds will be associated with the specified recognition model. More details, please refer to Specify a recognition model.
detectWithStream(HttpRequestBody, FaceDetectWithStreamOptionalParams, ServiceCallback<DetectedFace[]>)
detectWithStream(HttpRequestBody, ServiceCallback<DetectedFace[]>)
detectWithUrl(string, FaceDetectWithUrlOptionalParams)

Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, and attributes.

  • No image will be stored. Only the extracted face feature will be stored on server. The faceId is an identifier of the face feature and will be used in Face - Identify, Face - Verify, and Face - Find Similar. The stored face feature(s) will expire and be deleted at the time specified by faceIdTimeToLive after the original detection call.

  • Optional parameters include faceId, landmarks, and attributes. Attributes include age, gender, headPose, smile, facialHair, glasses, emotion, hair, makeup, occlusion, accessories, blur, exposure, noise, mask, and qualityForRecognition. Some of the results returned for specific attributes may not be highly accurate.

  • JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed image file size is from 1KB to 6MB.

  • Up to 100 faces can be returned for an image. Faces are ranked by face rectangle size from large to small.

  • For optimal results when querying Face - Identify, Face - Verify, and Face - Find Similar ('returnFaceId' is true), please use faces that are: frontal, clear, and with a minimum size of 200x200 pixels (100 pixels between eyes).

  • The minimum detectable face size is 36x36 pixels in an image no larger than 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will need a proportionally larger minimum face size.

  • Different 'detectionModel' values can be provided. To use and compare different detection models, please refer to How to specify a detection model.

  • Different 'recognitionModel' values are provided. If follow-up operations like Verify, Identify, Find Similar are needed, please specify the recognition model with 'recognitionModel' parameter. The default value for 'recognitionModel' is 'recognition_01', if latest model needed, please explicitly specify the model you need in this parameter. Once specified, the detected faceIds will be associated with the specified recognition model. More details, please refer to Specify a recognition model.

detectWithUrl(string, FaceDetectWithUrlOptionalParams, ServiceCallback<DetectedFace[]>)
detectWithUrl(string, ServiceCallback<DetectedFace[]>)
findSimilar(string, FaceFindSimilarOptionalParams)

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.

findSimilar(string, FaceFindSimilarOptionalParams, ServiceCallback<SimilarFace[]>)
findSimilar(string, ServiceCallback<SimilarFace[]>)
group(string[], RequestOptionsBase)

Divide candidate faces into groups based on face similarity.

  • The output is one or more disjointed face groups and a messyGroup. A face group contains faces that have similar looking, often of the same person. Face groups are ranked by group size, i.e. number of faces. Notice that faces belonging to a same person might be split into several groups in the result.
  • MessyGroup is a special face group containing faces that cannot find any similar counterpart face from original faces. The messyGroup will not appear in the result if all faces found their counterparts.
  • Group API needs at least 2 candidate faces and 1000 at most. We suggest to try Face - Verify when you only have 2 candidate faces.
  • The 'recognitionModel' associated with the query faces' faceIds should be the same.
group(string[], RequestOptionsBase, ServiceCallback<GroupResult>)
group(string[], ServiceCallback<GroupResult>)
identify(string[], FaceIdentifyOptionalParams)

1-to-many identification to find the closest matches of the specific query person face from a person group or large person group.
For each face in the faceIds array, Face Identify will compute similarities between the query face and all the faces in the person group (given by personGroupId) or large person group (given by largePersonGroupId), and return candidate person(s) for that face ranked by similarity confidence. The person group/large person group should be trained to make it ready for identification. See more in PersonGroup - Train and LargePersonGroup - Train.

Remarks:

  • The algorithm allows more than one face to be identified independently at the same request, but no more than 10 faces.
  • Each person in the person group/large person group could have more than one face, but no more than 248 faces.
  • Higher face image quality means better identification precision. Please consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger.
  • Number of candidates returned is restricted by maxNumOfCandidatesReturned and confidenceThreshold. If no person is identified, the returned candidates will be an empty array.
  • Try Face - Find Similar when you need to find similar faces from a face list/large face list instead of a person group/large person group.
  • The 'recognitionModel' associated with the query faces' faceIds should be the same as the 'recognitionModel' used by the target person group or large person group.
identify(string[], FaceIdentifyOptionalParams, ServiceCallback<IdentifyResult[]>)
identify(string[], ServiceCallback<IdentifyResult[]>)
verifyFaceToFace(string, string, RequestOptionsBase)

Verify whether two faces belong to a same person or whether one face belongs to a person.
Remarks:

  • Higher face image quality means better identification precision. Please consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger.
  • For the scenarios that are sensitive to accuracy please make your own judgment.
  • The 'recognitionModel' associated with the query faces' faceIds should be the same as the 'recognitionModel' used by the target face, person group or large person group.
verifyFaceToFace(string, string, RequestOptionsBase, ServiceCallback<VerifyResult>)
verifyFaceToFace(string, string, ServiceCallback<VerifyResult>)
verifyFaceToPerson(string, string, FaceVerifyFaceToPersonOptionalParams)

Verify whether two faces belong to a same person. Compares a face Id with a Person Id

verifyFaceToPerson(string, string, FaceVerifyFaceToPersonOptionalParams, ServiceCallback<VerifyResult>)
verifyFaceToPerson(string, string, ServiceCallback<VerifyResult>)

Constructor Details

Face(FaceClientContext)

Create a Face.

new Face(client: FaceClientContext)

Parameters

client
FaceClientContext

Reference to the service client.

Method Details

detectWithStream(HttpRequestBody, FaceDetectWithStreamOptionalParams)

Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, and attributes.

  • No image will be stored. Only the extracted face feature will be stored on server. The faceId is an identifier of the face feature and will be used in Face - Identify, Face - Verify, and Face - Find Similar. The stored face feature(s) will expire and be deleted at the time specified by faceIdTimeToLive after the original detection call.
  • Optional parameters include faceId, landmarks, and attributes. Attributes include age, gender, headPose, smile, facialHair, glasses, emotion, hair, makeup, occlusion, accessories, blur, exposure, noise, mask, and qualityForRecognition. Some of the results returned for specific attributes may not be highly accurate.
  • JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed image file size is from 1KB to 6MB.
  • Up to 100 faces can be returned for an image. Faces are ranked by face rectangle size from large to small.
  • For optimal results when querying Face - Identify, Face - Verify, and Face - Find Similar ('returnFaceId' is true), please use faces that are: frontal, clear, and with a minimum size of 200x200 pixels (100 pixels between eyes).
  • The minimum detectable face size is 36x36 pixels in an image no larger than 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will need a proportionally larger minimum face size.
  • Different 'detectionModel' values can be provided. To use and compare different detection models, please refer to How to specify a detection model
  • Different 'recognitionModel' values are provided. If follow-up operations like Verify, Identify, Find Similar are needed, please specify the recognition model with 'recognitionModel' parameter. The default value for 'recognitionModel' is 'recognition_01', if latest model needed, please explicitly specify the model you need in this parameter. Once specified, the detected faceIds will be associated with the specified recognition model. More details, please refer to Specify a recognition model.
function detectWithStream(image: HttpRequestBody, options?: FaceDetectWithStreamOptionalParams): Promise<FaceDetectWithStreamResponse>

Parameters

image
HttpRequestBody

An image stream.

options
FaceDetectWithStreamOptionalParams

The optional parameters

Returns

Promise<Models.FaceDetectWithStreamResponse>

detectWithStream(HttpRequestBody, FaceDetectWithStreamOptionalParams, ServiceCallback<DetectedFace[]>)

function detectWithStream(image: HttpRequestBody, options: FaceDetectWithStreamOptionalParams, callback: ServiceCallback<DetectedFace[]>)

Parameters

image
HttpRequestBody

An image stream.

options
FaceDetectWithStreamOptionalParams

The optional parameters

callback

ServiceCallback<DetectedFace[]>

The callback

detectWithStream(HttpRequestBody, ServiceCallback<DetectedFace[]>)

function detectWithStream(image: HttpRequestBody, callback: ServiceCallback<DetectedFace[]>)

Parameters

image
HttpRequestBody

An image stream.

callback

ServiceCallback<DetectedFace[]>

The callback

detectWithUrl(string, FaceDetectWithUrlOptionalParams)

Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, and attributes.

  • No image will be stored. Only the extracted face feature will be stored on server. The faceId is an identifier of the face feature and will be used in Face - Identify, Face - Verify, and Face - Find Similar. The stored face feature(s) will expire and be deleted at the time specified by faceIdTimeToLive after the original detection call.

  • Optional parameters include faceId, landmarks, and attributes. Attributes include age, gender, headPose, smile, facialHair, glasses, emotion, hair, makeup, occlusion, accessories, blur, exposure, noise, mask, and qualityForRecognition. Some of the results returned for specific attributes may not be highly accurate.

  • JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed image file size is from 1KB to 6MB.

  • Up to 100 faces can be returned for an image. Faces are ranked by face rectangle size from large to small.

  • For optimal results when querying Face - Identify, Face - Verify, and Face - Find Similar ('returnFaceId' is true), please use faces that are: frontal, clear, and with a minimum size of 200x200 pixels (100 pixels between eyes).

  • The minimum detectable face size is 36x36 pixels in an image no larger than 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will need a proportionally larger minimum face size.

  • Different 'detectionModel' values can be provided. To use and compare different detection models, please refer to How to specify a detection model.

  • Different 'recognitionModel' values are provided. If follow-up operations like Verify, Identify, Find Similar are needed, please specify the recognition model with 'recognitionModel' parameter. The default value for 'recognitionModel' is 'recognition_01', if latest model needed, please explicitly specify the model you need in this parameter. Once specified, the detected faceIds will be associated with the specified recognition model. More details, please refer to Specify a recognition model.

function detectWithUrl(url: string, options?: FaceDetectWithUrlOptionalParams): Promise<FaceDetectWithUrlResponse>

Parameters

url

string

Publicly reachable URL of an image

options
FaceDetectWithUrlOptionalParams

The optional parameters

Returns

Promise<Models.FaceDetectWithUrlResponse>

detectWithUrl(string, FaceDetectWithUrlOptionalParams, ServiceCallback<DetectedFace[]>)

function detectWithUrl(url: string, options: FaceDetectWithUrlOptionalParams, callback: ServiceCallback<DetectedFace[]>)

Parameters

url

string

Publicly reachable URL of an image

options
FaceDetectWithUrlOptionalParams

The optional parameters

callback

ServiceCallback<DetectedFace[]>

The callback

detectWithUrl(string, ServiceCallback<DetectedFace[]>)

function detectWithUrl(url: string, callback: ServiceCallback<DetectedFace[]>)

Parameters

url

string

Publicly reachable URL of an image

callback

ServiceCallback<DetectedFace[]>

The callback

findSimilar(string, FaceFindSimilarOptionalParams)

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.

function findSimilar(faceId: string, options?: FaceFindSimilarOptionalParams): Promise<FaceFindSimilarResponse>

Parameters

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

options
FaceFindSimilarOptionalParams

The optional parameters

Returns

Promise<Models.FaceFindSimilarResponse>

findSimilar(string, FaceFindSimilarOptionalParams, ServiceCallback<SimilarFace[]>)

function findSimilar(faceId: string, options: FaceFindSimilarOptionalParams, callback: ServiceCallback<SimilarFace[]>)

Parameters

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

options
FaceFindSimilarOptionalParams

The optional parameters

callback

ServiceCallback<SimilarFace[]>

The callback

findSimilar(string, ServiceCallback<SimilarFace[]>)

function findSimilar(faceId: string, callback: ServiceCallback<SimilarFace[]>)

Parameters

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

callback

ServiceCallback<SimilarFace[]>

The callback

group(string[], RequestOptionsBase)

Divide candidate faces into groups based on face similarity.

  • The output is one or more disjointed face groups and a messyGroup. A face group contains faces that have similar looking, often of the same person. Face groups are ranked by group size, i.e. number of faces. Notice that faces belonging to a same person might be split into several groups in the result.
  • MessyGroup is a special face group containing faces that cannot find any similar counterpart face from original faces. The messyGroup will not appear in the result if all faces found their counterparts.
  • Group API needs at least 2 candidate faces and 1000 at most. We suggest to try Face - Verify when you only have 2 candidate faces.
  • The 'recognitionModel' associated with the query faces' faceIds should be the same.
function group(faceIds: string[], options?: RequestOptionsBase): Promise<FaceGroupResponse>

Parameters

faceIds

string[]

Array of candidate faceId created by Face - Detect. The maximum is 1000 faces

options
RequestOptionsBase

The optional parameters

Returns

Promise<Models.FaceGroupResponse>

group(string[], RequestOptionsBase, ServiceCallback<GroupResult>)

function group(faceIds: string[], options: RequestOptionsBase, callback: ServiceCallback<GroupResult>)

Parameters

faceIds

string[]

Array of candidate faceId created by Face - Detect. The maximum is 1000 faces

options
RequestOptionsBase

The optional parameters

callback

ServiceCallback<GroupResult>

The callback

group(string[], ServiceCallback<GroupResult>)

function group(faceIds: string[], callback: ServiceCallback<GroupResult>)

Parameters

faceIds

string[]

Array of candidate faceId created by Face - Detect. The maximum is 1000 faces

callback

ServiceCallback<GroupResult>

The callback

identify(string[], FaceIdentifyOptionalParams)

1-to-many identification to find the closest matches of the specific query person face from a person group or large person group.
For each face in the faceIds array, Face Identify will compute similarities between the query face and all the faces in the person group (given by personGroupId) or large person group (given by largePersonGroupId), and return candidate person(s) for that face ranked by similarity confidence. The person group/large person group should be trained to make it ready for identification. See more in PersonGroup - Train and LargePersonGroup - Train.

Remarks:

  • The algorithm allows more than one face to be identified independently at the same request, but no more than 10 faces.
  • Each person in the person group/large person group could have more than one face, but no more than 248 faces.
  • Higher face image quality means better identification precision. Please consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger.
  • Number of candidates returned is restricted by maxNumOfCandidatesReturned and confidenceThreshold. If no person is identified, the returned candidates will be an empty array.
  • Try Face - Find Similar when you need to find similar faces from a face list/large face list instead of a person group/large person group.
  • The 'recognitionModel' associated with the query faces' faceIds should be the same as the 'recognitionModel' used by the target person group or large person group.
function identify(faceIds: string[], options?: FaceIdentifyOptionalParams): Promise<FaceIdentifyResponse>

Parameters

faceIds

string[]

Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10].

options
FaceIdentifyOptionalParams

The optional parameters

Returns

Promise<Models.FaceIdentifyResponse>

identify(string[], FaceIdentifyOptionalParams, ServiceCallback<IdentifyResult[]>)

function identify(faceIds: string[], options: FaceIdentifyOptionalParams, callback: ServiceCallback<IdentifyResult[]>)

Parameters

faceIds

string[]

Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10].

options
FaceIdentifyOptionalParams

The optional parameters

callback

ServiceCallback<IdentifyResult[]>

The callback

identify(string[], ServiceCallback<IdentifyResult[]>)

function identify(faceIds: string[], callback: ServiceCallback<IdentifyResult[]>)

Parameters

faceIds

string[]

Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10].

callback

ServiceCallback<IdentifyResult[]>

The callback

verifyFaceToFace(string, string, RequestOptionsBase)

Verify whether two faces belong to a same person or whether one face belongs to a person.
Remarks:

  • Higher face image quality means better identification precision. Please consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger.
  • For the scenarios that are sensitive to accuracy please make your own judgment.
  • The 'recognitionModel' associated with the query faces' faceIds should be the same as the 'recognitionModel' used by the target face, person group or large person group.
function verifyFaceToFace(faceId1: string, faceId2: string, options?: RequestOptionsBase): Promise<FaceVerifyFaceToFaceResponse>

Parameters

faceId1

string

FaceId of the first face, comes from Face - Detect

faceId2

string

FaceId of the second face, comes from Face - Detect

options
RequestOptionsBase

The optional parameters

Returns

Promise<Models.FaceVerifyFaceToFaceResponse>

verifyFaceToFace(string, string, RequestOptionsBase, ServiceCallback<VerifyResult>)

function verifyFaceToFace(faceId1: string, faceId2: string, options: RequestOptionsBase, callback: ServiceCallback<VerifyResult>)

Parameters

faceId1

string

FaceId of the first face, comes from Face - Detect

faceId2

string

FaceId of the second face, comes from Face - Detect

options
RequestOptionsBase

The optional parameters

callback

ServiceCallback<VerifyResult>

The callback

verifyFaceToFace(string, string, ServiceCallback<VerifyResult>)

function verifyFaceToFace(faceId1: string, faceId2: string, callback: ServiceCallback<VerifyResult>)

Parameters

faceId1

string

FaceId of the first face, comes from Face - Detect

faceId2

string

FaceId of the second face, comes from Face - Detect

callback

ServiceCallback<VerifyResult>

The callback

verifyFaceToPerson(string, string, FaceVerifyFaceToPersonOptionalParams)

Verify whether two faces belong to a same person. Compares a face Id with a Person Id

function verifyFaceToPerson(faceId: string, personId: string, options?: FaceVerifyFaceToPersonOptionalParams): Promise<FaceVerifyFaceToPersonResponse>

Parameters

faceId

string

FaceId of the face, comes from Face - Detect

personId

string

Specify a certain person in a person group or a large person group. personId is created in PersonGroup Person - Create or LargePersonGroup Person - Create.

options
FaceVerifyFaceToPersonOptionalParams

The optional parameters

Returns

Promise<Models.FaceVerifyFaceToPersonResponse>

verifyFaceToPerson(string, string, FaceVerifyFaceToPersonOptionalParams, ServiceCallback<VerifyResult>)

function verifyFaceToPerson(faceId: string, personId: string, options: FaceVerifyFaceToPersonOptionalParams, callback: ServiceCallback<VerifyResult>)

Parameters

faceId

string

FaceId of the face, comes from Face - Detect

personId

string

Specify a certain person in a person group or a large person group. personId is created in PersonGroup Person - Create or LargePersonGroup Person - Create.

options
FaceVerifyFaceToPersonOptionalParams

The optional parameters

callback

ServiceCallback<VerifyResult>

The callback

verifyFaceToPerson(string, string, ServiceCallback<VerifyResult>)

function verifyFaceToPerson(faceId: string, personId: string, callback: ServiceCallback<VerifyResult>)

Parameters

faceId

string

FaceId of the face, comes from Face - Detect

personId

string

Specify a certain person in a person group or a large person group. personId is created in PersonGroup Person - Create or LargePersonGroup Person - Create.

callback

ServiceCallback<VerifyResult>

The callback