Person Group Operations - Add Person Group Person Face From Url

Add a face to a person into a Person Group 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 "Delete Person Group Person Face", "Delete Person Group Person" or "Delete Person Group" 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.
POST {endpoint}/face/{apiVersion}/persongroups/{personGroupId}/persons/{personId}/persistedfaces
POST {endpoint}/face/{apiVersion}/persongroups/{personGroupId}/persons/{personId}/persistedfaces?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).

personGroupId
path True

string

ID of the container.

Regex pattern: ^[a-z0-9-_]+$

personId
path True

string

uuid

ID of the person.

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
200 OK

AddFaceResult

A successful call returns a new persistedFaceId.

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 PersonGroupPerson from Url

Sample request

POST {endpoint}/face/v1.2-preview.1/persongroups/your_person_group_id/persons/25985303-c537-4467-b41d-bdb45cd95ca1/persistedfaces?targetFace=10,10,100,100&detectionModel=detection_01&userData=your_user_data

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

Sample response

{
  "persistedFaceId": "43897a75-8d6f-42cf-885e-74832febb055"
}

Definitions

Name Description
AddFaceFromUrlRequest

Add face from url request.

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.

AddFaceFromUrlRequest

Add face from url request.

Name Type Description
url

string

URL of input image.

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.