コード例 #1
0
        public void DetectLogos()
        {
            Image image = LoadResourceImage("Chrome.png");
            // Snippet: DetectLogos
            ImageAnnotatorClient             client = ImageAnnotatorClient.Create();
            IReadOnlyList <EntityAnnotation> logos  = client.DetectLogos(image);

            foreach (EntityAnnotation logo in logos)
            {
                Console.WriteLine($"Description: {logo.Description}");
            }
            // End snippet
            Assert.Equal(1, logos.Count);
            Assert.Equal("Google Chrome", logos[0].Description);
        }
コード例 #2
0
        public void ErrorHandling_SingleImage()
        {
            // Sample: ErrorHandling_SingleImage
            Image image = new Image(); // No content or source!
            ImageAnnotatorClient client = ImageAnnotatorClient.Create();

            try
            {
                IReadOnlyList <EntityAnnotation> logos = client.DetectLogos(image);
                // Normally use logos here...
            }
            catch (AnnotateImageException e)
            {
                AnnotateImageResponse response = e.Response;
                Console.WriteLine(response.Error);
            }
            // End sample
        }
コード例 #3
0
        public void ErrorHandling_SingleImage()
        {
            // Sample: ErrorHandling_SingleImage
            // We create a request which passes simple validation, but isn't a valid image.
            Image image = Image.FromBytes(new byte[10]);
            ImageAnnotatorClient client = ImageAnnotatorClient.Create();

            try
            {
                IReadOnlyList <EntityAnnotation> logos = client.DetectLogos(image);
                // Normally use logos here...
            }
            catch (AnnotateImageException e)
            {
                AnnotateImageResponse response = e.Response;
                Console.WriteLine(response.Error);
            }
            // End sample
        }