Faces - Compare
Compare the similarity between two faces.
POST {endpoint}/contentunderstanding/faces:compare?api-version=2025-05-01-preview
URI Parameters
Name | In | Required | Type | Description |
---|---|---|---|---|
endpoint
|
path | True |
string (uri) |
Content Understanding service endpoint. |
api-version
|
query | True |
string minLength: 1 |
The API version to use for this operation. |
Request Header
Name | Required | Type | Description |
---|---|---|---|
x-ms-client-request-id |
string (uuid) |
An opaque, globally-unique, client-generated string identifier for the request. |
Request Body
Name | Required | Type | Description |
---|---|---|---|
faceSource1 | True |
First face to compare. |
|
faceSource2 | True |
Second face to compare. |
Responses
Name | Type | Description |
---|---|---|
200 OK |
The request has succeeded. |
|
Other Status Codes |
An unexpected error response. Headers x-ms-error-code: string |
Security
Ocp-Apim-Subscription-Key
Type:
apiKey
In:
header
OAuth2Auth
Type:
oauth2
Flow:
accessCode
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Token URL:
https://login.microsoftonline.com/common/oauth2/token
Scopes
Name | Description |
---|---|
https://cognitiveservices.azure.com/.default |
Examples
Compare the Similarity Between Two Faces
Sample request
POST {endpoint}/contentunderstanding/faces:compare?api-version=2025-05-01-preview
{
"faceSource1": {
"url": "https://mystorageaccount.blob.core.windows.net/images/faces/face1.jpg",
"targetBoundingBox": {
"left": 33,
"top": 73,
"width": 262,
"height": 324
}
},
"faceSource2": {
"data": "RXhhbXBsZSBGaWxl"
}
}
Sample response
{
"detectedFace1": {
"boundingBox": {
"left": 33,
"top": 73,
"width": 262,
"height": 324
}
},
"detectedFace2": {
"boundingBox": {
"left": 87,
"top": 96,
"width": 235,
"height": 345
}
},
"confidence": 0.95
}
Definitions
Name | Description |
---|---|
Azure. |
The error object. |
Azure. |
A response containing error details. |
Azure. |
An object containing more specific information about the error. As per Microsoft One API guidelines - https://github.com/microsoft/api-guidelines/blob/vNext/azure/Guidelines.md#handling-errors. |
Bounding |
Bounding box in an image. |
Compare |
Compare faces parameters. |
Compare |
Compare faces response. |
Detected |
Detected bounding box of an object. |
Face |
Input face source with an optional target bounding box. If not specified, the largest face will be used. |
Azure.Core.Foundations.Error
The error object.
Name | Type | Description |
---|---|---|
code |
string |
One of a server-defined set of error codes. |
details |
An array of details about specific errors that led to this reported error. |
|
innererror |
An object containing more specific information than the current object about the error. |
|
message |
string |
A human-readable representation of the error. |
target |
string |
The target of the error. |
Azure.Core.Foundations.ErrorResponse
A response containing error details.
Name | Type | Description |
---|---|---|
error |
The error object. |
Azure.Core.Foundations.InnerError
An object containing more specific information about the error. As per Microsoft One API guidelines - https://github.com/microsoft/api-guidelines/blob/vNext/azure/Guidelines.md#handling-errors.
Name | Type | Description |
---|---|---|
code |
string |
One of a server-defined set of error codes. |
innererror |
Inner error. |
BoundingBox
Bounding box in an image.
Name | Type | Description |
---|---|---|
height |
integer (int32) |
Height of the bounding box. |
left |
integer (int32) |
Left coordinate of the bounding box. |
top |
integer (int32) |
Top coordinate of the bounding box. |
width |
integer (int32) |
Width of the bounding box. |
CompareFacesParameters
Compare faces parameters.
Name | Type | Description |
---|---|---|
faceSource1 |
First face to compare. |
|
faceSource2 |
Second face to compare. |
CompareFacesResult
Compare faces response.
Name | Type | Description |
---|---|---|
confidence |
number (float) |
Confidence score of the face comparison. |
detectedFace1 |
Details of the first detected face. |
|
detectedFace2 |
Details of the second detected face. |
DetectedBoundingBox
Detected bounding box of an object.
Name | Type | Description |
---|---|---|
boundingBox |
Bounding box of the detected face. |
FaceSource
Input face source with an optional target bounding box. If not specified, the largest face will be used.
Name | Type | Description |
---|---|---|
data |
string (byte) |
Base64-encoded image data. Only one of url or data should be specified. |
imageReferenceId |
string |
User provided identifier for the source image. |
targetBoundingBox |
Bounding box specifying the region of interest. |
|
url |
string (uri) |
Image URL. Only one of url or data should be specified. |