public static async Task <string> GetTextAsync(Stream imageFilePath) { try { using (var client = new ComputerVisionClient(new ApiKeyServiceClientCredentials(SubscriptionKey)) { Endpoint = UriBase }) { var result = await client.RecognizePrintedTextInStreamWithHttpMessagesAsync(true, imageFilePath); return(result.Body.GetText()); } } catch (Exception e) { return(e.Message); } }
private static async Task MakeApiRequest(string imageFilePath) { try { using (var client = new ComputerVisionClient(new ApiKeyServiceClientCredentials(subscriptionKey)) { Endpoint = uriBase }) { var result = await client.RecognizePrintedTextInStreamWithHttpMessagesAsync(true, File.OpenRead(imageFilePath)); Console.WriteLine(result.Body.GetText()); } } catch (Exception e) { Console.WriteLine("\n" + e.Message); } }