Skip to content

Commit 0b85258

Browse files
committed
clarify sync and async calls and the dependency
1 parent ba78098 commit 0b85258

File tree

1 file changed

+92
-1
lines changed

1 file changed

+92
-1
lines changed

articles/ai-services/computer-vision/how-to/use-persondirectory.md

Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ using (var content = new ByteArrayContent(byteData))
238238
```
239239

240240
> [!NOTE]
241-
> As soon as the call returns, the created **DynamicPersonGroup** will be ready to use in an Identify call, with any **Person** references provided in the process. The completion status of the returned operation ID, on the other hand, indicates the update status of the person-to-group relationship.
241+
> As soon as the call returns, the created **DynamicPersonGroup** will be ready to use in an Identify call, with any **Person** references provided in the process. The completion status of the returned operation ID, on the other hand, only indicates the update status for [Get Dynamic Person Group References](/rest/api/face/person-directory-operations/get-dynamic-person-group-references) lookup calls.
242242
243243
### Update the DynamicPersonGroup
244244

@@ -393,6 +393,97 @@ using (var content = new ByteArrayContent(byteData))
393393

394394
The response will contain a Boolean value indicating whether the service considers the new face to belong to the same **Person**, and a confidence score for the prediction.
395395

396+
## Overview of asynchronous operations
397+
398+
The tables below summarize whether a **PersonDirectory** management call is a long-running operation (LRO) processed asynchronously, or it completes immediately and synchronously:
399+
400+
| Person/Face Management | URI | LRO? |
401+
| --- | --- | --- |
402+
| [Get Persons](/rest/api/face/person-directory-operations/get-persons) | /persons | |
403+
| [Create Person](/rest/api/face/person-directory-operations/create-person) | /persons | 🔴 |
404+
| [Get Person](/rest/api/face/person-directory-operations/get-person) | /persons/{personId} | |
405+
| [Update Person](/rest/api/face/person-directory-operations/update-person) | /persons/{personId} | |
406+
| [Delete Person](/rest/api/face/person-directory-operations/delete-person) | /persons/{personId} | 🔴 |
407+
| [Get Person Faces](/rest/api/face/person-directory-operations/get-person-faces) | /persons/{personId}/recognitionModels/{model}/persistedfaces | |
408+
| [Add Person Face](/rest/api/face/person-directory-operations/add-person-face) | /persons/{personId}/recognitionModels/{model}/persistedfaces | 🔴 |
409+
| [Add Person Face From Url](/rest/api/face/person-directory-operations/add-person-face-from-url) | /persons/{personId}/recognitionModels/{model}/persistedfaces | 🔴 |
410+
| [Get Person Face](/rest/api/face/person-directory-operations/get-person-face) | /persons/{personId}/recognitionModels/{model}/persistedfaces/{persistedFaceId} | |
411+
| [Update Person Face](/rest/api/face/person-directory-operations/update-person-face) | /persons/{personId}/recognitionModels/{model}/persistedfaces/{persistedFaceId} | |
412+
| [Delete Person Face](/rest/api/face/person-directory-operations/delete-person-face) | /persons/{personId}/recognitionModels/{model}/persistedfaces/{persistedFaceId} | 🔴 |
413+
414+
| Group Management | URI | LRO? |
415+
| --- | --- | --- |
416+
| [Get Dynamic Person Groups](/rest/api/face/person-directory-operations/get-dynamic-person-groups) | /dynamicpersongroups | |
417+
| [Create Dynamic Person Group](/rest/api/face/person-directory-operations/create-dynamic-person-group) | /dynamicpersongroups/{dynamicPersonGroupId} | |
418+
| [Create Dynamic Person Group With Person](/rest/api/face/person-directory-operations/create-dynamic-person-group-with-person) | /dynamicpersongroups/{dynamicPersonGroupId} | 🔴 |
419+
| [Get Dynamic Person Group](/rest/api/face/person-directory-operations/get-dynamic-person-group) | /dynamicpersongroups/{dynamicPersonGroupId} | |
420+
| [Update Dynamic Person Group](/rest/api/face/person-directory-operations/update-dynamic-person-group) | /dynamicpersongroups/{dynamicPersonGroupId} | |
421+
| [Update Dynamic Person Group With Person Changes](/rest/api/face/person-directory-operations/update-dynamic-person-group-with-person-changes) | /dynamicpersongroups/{dynamicPersonGroupId} | 🔴 |
422+
| [Delete Dynamic Person Group](/rest/api/face/person-directory-operations/delete-dynamic-person-group) | /dynamicpersongroups/{dynamicPersonGroupId} | 🔴 |
423+
| [Get Dynamic Person Group Persons](/rest/api/face/person-directory-operations/get-dynamic-person-group-persons) | /dynamicpersongroups/{dynamicPersonGroupId}/persons | |
424+
| [Get Dynamic Person Group References](/rest/api/face/person-directory-operations/get-dynamic-person-group-references) | /persons/{personId}/dynamicPersonGroupReferences | |
425+
426+
The following code illustrates the dependencies of these asynchronous operations:
427+
428+
```csharp
429+
var createPersonResponse = await CreatePersonAsync();
430+
var personId = createPersonResponse.PersonId;
431+
432+
// faces can be added once the person creation HTTP call returns, even if it's still processing
433+
var addPersonFaceResponse = await AddPersonFaceAsync(personId);
434+
var addPersonFaceFromUrlResponse = await AddPersonFaceFromUrlAsync(personId);
435+
436+
switch (scenario)
437+
{
438+
case Scenario.Verify:
439+
// only need to ensure the addition of face data has propagated
440+
await WaitForLongRunningOperationsAsync(new[]
441+
{
442+
addPersonFaceResponse.OperationLocation,
443+
addPersonFaceFromUrlResponse.OperationLocation
444+
});
445+
await VerifyFromPersonDirectoryAsync(queryFaceId, personId);
446+
break;
447+
448+
case Scenario.IdentifyInPersonDirectory:
449+
// ensure person creation and face data enrollment finish successfully
450+
await WaitForLongRunningOperationsAsync(new[]
451+
{
452+
createPersonResponse.OperationLocation,
453+
addPersonFaceResponse.OperationLocation,
454+
addPersonFaceFromUrlResponse.OperationLocation
455+
});
456+
await IdentifyFromPersonDirectoryAsync(queryFaceId);
457+
break;
458+
459+
case Scenario.IdentifyAgainstDynamicPersonGroup:
460+
// person creation needs to be completed before it can be added to a group
461+
await WaitForLongRunningOperationsAsync(new[]
462+
{
463+
createPersonResponse.OperationLocation
464+
});
465+
var groupResponse = await CreateOrUpdateDynamicPersonGroupWithPersonChangesAsync(groupId, [personId]);
466+
// and make sure face data are ready before identification
467+
await WaitForLongRunningOperationsAsync(new[]
468+
{
469+
addPersonFaceResponse.OperationLocation,
470+
addPersonFaceFromUrlResponse.OperationLocation
471+
});
472+
await IdentifyFromDynamicPersonGroupAsync(queryFaceId, groupId);
473+
// optionally check the person-to-group relationship, which requires the completion of the group's creation or updating call
474+
await WaitForLongRunningOperationsAsync(new[]
475+
{
476+
groupResponse.OperationLocation
477+
});
478+
var groupIds = await GetDynamicPersonGroupReferencesAsync(personId);
479+
break;
480+
481+
default:
482+
break;
483+
}
484+
```
485+
486+
396487
## Next steps
397488

398489
In this guide, you learned how to use the **PersonDirectory** structure to store face and person data for your Face app. Next, learn the best practices for adding your users' face data.

0 commit comments

Comments
 (0)