Skip to content

Commit

Permalink
Merge branch 'MicrosoftDocs:main' into patch-1
Browse files Browse the repository at this point in the history
sufenfong authored Jul 23, 2024
2 parents 56ba172 + b4e7d93 commit 9c196d6
Showing 163 changed files with 2,544 additions and 1,475 deletions.
15 changes: 15 additions & 0 deletions .openpublishing.redirection.json
Original file line number Diff line number Diff line change
@@ -4162,6 +4162,21 @@
"redirect_url": "/azure/service-fabric/service-fabric-best-practices-security",
"redirect_document_id": false
},
{
"source_path_from_root": "/articles/service-fabric/service-fabric-diagnostics-overview.md",
"redirect_url": "/azure/service-fabric/monitor-service-fabric",
"redirect_document_id": false
},
{
"source_path_from_root": "/articles/service-fabric/service-fabric-diagnostics-event-generation-perf.md",
"redirect_url": "/azure/service-fabric/monitor-service-fabric-reference#performance-metrics",
"redirect_document_id": false
},
{
"source_path_from_root": "/articles/service-fabric/service-fabric-diagnostics-event-generation-app.md",
"redirect_url": "/azure/service-fabric/monitor-service-fabric#application-monitoring",
"redirect_document_id": false
},
{
"source_path_from_root": "/articles/virtual-desktop/partners.md",
"redirect_url": "https://azuremarketplace.microsoft.com/marketplace/apps?page=1&search=azure%20virtual%20desktop",
72 changes: 36 additions & 36 deletions articles/ai-services/computer-vision/Tutorials/liveness.md
Original file line number Diff line number Diff line change
@@ -87,8 +87,8 @@ The high-level steps involved in liveness orchestration are illustrated below:

#### [C#](#tab/csharp)
```csharp
var endpoint = new Uri(System.Environment.GetEnvironmentVariable("VISION_ENDPOINT"));
var credential = new AzureKeyCredential(System.Environment.GetEnvironmentVariable("VISION_KEY"));
var endpoint = new Uri(System.Environment.GetEnvironmentVariable("FACE_ENDPOINT"));
var credential = new AzureKeyCredential(System.Environment.GetEnvironmentVariable("FACE_APIKEY"));

var sessionClient = new FaceSessionClient(endpoint, credential);

@@ -107,8 +107,8 @@ The high-level steps involved in liveness orchestration are illustrated below:

#### [Java](#tab/java)
```java
String endpoint = System.getenv("VISION_ENDPOINT");
String accountKey = System.getenv("VISION_KEY");
String endpoint = System.getenv("FACE_ENDPOINT");
String accountKey = System.getenv("FACE_APIKEY");

FaceSessionClient sessionClient = new FaceSessionClientBuilder()
.endpoint(endpoint)
@@ -127,8 +127,8 @@ The high-level steps involved in liveness orchestration are illustrated below:

#### [Python](#tab/python)
```python
endpoint = os.environ["VISION_ENDPOINT"]
key = os.environ["VISION_KEY"]
endpoint = os.environ["FACE_ENDPOINT"]
key = os.environ["FACE_APIKEY"]

face_session_client = FaceSessionClient(endpoint=endpoint, credential=AzureKeyCredential(key))

@@ -171,8 +171,8 @@ The high-level steps involved in liveness orchestration are illustrated below:

#### [REST API (Windows)](#tab/cmd)
```console
curl --request POST --location "%VISION_ENDPOINT%/face/v1.1-preview.1/detectliveness/singlemodal/sessions" ^
--header "Ocp-Apim-Subscription-Key: %VISION_KEY%" ^
curl --request POST --location "%FACE_ENDPOINT%/face/v1.1-preview.1/detectliveness/singlemodal/sessions" ^
--header "Ocp-Apim-Subscription-Key: %FACE_APIKEY%" ^
--header "Content-Type: application/json" ^
--data ^
"{ ^
@@ -184,8 +184,8 @@ The high-level steps involved in liveness orchestration are illustrated below:

#### [REST API (Linux)](#tab/bash)
```bash
curl --request POST --location "${VISION_ENDPOINT}/face/v1.1-preview.1/detectliveness/singlemodal/sessions" \
--header "Ocp-Apim-Subscription-Key: ${VISION_KEY}" \
curl --request POST --location "${FACE_ENDPOINT}/face/v1.1-preview.1/detectliveness/singlemodal/sessions" \
--header "Ocp-Apim-Subscription-Key: ${FACE_APIKEY}" \
--header "Content-Type: application/json" \
--data \
'{
@@ -303,14 +303,14 @@ The high-level steps involved in liveness orchestration are illustrated below:

#### [REST API (Windows)](#tab/cmd)
```console
curl --request GET --location "%VISION_ENDPOINT%/face/v1.1-preview.1/detectliveness/singlemodal/sessions/<session-id>" ^
--header "Ocp-Apim-Subscription-Key: %VISION_KEY%"
curl --request GET --location "%FACE_ENDPOINT%/face/v1.1-preview.1/detectliveness/singlemodal/sessions/<session-id>" ^
--header "Ocp-Apim-Subscription-Key: %FACE_APIKEY%"
```

#### [REST API (Linux)](#tab/bash)
```bash
curl --request GET --location "${VISION_ENDPOINT}/face/v1.1-preview.1/detectliveness/singlemodal/sessions/<session-id>" \
--header "Ocp-Apim-Subscription-Key: ${VISION_KEY}"
curl --request GET --location "${FACE_ENDPOINT}/face/v1.1-preview.1/detectliveness/singlemodal/sessions/<session-id>" \
--header "Ocp-Apim-Subscription-Key: ${FACE_APIKEY}"
```

---
@@ -394,14 +394,14 @@ The high-level steps involved in liveness orchestration are illustrated below:

#### [REST API (Windows)](#tab/cmd)
```console
curl --request DELETE --location "%VISION_ENDPOINT%/face/v1.1-preview.1/detectliveness/singlemodal/sessions/<session-id>" ^
--header "Ocp-Apim-Subscription-Key: %VISION_KEY%"
curl --request DELETE --location "%FACE_ENDPOINT%/face/v1.1-preview.1/detectliveness/singlemodal/sessions/<session-id>" ^
--header "Ocp-Apim-Subscription-Key: %FACE_APIKEY%"
```

#### [REST API (Linux)](#tab/bash)
```bash
curl --request DELETE --location "${VISION_ENDPOINT}/face/v1.1-preview.1/detectliveness/singlemodal/sessions/<session-id>" \
--header "Ocp-Apim-Subscription-Key: ${VISION_KEY}"
curl --request DELETE --location "${FACE_ENDPOINT}/face/v1.1-preview.1/detectliveness/singlemodal/sessions/<session-id>" \
--header "Ocp-Apim-Subscription-Key: ${FACE_APIKEY}"
```

---
@@ -443,8 +443,8 @@ The high-level steps involved in liveness with verification orchestration are il
#### [C#](#tab/csharp)
```csharp
var endpoint = new Uri(System.Environment.GetEnvironmentVariable("VISION_ENDPOINT"));
var credential = new AzureKeyCredential(System.Environment.GetEnvironmentVariable("VISION_KEY"));
var endpoint = new Uri(System.Environment.GetEnvironmentVariable("FACE_ENDPOINT"));
var credential = new AzureKeyCredential(System.Environment.GetEnvironmentVariable("FACE_APIKEY"));

var sessionClient = new FaceSessionClient(endpoint, credential);

@@ -467,8 +467,8 @@ The high-level steps involved in liveness with verification orchestration are il

#### [Java](#tab/java)
```java
String endpoint = System.getenv("VISION_ENDPOINT");
String accountKey = System.getenv("VISION_KEY");
String endpoint = System.getenv("FACE_ENDPOINT");
String accountKey = System.getenv("FACE_APIKEY");

FaceSessionClient sessionClient = new FaceSessionClientBuilder()
.endpoint(endpoint)
@@ -493,8 +493,8 @@ The high-level steps involved in liveness with verification orchestration are il

#### [Python](#tab/python)
```python
endpoint = os.environ["VISION_ENDPOINT"]
key = os.environ["VISION_KEY"]
endpoint = os.environ["FACE_ENDPOINT"]
key = os.environ["FACE_APIKEY"]

face_session_client = FaceSessionClient(endpoint=endpoint, credential=AzureKeyCredential(key))

@@ -558,16 +558,16 @@ The high-level steps involved in liveness with verification orchestration are il

#### [REST API (Windows)](#tab/cmd)
```console
curl --request POST --location "%VISION_ENDPOINT%/face/v1.1-preview.1/detectlivenesswithverify/singlemodal/sessions" ^
--header "Ocp-Apim-Subscription-Key: %VISION_KEY%" ^
curl --request POST --location "%FACE_ENDPOINT%/face/v1.1-preview.1/detectlivenesswithverify/singlemodal/sessions" ^
--header "Ocp-Apim-Subscription-Key: %FACE_APIKEY%" ^
--form "Parameters=""{\\\""livenessOperationMode\\\"": \\\""passive\\\"", \\\""deviceCorrelationId\\\"": \\\""723d6d03-ef33-40a8-9682-23a1feb7bccd\\\""}""" ^
--form "VerifyImage=@""test.png"""
```

#### [REST API (Linux)](#tab/bash)
```bash
curl --request POST --location "${VISION_ENDPOINT}/face/v1.1-preview.1/detectlivenesswithverify/singlemodal/sessions" \
--header "Ocp-Apim-Subscription-Key: ${VISION_KEY}" \
curl --request POST --location "${FACE_ENDPOINT}/face/v1.1-preview.1/detectlivenesswithverify/singlemodal/sessions" \
--header "Ocp-Apim-Subscription-Key: ${FACE_APIKEY}" \
--form 'Parameters="{
\"livenessOperationMode\": \"passive\",
\"deviceCorrelationId\": \"723d6d03-ef33-40a8-9682-23a1feb7bccd\"
@@ -693,14 +693,14 @@ The high-level steps involved in liveness with verification orchestration are il

#### [REST API (Windows)](#tab/cmd)
```console
curl --request GET --location "%VISION_ENDPOINT%/face/v1.1-preview.1/detectlivenesswithverify/singlemodal/sessions/<session-id>" ^
--header "Ocp-Apim-Subscription-Key: %VISION_KEY%"
curl --request GET --location "%FACE_ENDPOINT%/face/v1.1-preview.1/detectlivenesswithverify/singlemodal/sessions/<session-id>" ^
--header "Ocp-Apim-Subscription-Key: %FACE_APIKEY%"
```

#### [REST API (Linux)](#tab/bash)
```bash
curl --request GET --location "${VISION_ENDPOINT}/face/v1.1-preview.1/detectlivenesswithverify/singlemodal/sessions/<session-id>" \
--header "Ocp-Apim-Subscription-Key: ${VISION_KEY}"
curl --request GET --location "${FACE_ENDPOINT}/face/v1.1-preview.1/detectlivenesswithverify/singlemodal/sessions/<session-id>" \
--header "Ocp-Apim-Subscription-Key: ${FACE_APIKEY}"
```

---
@@ -788,14 +788,14 @@ The high-level steps involved in liveness with verification orchestration are il

#### [REST API (Windows)](#tab/cmd)
```console
curl --request DELETE --location "%VISION_ENDPOINT%/face/v1.1-preview.1/detectlivenesswithverify/singlemodal/sessions/<session-id>" ^
--header "Ocp-Apim-Subscription-Key: %VISION_KEY%"
curl --request DELETE --location "%FACE_ENDPOINT%/face/v1.1-preview.1/detectlivenesswithverify/singlemodal/sessions/<session-id>" ^
--header "Ocp-Apim-Subscription-Key: %FACE_APIKEY%"
```

#### [REST API (Linux)](#tab/bash)
```bash
curl --request DELETE --location "${VISION_ENDPOINT}/face/v1.1-preview.1/detectlivenesswithverify/singlemodal/sessions/<session-id>" \
--header "Ocp-Apim-Subscription-Key: ${VISION_KEY}"
curl --request DELETE --location "${FACE_ENDPOINT}/face/v1.1-preview.1/detectlivenesswithverify/singlemodal/sessions/<session-id>" \
--header "Ocp-Apim-Subscription-Key: ${FACE_APIKEY}"
```

---
31 changes: 21 additions & 10 deletions articles/ai-services/computer-vision/how-to/add-faces.md
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ ms.custom: devx-track-csharp

[!INCLUDE [Gate notice](../includes/identity-gate-notice.md)]

This guide demonstrates how to add a large number of persons and faces to a **PersonGroup** object. The same strategy also applies to **LargePersonGroup**, **FaceList**, and **LargeFaceList** objects. This sample is written in C# and uses the Azure AI Face .NET client library.
This guide demonstrates how to add a large number of persons and faces to a **PersonGroup** object. The same strategy also applies to **LargePersonGroup**, **FaceList**, and **LargeFaceList** objects. This sample is written in C#.

## Initialization

@@ -57,10 +57,6 @@ static async Task WaitCallLimitPerSecondAsync()
}
```

## Authorize the API call

When you use the Face client library, the key and subscription endpoint are passed in through the constructor of the FaceClient class. See the [quickstart](../quickstarts-sdk/identity-client-library.md?pivots=programming-language-csharp&tabs=visual-studio) for instructions on creating a Face client object.


## Create the PersonGroup

@@ -70,21 +66,33 @@ This code creates a **PersonGroup** named `"MyPersonGroup"` to save the persons.
const string personGroupId = "mypersongroupid";
const string personGroupName = "MyPersonGroup";
_timeStampQueue.Enqueue(DateTime.UtcNow);
await faceClient.LargePersonGroup.CreateAsync(personGroupId, personGroupName);
using (var content = new ByteArrayContent(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new Dictionary<string, object> { ["name"] = personGroupName, ["recognitionModel"] = "recognition_04" }))))
{
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
await httpClient.PutAsync($"{ENDPOINT}/face/v1.0/persongroups/{personGroupId}", content);
}
```

## Create the persons for the PersonGroup

This code creates **Persons** concurrently, and uses `await WaitCallLimitPerSecondAsync()` to avoid exceeding the call rate limit.

```csharp
Person[] persons = new Person[PersonCount];
string?[] persons = new string?[PersonCount];
Parallel.For(0, PersonCount, async i =>
{
await WaitCallLimitPerSecondAsync();

string personName = $"PersonName#{i}";
persons[i] = await faceClient.PersonGroupPerson.CreateAsync(personGroupId, personName);
using (var content = new ByteArrayContent(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new Dictionary<string, object> { ["name"] = personName }))))
{
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
using (var response = await httpClient.PostAsync($"{ENDPOINT}/face/v1.0/persongroups/{personGroupId}/persons", content))
{
string contentString = await response.Content.ReadAsStringAsync();
persons[i] = (string?)(JsonConvert.DeserializeObject<Dictionary<string, object>>(contentString)?["personId"]);
}
}
});
```

@@ -95,7 +103,6 @@ Faces added to different persons are processed concurrently. Faces added for one
```csharp
Parallel.For(0, PersonCount, async i =>
{
Guid personId = persons[i].PersonId;
string personImageDir = @"/path/to/person/i/images";

foreach (string imagePath in Directory.GetFiles(personImageDir, "*.jpg"))
@@ -104,7 +111,11 @@ Parallel.For(0, PersonCount, async i =>

using (Stream stream = File.OpenRead(imagePath))
{
await faceClient.PersonGroupPerson.AddFaceFromStreamAsync(personGroupId, personId, stream);
using (var content = new StreamContent(stream))
{
content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
await httpClient.PostAsync($"{ENDPOINT}/face/v1.0/persongroups/{personGroupId}/persons/{persons[i]}/persistedfaces?detectionModel=detection_03", content);
}
}
}
});
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ ms.author: pafarley

[!INCLUDE [Gate notice](../includes/identity-gate-notice.md)]

The [Find Similar](/rest/api/face/face-recognition-operations/find-similar-from-large-face-list) operation does face matching between a target face and a set of candidate faces, finding a smaller set of faces that look similar to the target face. This is useful for doing a face search by image.
The [Find Similar](/rest/api/face/face-recognition-operations/find-similar) operation does face matching between a target face and a set of candidate faces, finding a smaller set of faces that look similar to the target face. This is useful for doing a face search by image.

This guide demonstrates how to use the Find Similar feature in the different language SDKs. The following sample code assumes you have already authenticated a Face client object. For details on how to do this, follow a [quickstart](../quickstarts-sdk/identity-client-library.md).

@@ -39,11 +39,11 @@ You need to detect faces in images before you can compare them. In this guide, t

The following face detection method is optimized for comparison operations. It doesn't extract detailed face attributes, and it uses an optimized recognition model.

[!code-csharp[](~/cognitive-services-quickstart-code/dotnet/Face/FaceQuickstart.cs?name=snippet_face_detect_recognize)]
[!code-csharp[](~/cognitive-services-quickstart-code/dotnet/Face/FindSimilar.cs?name=snippet_face_detect_recognize)]

The following code uses the above method to get face data from a series of images.

[!code-csharp[](~/cognitive-services-quickstart-code/dotnet/Face/FaceQuickstart.cs?name=snippet_loadfaces)]
[!code-csharp[](~/cognitive-services-quickstart-code/dotnet/Face/FindSimilar.cs?name=snippet_loadfaces)]


#### [REST API](#tab/rest)
@@ -72,11 +72,11 @@ In this guide, the face detected in the *Family1-Dad1.jpg* image should be retur

The following code calls the Find Similar API on the saved list of faces.

[!code-csharp[](~/cognitive-services-quickstart-code/dotnet/Face/FaceQuickstart.cs?name=snippet_find_similar)]
[!code-csharp[](~/cognitive-services-quickstart-code/dotnet/Face/FindSimilar.cs?name=snippet_find_similar)]

The following code prints the match details to the console:

[!code-csharp[](~/cognitive-services-quickstart-code/dotnet/Face/FaceQuickstart.cs?name=snippet_find_similar_print)]
[!code-csharp[](~/cognitive-services-quickstart-code/dotnet/Face/FindSimilar.cs?name=snippet_find_similar_print)]


#### [REST API](#tab/rest)
Loading

0 comments on commit 9c196d6

Please sign in to comment.