FaceClient.VerifyFaceToFaceAsync Method

Definition

Overloads

VerifyFaceToFaceAsync(RequestContent, RequestContext)

[Protocol Method] Verify whether two faces belong to a same person.

VerifyFaceToFaceAsync(Guid, Guid, CancellationToken)

Verify whether two faces belong to a same person.

VerifyFaceToFaceAsync(RequestContent, RequestContext)

Source:
FaceClient.cs

[Protocol Method] Verify whether two faces belong to a same person.

public virtual System.Threading.Tasks.Task<Azure.Response> VerifyFaceToFaceAsync (Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member VerifyFaceToFaceAsync : Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.VerifyFaceToFaceAsync : Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function VerifyFaceToFaceAsync (content As RequestContent, Optional context As RequestContext = Nothing) As Task(Of Response)

Parameters

content
RequestContent

The content to send as the body of the request.

context
RequestContext

The request context, which can override default behaviors of the client pipeline on a per-call basis.

Returns

The response returned from the service.

Exceptions

content is null.

Service returned a non-success status code.

Examples

This sample shows how to call VerifyFaceToFaceAsync and parse the result.

Uri endpoint = new Uri("<https://my-service.azure.com>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
FaceClient client = new FaceClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    faceId1 = "73f411fe-4f43-4b4b-9cbd-6828d8f4cf9a",
    faceId2 = "73f411fe-4f43-4b4b-9cbd-6828d8f4cf9a",
});
Response response = await client.VerifyFaceToFaceAsync(content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("isIdentical").ToString());
Console.WriteLine(result.GetProperty("confidence").ToString());

This sample shows how to call VerifyFaceToFaceAsync with all request content and parse the result.

Uri endpoint = new Uri("<https://my-service.azure.com>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
FaceClient client = new FaceClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    faceId1 = "73f411fe-4f43-4b4b-9cbd-6828d8f4cf9a",
    faceId2 = "73f411fe-4f43-4b4b-9cbd-6828d8f4cf9a",
});
Response response = await client.VerifyFaceToFaceAsync(content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("isIdentical").ToString());
Console.WriteLine(result.GetProperty("confidence").ToString());

Applies to

VerifyFaceToFaceAsync(Guid, Guid, CancellationToken)

Source:
FaceClient.cs

Verify whether two faces belong to a same person.

public virtual System.Threading.Tasks.Task<Azure.Response<Azure.AI.Vision.Face.FaceVerificationResult>> VerifyFaceToFaceAsync (Guid faceId1, Guid faceId2, System.Threading.CancellationToken cancellationToken = default);
abstract member VerifyFaceToFaceAsync : Guid * Guid * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.AI.Vision.Face.FaceVerificationResult>>
override this.VerifyFaceToFaceAsync : Guid * Guid * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.AI.Vision.Face.FaceVerificationResult>>
Public Overridable Function VerifyFaceToFaceAsync (faceId1 As Guid, faceId2 As Guid, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of FaceVerificationResult))

Parameters

faceId1
Guid

The faceId of one face, come from "Detect".

faceId2
Guid

The faceId of another face, come from "Detect".

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Examples

This sample shows how to call VerifyFaceToFaceAsync.

Uri endpoint = new Uri("<https://my-service.azure.com>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
FaceClient client = new FaceClient(endpoint, credential);

Response<FaceVerificationResult> response = await client.VerifyFaceToFaceAsync(Guid.Parse("73f411fe-4f43-4b4b-9cbd-6828d8f4cf9a"), Guid.Parse("73f411fe-4f43-4b4b-9cbd-6828d8f4cf9a"));

This sample shows how to call VerifyFaceToFaceAsync with all parameters.

Uri endpoint = new Uri("<https://my-service.azure.com>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
FaceClient client = new FaceClient(endpoint, credential);

Response<FaceVerificationResult> response = await client.VerifyFaceToFaceAsync(Guid.Parse("73f411fe-4f43-4b4b-9cbd-6828d8f4cf9a"), Guid.Parse("73f411fe-4f43-4b4b-9cbd-6828d8f4cf9a"));

Remarks

> [!NOTE] > > * > * 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 both faces should be the same.

Applies to