/// <summary>
 /// Initializes a new instance of the CelebritiesModel class.
 /// </summary>
 /// <param name="name">Name of the celebrity.</param>
 /// <param name="confidence">Confidence level for the celebrity
 /// recognition as a value ranging from 0 to 1.</param>
 /// <param name="faceRectangle">Location of the identified face in the
 /// image.</param>
 public CelebritiesModel(string name = default(string), double confidence = default(double), FaceRectangle faceRectangle = default(FaceRectangle))
 {
     Name          = name;
     Confidence    = confidence;
     FaceRectangle = faceRectangle;
     CustomInit();
 }
        private void GetCelebrityInfoIfAvailable(ImageAnalyzer analyzer, Microsoft.Azure.CognitiveServices.Vision.ComputerVision.Models.FaceRectangle rectangle, out string name, out double confidence)
        {
            if (analyzer.AnalysisResult?.Categories != null)
            {
                foreach (var category in analyzer.AnalysisResult.Categories.Where(c => c.Detail != null))
                {
                    if (category.Detail.Celebrities != null)
                    {
                        foreach (var celebrity in category.Detail.Celebrities)
                        {
                            int left = celebrity.FaceRectangle.Left;
                            int top  = celebrity.FaceRectangle.Top;

                            if (Math.Abs(left - rectangle.Left) <= 20 && Math.Abs(top - rectangle.Top) <= 20)
                            {
                                name       = celebrity.Name;
                                confidence = celebrity.Confidence;
                                return;
                            }
                        }
                    }
                }
            }

            name       = null;
            confidence = 0;
        }
 /// <summary>
 /// Initializes a new instance of the FaceDescription class.
 /// </summary>
 /// <param name="age">Possible age of the face.</param>
 /// <param name="gender">Possible gender of the face. Possible values
 /// include: 'Male', 'Female'</param>
 /// <param name="faceRectangle">Rectangle in the image containing the
 /// identified face.</param>
 public FaceDescription(int age = default(int), Gender?gender = default(Gender?), FaceRectangle faceRectangle = default(FaceRectangle))
 {
     Age           = age;
     Gender        = gender;
     FaceRectangle = faceRectangle;
     CustomInit();
 }