Add text recognition capabilities to Windows Store apps

Some scenarios in a mobile app might require a text recognition mechanism, for example scanning a car plate or passport and transferring the input to data. Microsoft has built the library that you need to develop such a functionality in your WinRT apps. It is called Microsoft OCR Library for Windows Runtime, and this library is available as NuGet package. The library empowers developers to easily add text recognition capabilities to their Windows Phone 8/8.1 and Windows 8.1 Store apps. 

This OCR technology will enable various scenarios like text search in images, translation and copying text from images as per the examples I listed previously… The library was designed with flexibility and performance in mind, as it allows for OCR of high variety of image types and has numerous performance optimizations. The library runs entirely on client, supports 21 languages and enables processing images from various sources – camera, local file or network. The documentation is available at MSDN in the same format as for Platform API. The library is free and there will be no fees for runtime licenses of commercial applications developed with the library.

To add this library to your project, open your app project in Visual Studio and select PROJECT | Manage NuGet Packages, then search for Microsoft OCR. The following screenshot illustrates:

The OCR Library extracts text and layout information from the image. When you add the OCR Library to an application, you control how your application interprets the returned text, for example you can recognize patterns such as email addresses, phone numbers, and URLs, and your app can launch common actions such as sending an email, making a phone call, or visiting a web site.

It’s really simple to run OCR on an image. The following is a code snippets that demonstrates how to use it:


 OcrResult result = await ocrEngine.RecognizeAsync(height, width, pixels);

 // The RecognizeAsync method’s arguments are the image dimensions and byte array of image pixels in BGRA format. The extracted text and layout info are contained within OcrResult: //

            if (result.Lines != null)
string recognizedText = "";
foreach (var line in result.Lines)
foreach (var word in line.Words)
recognizedText += word.Text + " ";
recognizedText += Environment.NewLine;
OcrText.Text = recognizedText;

For more info about the OCR Library, visit MSDN page and download OCR library sample app. See the NuGet documentation for all the ways you can download and install the NuGet package in your project.

Happy Codiing!

Comments (0)

Skip to main content