static async Task RunTextScanAsync() { var contninue = false; do { Console.Clear(); Console.WriteLine("Enter an Image (with text) URL (e.g. https://intelligentkioskstore.blob.core.windows.net/visionapi/suggestedphotos/3.png \nor https://raw.githubusercontent.com/MicrosoftDocs/azure-docs/master/articles/cognitive-services/Computer-vision/Images/readsample.jpg):"); var url = Console.ReadLine(); if (string.IsNullOrWhiteSpace(url)) { Console.WriteLine("URL is empty"); } else { Console.WriteLine("Analyzing the image to extract texts with Azure Cognitive Service..."); var cv = new ComputerVisionService(new ConfigurationReader()); var results = await cv.BatchReadFileUrl(url); var textRecognitionLocalFileResults = results.AnalyzeResult; foreach (var recResult in textRecognitionLocalFileResults.ReadResults) { foreach (Line line in recResult.Lines) { Console.WriteLine(line.Text); } } Console.WriteLine(); Console.WriteLine("\n\nPress 'C' to continue..."); contninue = Char.ToUpperInvariant(Console.ReadKey().KeyChar) == 'C'; } } while (contninue); }
static async Task RunImageScanAsync() { var contninue = false; do { Console.Clear(); Console.WriteLine("Enter an Image URL (e.g. https://moderatorsampleimages.blob.core.windows.net/samples/sample16.png):"); var url = Console.ReadLine(); if (string.IsNullOrWhiteSpace(url)) { Console.WriteLine("URL is empty"); } else { Console.WriteLine("Analyzing the image with Azure Cognitive Service..."); var cv = new ComputerVisionService(new ConfigurationReader()); var ar = await cv.AnalyzeImageUrl(url); var serializer = new YamlDotNet.Serialization.Serializer(); var yaml = serializer.Serialize(ar); Console.WriteLine("Analysis report:"); Console.WriteLine(yaml); Console.WriteLine("\n\nPress 'C' to continue..."); contninue = Char.ToUpperInvariant(Console.ReadKey().KeyChar) == 'C'; } } while (contninue); }