Microsoft Faceid - Instantiating Faceclient

Asked

Viewed 66 times

0

Hello,

I am developing an application using the Microsoft cognitive services in specific Faceid, however I have a problem in the library startup, I took this code in the Microsoft site itself:

FaceClient faceClient = new FaceClient(new ApiKeyServiceClientCredentials(subscriptionKey), new System.Net.Http.DelegatingHandler[] { })
{
    Endpoint = faceEndpoint
};

However when the courses go through this line of code it gives the following error:

{"Inheritance safety rules were violated by the type: System.Net.Http.Webrequesthandler. Derived types must correspond to the security accessibility of the basic type or be less accessible.":" System.Net.Http.Webrequesthandler"}

I couldn’t find anything on the Internet to explain it, I count on your wisdom, thank you!

1 answer

0

According to the documentation of the SDK Csharp:

// Troque <SubscriptionKey> com sua chave de inscrição.
// Por exemplo, subscriptionKey = "0123456789abcdef0123456789ABCDEF"
private const string subscriptionKey = "<SubscriptionKey>";

// Troque ou verifique seu endPoint.
//
// Você deve usar a mesma região usada para obter sua chave de inscrição
// Por exemplo, se você obteve suas chave de inscrição do
// westus region, substitua "Westcentralus" por "Westus".
//
// NOTA: As chave de inscrição de avaliação gratuita são geradas no westcentralus
// por isso, se você estiver usando uma chave de inscrição de avaliação gratuita,
// não precisa mudar esta região.
private const string faceEndpoint =
    "https://westcentralus.api.cognitive.microsoft.com";

private readonly IFaceClient faceClient = new FaceClient(
    new ApiKeyServiceClientCredentials(subscriptionKey),
    new System.Net.Http.DelegatingHandler[] { });

recalling that it is necessary to use imports:

using Microsoft.Azure.CognitiveServices.Vision.Face;
using Microsoft.Azure.CognitiveServices.Vision.Face.Models;

According to this other documentation you must be doing it this way:

Step 1: Authorize the API Call

Each call to the Face API requires a signup key. This key needs to be passed by a query string parameter or specified in the request header. To pass the signup key through the query string, see the request URL of Face-Detect as an example:

https://westus.api.cognitive.microsoft.com/face/v1.0/detect[?returnFaceId][&returnFaceLandmarks][&returnFaceAttributes]&subscription-key=<Subscription Key>

Alternatively, the signup key can also be specified in the header of the HTTP request: ocp-apim-Subscription-key: When using a client library, the signature key is passed by the constructor of the Faceserviceclient class. For example:

faceServiceClient = new FaceServiceClient("<Subscription Key>");

It would just do that and it would already work ok.

  • Good afternoon Gunblades, thanks for the reply, but within the library there is no class faceServiceClient, only Faceclient version 2.0

  • Another thing, the first way you passed me the same mistake !

Browser other questions tagged

You are not signed in. Login or sign up in order to post.