Person Directory Operations - Add Person Face From Url

Add a face to a person (see Person Directory "Create Person") for face identification or verification.
To deal with an image containing multiple faces, input face can be specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face. No image will be stored. Only the extracted face feature(s) will be stored on server until Person Directory "Delete Person Face" or "Delete Person" is called.

Note that persistedFaceId is different from faceId generated by "Detect".

    • Each person entry can hold up to 248 faces.
    • Higher face image quality means better recognition precision. Please consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger.
    • JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed image file size is from 1KB to 6MB.
    • "targetFace" rectangle should contain one face. Zero or multiple faces will be regarded as an error. If the provided "targetFace" rectangle is not returned from "Detect", there's no guarantee to detect and add the face successfully.
    • Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or large occlusions will cause failures.
    • 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 here.
    • Adding/deleting faces to/from a same person will be processed sequentially. Adding/deleting faces to/from different persons are processed in parallel.
    • This is a long running operation. Use Response Header "Operation-Location" to determine when the AddFace operation has successfully propagated for future requests to "Identify". For further information about Operation-Locations see "Get Face Operation Status".
POST {endpoint}/face/{apiVersion}/persons/{personId}/recognitionModels/{recognitionModel}/persistedfaces
POST {endpoint}/face/{apiVersion}/persons/{personId}/recognitionModels/{recognitionModel}/persistedfaces?_overload=addPersonFaceFromUrl&targetFace={targetFace}&detectionModel={detectionModel}&userData={userData}

URI Parameters

Name In Required Type Description
apiVersion
path True

string

API Version

endpoint
path True

string

uri

Supported Cognitive Services endpoints (protocol and hostname, for example: https://{resource-name}.cognitiveservices.azure.com).

personId
path True

string

uuid

Person ID of the person.

recognitionModel
path True

RecognitionModel

The 'recognitionModel' associated with faces.

detectionModel
query

DetectionModel

The 'detectionModel' associated with the detected faceIds. Supported 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default value is 'detection_01'.

targetFace
query

integer[]

A face rectangle to specify the target face to be added to a person, in the format of 'targetFace=left,top,width,height'.

userData
query

string

User-provided data attached to the face. The size limit is 1K.

Request Body

Name Required Type Description
url True

string

URL of input image.

Responses

Name Type Description
202 Accepted

AddFaceResult

A successful call returns an empty response body. The service has accepted the request and will start processing soon. The client can query the operation status and result using the URL specified in the 'Operation-Location' response header. The URL expires in 48 hours.

Headers

  • Location: string
  • operation-Location: string
Other Status Codes

FaceErrorResponse

An unexpected error response.

Headers

x-ms-error-code: string

Security

Ocp-Apim-Subscription-Key

The secret key for your Azure AI Face subscription.

Type: apiKey
In: header

AADToken

The Azure Active Directory OAuth2 Flow

Type: oauth2
Flow: accessCode
Authorization URL: https://api.example.com/oauth2/authorize
Token URL: https://api.example.com/oauth2/token

Scopes

Name Description
https://cognitiveservices.azure.com/.default

Examples

Add Face to PersonDirectory Person from Url

Sample request

POST {endpoint}/face/v1.2-preview.1/persons/85c0c630-c9c9-40f8-8a4e-f9ae4f926ea5/recognitionModels/recognition_01/persistedfaces?_overload=addPersonFaceFromUrl&targetFace=10,10,100,100&detectionModel=detection_01&userData=your_user_data

{
  "url": "https://microsoft.com/example.jpg"
}

Sample response

location: https://contoso.com/operationstatus
operation-Location: https://contoso.com/operationstatus
{
  "persistedFaceId": "43897a75-8d6f-42cf-885e-74832febb055"
}

Definitions

Name Description
AddFaceResult

Response body for adding face.

DetectionModel

The 'detectionModel' associated with the detected faceIds. Supported 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default value is 'detection_01'.

FaceError

The error object. For comprehensive details on error codes and messages returned by the Face Service, please refer to the following link: https://aka.ms/face-error-codes-and-messages.

FaceErrorResponse

A response containing error details.

RecognitionModel

The recognition model for the face.

AddFaceResult

Response body for adding face.

Name Type Description
persistedFaceId

string

Persisted Face ID of the added face, which is persisted and will not expire. Different from faceId which is created in "Detect" and will expire in 24 hours after the detection call.

DetectionModel

The 'detectionModel' associated with the detected faceIds. Supported 'detectionModel' values include 'detection_01', 'detection_02' and 'detection_03'. The default value is 'detection_01'.

Name Type Description
detection_01

string

The default detection model. Recommend for near frontal face detection. For scenarios with exceptionally large angle (head-pose) faces, occluded faces or wrong image orientation, the faces in such cases may not be detected.

detection_02

string

Detection model released in 2019 May with improved accuracy especially on small, side and blurry faces.

detection_03

string

Detection model released in 2021 February with improved accuracy especially on small faces.

FaceError

The error object. For comprehensive details on error codes and messages returned by the Face Service, please refer to the following link: https://aka.ms/face-error-codes-and-messages.

Name Type Description
code

string

One of a server-defined set of error codes.

message

string

A human-readable representation of the error.

FaceErrorResponse

A response containing error details.

Name Type Description
error

FaceError

The error object.

RecognitionModel

The recognition model for the face.

Name Type Description
recognition_01

string

The default recognition model for "Detect". All those faceIds created before 2019 March are bonded with this recognition model.

recognition_02

string

Recognition model released in 2019 March.

recognition_03

string

Recognition model released in 2020 May.

recognition_04

string

Recognition model released in 2021 February. It's recommended to use this recognition model for better recognition accuracy.