Skip to content

Instantly share code, notes, and snippets.

@fraxedas
Last active November 27, 2018 12:09
Show Gist options
  • Save fraxedas/ae84f9c8e4a5900a281bb7e660917618 to your computer and use it in GitHub Desktop.
Save fraxedas/ae84f9c8e4a5900a281bb7e660917618 to your computer and use it in GitHub Desktop.
OCR with Azure Computer Vision
public static async Task<string> GetTextAsync(Stream image)
{
try
{
using (var client = new ComputerVisionClient(
new ApiKeyServiceClientCredentials(SubscriptionKey))
{Endpoint = UriBase}
)
{
var result =
await client.RecognizePrintedTextInStreamWithHttpMessagesAsync(true, image);
return result.Body.GetText();
}
}
catch (Exception e)
{
return e.Message;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment