Skip to content

Commit

Permalink
Updated endpoint path
Browse files Browse the repository at this point in the history
  • Loading branch information
wiazur authored Jan 18, 2020
1 parent 4b98cbc commit e139152
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions dotnet/Face/Face1.0.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT License.
// Copyright(c) Microsoft Corporation.All rights reserved.
// Licensed under the MIT License.

using System;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;

namespace CSHttpClientSample
/* This sample uses the Azure Face API to detect faces in an image and then
* returns a lot of facial features, in addition to gender and age.
* Face API:
* https://westus.dev.cognitive.microsoft.com/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236
*/

namespace FaceSample
{
static class Program
{
// **********************************************
// *** Update or verify the following values. ***
// **********************************************

// Add your Azure Face subscription key and endpoint to your environment variables
const string subscriptionKey = Environment.GetEnvironmentVariable("FACE_SUBSCRIPTION_KEY");
const string uriBase = Environment.GetEnvironmentVariable("FACE_ENDPOINT");

private static string subscriptionKey = Environment.GetEnvironmentVariable("FACE_SUBSCRIPTION_KEY");
private static string uriBase = Environment.GetEnvironmentVariable("FACE_ENDPOINT");

static void Main()
{
// Get the path and filename to process from the user.
Console.WriteLine("Detect faces:");
Console.Write("Enter the path to an image with faces that you wish to analzye: ");
string imageFilePath = Console.ReadLine();
// Download an image from here:
// https://github.com/Azure-Samples/cognitive-services-sample-data-files/tree/master/ComputerVision/Images
// Or add your own image and put into your bin\Debug\netcoreapp3.0\Images folder.
string imageFilePath = @"Images\faces.jpg";

// Execute the REST API call.
MakeAnalysisRequest(imageFilePath);
Expand All @@ -34,7 +35,6 @@ static void Main()
Console.ReadLine();
}


/// <summary>
/// Gets the analysis of the specified image file by using the Computer Vision REST API.
/// </summary>
Expand All @@ -47,10 +47,11 @@ static async void MakeAnalysisRequest(string imageFilePath)
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", subscriptionKey);

// Request parameters. A third optional parameter is "details".
string requestParameters = "returnFaceId=true&returnFaceLandmarks=false&returnFaceAttributes=age,gender,headPose,smile,facialHair,glasses,emotion,hair,makeup,occlusion,accessories,blur,exposure,noise";
string requestParameters =
"returnFaceId=true&returnFaceLandmarks=false&returnFaceAttributes=age,gender,headPose,smile,facialHair,glasses,emotion,hair,makeup,occlusion,accessories,blur,exposure,noise";

// Assemble the URI for the REST API Call.
string uri = uriBase + "?" + requestParameters;
string uri = uriBase + "/face/v1.0/detect?" + requestParameters;

HttpResponseMessage response;

Expand All @@ -75,7 +76,6 @@ static async void MakeAnalysisRequest(string imageFilePath)
}
}


/// <summary>
/// Returns the contents of the specified file as a byte array.
/// </summary>
Expand All @@ -88,7 +88,6 @@ static byte[] GetImageAsByteArray(string imageFilePath)
return binaryReader.ReadBytes((int)fileStream.Length);
}


/// <summary>
/// Formats the given JSON string by adding line breaks and indents.
/// </summary>
Expand Down

0 comments on commit e139152

Please sign in to comment.