private void AddTagResultsToComputerVisionResults(ImageAnalysis results, ComputerVisionResults computerVisionResults)
 {
     if (results.Tags != null)
     {
         foreach (var tag in results.Tags)
         {
             var tagResultItem = new ComputerVisionResultItem
             {
                 Name       = tag.Name,
                 Confidence = tag.Confidence
             };
             computerVisionResults.Tags.Add(tagResultItem);
         }
     }
 }
 private void AddBrandResultsToComputerVisionResults(ImageAnalysis results, ComputerVisionResults computerVisionResults)
 {
     if (results.Brands != null)
     {
         foreach (var brand in results.Brands)
         {
             var brandResultItem = new ComputerVisionResultItem()
             {
                 Name        = brand.Name,
                 Confidence  = brand.Confidence,
                 BoundingBox = new Rect(brand.Rectangle.X, brand.Rectangle.Y, brand.Rectangle.W, brand.Rectangle.H)
             };
             computerVisionResults.Brands.Add(brandResultItem);
         }
     }
 }
 private void AddObjectResultsToComputerVisionResults(ImageAnalysis results, ComputerVisionResults computerVisionResults)
 {
     if (results.Objects != null)
     {
         foreach (var obj in results.Objects)
         {
             var objectResultItem = new ComputerVisionResultItem()
             {
                 Name        = obj.ObjectProperty,
                 Confidence  = obj.Confidence,
                 BoundingBox = new Rect(obj.Rectangle.X, obj.Rectangle.Y, obj.Rectangle.W, obj.Rectangle.H)
             };
             computerVisionResults.Objects.Add(objectResultItem);
         }
     }
 }
        private void AddCategoryResultsToComputerVisionResults(ImageAnalysis results, ComputerVisionResults computerVisionResults)
        {
            if (results.Categories != null)
            {
                foreach (var category in results.Categories)
                {
                    var categoryResultItem = new ComputerVisionResultItem()
                    {
                        Name       = category.Name,
                        Confidence = category.Score
                    };
                    computerVisionResults.Categories.Add(categoryResultItem);

                    if (category.Detail != null)
                    {
                        if (category.Detail.Celebrities != null)
                        {
                            foreach (var celebrity in category.Detail.Celebrities)
                            {
                                var celebrityResultItem = new ComputerVisionResultItem()
                                {
                                    Name        = celebrity.Name,
                                    Confidence  = celebrity.Confidence,
                                    BoundingBox = new Rect(celebrity.FaceRectangle.Left, celebrity.FaceRectangle.Top,
                                                           celebrity.FaceRectangle.Width, celebrity.FaceRectangle.Height)
                                };
                                computerVisionResults.Celebrities.Add(celebrityResultItem);
                            }
                        }

                        if (category.Detail.Landmarks != null)
                        {
                            foreach (var landmark in category.Detail.Landmarks)
                            {
                                var landmarkResultItem = new ComputerVisionResultItem()
                                {
                                    Name       = landmark.Name,
                                    Confidence = landmark.Confidence
                                };
                                computerVisionResults.Landmarks.Add(landmarkResultItem);
                            }
                        }
                    }
                }
            }
        }
 private void AddFaceResultsToComputerVisionResults(ImageAnalysis results, ComputerVisionResults computerVisionResults)
 {
     if (results.Faces != null)
     {
         foreach (var face in results.Faces)
         {
             var faceResultItem = new ComputerVisionResultItem()
             {
                 Name        = face.Gender.HasValue ? face.Gender.Value.ToString() : "",
                 Confidence  = double.Parse(face.Age.ToString()),
                 BoundingBox = new Rect(face.FaceRectangle.Left, face.FaceRectangle.Top, face.FaceRectangle.Width,
                                        face.FaceRectangle.Height)
             };
             computerVisionResults.Faces.Add(faceResultItem);
         }
     }
 }
        private void AddDescriptionResultsToComputerVisionResults(ImageAnalysis results, ComputerVisionResults computerVisionResults)
        {
            if (results.Description != null)
            {
                if (results.Description.Captions != null)
                {
                    foreach (var caption in results.Description.Captions)
                    {
                        var captionResultItem = new ComputerVisionResultItem()
                        {
                            Name       = caption.Text,
                            Confidence = caption.Confidence
                        };
                        computerVisionResults.Captions.Add(captionResultItem);
                    }
                }

                if (results.Description.Tags != null)
                {
                    computerVisionResults.DescriptionTags.AddRange(results.Description.Tags);
                }
            }
        }