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); }
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 }
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 }