Microsoft OCR Library Sample

This sample demonstrates how to use the Microsoft OCR Library for Windows Runtime to extract text in the specified language from an image.

Note  

This sample requires you to download and install the OCR Library into the sample project. The OCR Library is a NuGet package. For more info, see the instructions on this page. 

This sample demonstrates following features:

  • Extract text in the specified language from an image.
  • Overlay extracted text over the image.

The OCR Library reads text from images and returns the text and layout information. All of this happens locally on the user's device. When you add the OCR Library to an application, you control how your application interprets the returned text. When the OCR Library recognizes patterns, such as email addresses, phone numbers, and URIs, your app can launch common actions such as sending an email, making a phone call, or visiting a web site.

To use the OCR Library in your app, call the RecognizeAsync method of the OcrEngine class. This method returns an OcrResult object, which contains the recognized text and its size and position. The result is split into lines, and the lines are split into words.

For more info about the OCR Library, see WindowsPreview.Media.Ocr.

To obtain an evaluation copy of Windows 8.1, go to Windows 8.1.

To obtain an evaluation copy of Microsoft Visual Studio 2013, go to Visual Studio 2013.

Downloading and installing the OCR Library

See the NuGet documentation for all the ways you can download and install the NuGet package in your project. To install the package from within Microsoft Visual Studio, do the following:

  1. In Visual Studio, select PROJECT | Manage NuGet Packages.
  2. In the Online section, select nuget.org. Search for Microsoft.Windows.Ocr.
  3. Click Install.
  4. Select BUILD | Configuration Manager to change the build configuration of your project from AnyCPU to x86, x64, or ARM.
  5. If Intellisense does not work after you have installed the NuGet package, unload and reload the Visual Studio project. In Solution Explorer, right-click the project and select Unload Project. Then right-click the project again and select Reload Project.

Operating system requirements

Client
Windows 8.1
Server
Windows Server 2012 R2
Phone
Windows Phone 8.1

Build the sample 

  1. Start Visual Studio Express 2013 for Windows --> and select File > Open > Project/Solution.
  2. Go to the directory in which you unzipped the sample. Go to the directory named for the sample, and double-click the Visual Studio Express 2013 for Windows Solution (.sln) file.
  3. Press F7 or use Build > Build Solution to build the sample. 

Run the sample

To debug the app and then run it, press F5 or use Debug > Start Debugging. To run the app without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.