Skip to content

Commit b69a3e2

Browse files
authored
Updated endpoint path
1 parent 6b0b482 commit b69a3e2

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

dotnet/ComputerVision/HttpClientSample

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Microsoft Corporation. All rights reserved.
1+
// Copyright(c) Microsoft Corporation.All rights reserved.
22
// Licensed under the MIT License.
33

44
using System;
@@ -7,24 +7,26 @@ using System.Net.Http;
77
using System.Net.Http.Headers;
88
using System.Text;
99

10-
/* This sample uses the Azure Computer Vision API to analyze an image,
11-
* then retrieves its categories, color, description, and captions... in addition to some metadata.
10+
/* This sample uses the Azure Face API to detect faces in an image and then
11+
* returns a lot of facial features, in addition to gender and age.
12+
* Face API:
13+
* https://westus.dev.cognitive.microsoft.com/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236
1214
*/
1315

14-
namespace HttpClientSample
16+
namespace FaceSample
1517
{
1618
static class Program
1719
{
18-
// Add your Azure Computer Vision subscription key and endpoint to your environment variables
19-
public static string subscriptionKey = Environment.GetEnvironmentVariable("COMPUTER_VISION_SUBSCRIPTION_KEY");
20-
public static string uriBase = Environment.GetEnvironmentVariable("COMPUTER_VISION_ENDPOINT");
20+
// Add your Azure Face subscription key and endpoint to your environment variables
21+
private static string subscriptionKey = Environment.GetEnvironmentVariable("FACE_SUBSCRIPTION_KEY");
22+
private static string uriBase = Environment.GetEnvironmentVariable("FACE_ENDPOINT");
2123

2224
static void Main()
2325
{
2426
// Download an image from here:
2527
// https://github.com/Azure-Samples/cognitive-services-sample-data-files/tree/master/ComputerVision/Images
2628
// Or add your own image and put into your bin\Debug\netcoreapp3.0\Images folder.
27-
string imageFilePath = @"Images\objects.jpg";
29+
string imageFilePath = @"Images\faces.jpg";
2830

2931
// Execute the REST API call.
3032
MakeAnalysisRequest(imageFilePath);
@@ -45,10 +47,11 @@ namespace HttpClientSample
4547
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", subscriptionKey);
4648

4749
// Request parameters. A third optional parameter is "details".
48-
string requestParameters = "visualFeatures=Categories,Description,Color&language=en";
50+
string requestParameters =
51+
"returnFaceId=true&returnFaceLandmarks=false&returnFaceAttributes=age,gender,headPose,smile,facialHair,glasses,emotion,hair,makeup,occlusion,accessories,blur,exposure,noise";
4952

5053
// Assemble the URI for the REST API Call.
51-
string uri = uriBase + "/vision/v2.0/analyze?" + requestParameters;
54+
string uri = uriBase + "/face/v1.0/detect?" + requestParameters;
5255

5356
HttpResponseMessage response;
5457

@@ -85,7 +88,6 @@ namespace HttpClientSample
8588
return binaryReader.ReadBytes((int)fileStream.Length);
8689
}
8790

88-
8991
/// <summary>
9092
/// Formats the given JSON string by adding line breaks and indents.
9193
/// </summary>

0 commit comments

Comments
 (0)