jonasPamm
jonasPamm

Reputation: 97

C# Azure Face AI try to recognize people in image

My goal is to check if the system know/don't know the person who is sitting in front of my webcam. First I tried it in a Console App and everythink worked fine but now I what to have a "nice" operlay in WPF and I inplement all in my WPF App even a Anti UI Block System but now I get a exeption

enter image description here

I know thats a big exeption. I'm sorry that the exeption is written in German (I can't change it). What is says: System.Net.Http.HttpRequestException: Error while sending and the remotehost closed a connection.

Here is the methode that triggers that exeption:

private static async Task<List<DetectedFace>> DetectFaceRecognize(IFaceClient faceClient, string path, string recognition_model)
    {
        try
        {
            FileStream fs = File.OpenRead(path);

            IList<DetectedFace> detectedFaces = await faceClient.Face.DetectWithStreamAsync(fs, detectionModel: DetectionModel.Detection03);//Exeption triggert here
            Console.WriteLine($"{detectedFaces.Count} face(s) detected from image `{Path.GetFileName(path)}`");

            fs.Close();
            return detectedFaces.ToList();
        }
        catch(Exception ex)
        {
            MessageBox.Show(ex.ToString());
            return await DetectFaceRecognize(faceClient, path, recognition_model);
            
        }
    }

Can someone help me with this exeption?

Upvotes: 0

Views: 107

Answers (1)

Sajeetharan
Sajeetharan

Reputation: 222722

Can you explicitly set the TLS version by adding the following line

 System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;

Upvotes: 1

Related Questions