FaceClient.GroupAsync Method

Definition

Overloads

GroupAsync(RequestContent, RequestContext)

[Protocol Method] Divide candidate faces into groups based on face similarity.

GroupAsync(IEnumerable<Guid>, CancellationToken)

Divide candidate faces into groups based on face similarity.

GroupAsync(RequestContent, RequestContext)

Source:
FaceClient.cs

[Protocol Method] Divide candidate faces into groups based on face similarity.

public virtual System.Threading.Tasks.Task<Azure.Response> GroupAsync (Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member GroupAsync : Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.GroupAsync : Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function GroupAsync (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 GroupAsync 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
{
    faceIds = new object[]
    {
        "73f411fe-4f43-4b4b-9cbd-6828d8f4cf9a"
    },
});
Response response = await client.GroupAsync(content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("groups")[0][0].ToString());
Console.WriteLine(result.GetProperty("messyGroup")[0].ToString());

This sample shows how to call GroupAsync 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
{
    faceIds = new object[]
    {
        "73f411fe-4f43-4b4b-9cbd-6828d8f4cf9a"
    },
});
Response response = await client.GroupAsync(content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("groups")[0][0].ToString());
Console.WriteLine(result.GetProperty("messyGroup")[0].ToString());

Applies to

GroupAsync(IEnumerable<Guid>, CancellationToken)

Source:
FaceClient.cs

Divide candidate faces into groups based on face similarity.

public virtual System.Threading.Tasks.Task<Azure.Response<Azure.AI.Vision.Face.FaceGroupingResult>> GroupAsync (System.Collections.Generic.IEnumerable<Guid> faceIds, System.Threading.CancellationToken cancellationToken = default);
abstract member GroupAsync : seq<Guid> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.AI.Vision.Face.FaceGroupingResult>>
override this.GroupAsync : seq<Guid> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.AI.Vision.Face.FaceGroupingResult>>
Public Overridable Function GroupAsync (faceIds As IEnumerable(Of Guid), Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of FaceGroupingResult))

Parameters

faceIds
IEnumerable<Guid>

Array of candidate faceIds created by "Detect". The maximum is 1000 faces.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

faceIds is null.

Examples

This sample shows how to call GroupAsync.

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

Response<FaceGroupingResult> response = await client.GroupAsync(new Guid[] { Guid.Parse("73f411fe-4f43-4b4b-9cbd-6828d8f4cf9a") });

This sample shows how to call GroupAsync with all parameters.

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

Response<FaceGroupingResult> response = await client.GroupAsync(new Guid[] { Guid.Parse("73f411fe-4f43-4b4b-9cbd-6828d8f4cf9a") });

Remarks

> * * 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 "Verify Face To Face" when you only have 2 candidate faces. * The 'recognitionModel' associated with the query faces' faceIds should be the same.

Applies to