Running the Sample Microsoft OCR Application

To support Optical Character Recognition (OCR), Microsoft has developed the Microsoft OCR Library. This library helps developers to extract text from images (containing printed text) after taking it as input. A good read would be an article on achieving OCR in Windows Store Apps using Bing OCR Control (Getting Started With Optical Character Recognition (OCR) in Windows Store Apps). WindowsPreview.Media.Ocr is the library responsible for providing the optical character recognition feature in your Windows Phone 8.1 and Windows 8.1 applications. Learn more about the WindowsPreview.Media.Ocr namespace from the webpage: WindowsPreview.Media.Ocr namespace . You can also use this library by installing it using the NuGet Package Manager.

The following is the procedure for getting started with the library.

  1. Download the Microsoft OCR Library Sample from: http://code.msdn.microsoft.com/Uses-the-OCR-Library-to-2a9f5bf4#content

    The solution you download from this link will be a Universal application. So, you will have two projects targeting Windows 8.1 and Windows Phone 8.1 platforms in the same solution. Use the following library installation procedure for both Windows 8.1 and Windows Phone 8.1 projects present in the single solution. The sample code targets the Universal Windows App and hence the solution contains both Windows and Windows Phone projects. Learn more about building Universal Windows Apps ( Build universal Windows apps that target Windows and Windows Phone ).

  2. Right-click on the project and go to NuGet Package Manager.

    NuGet Package Manager

  3. Install the Microsoft OCR Library.

    Microsoft OCR Library

    As shown in the preceding screen, search for Microsoft.Windows.Ocr in the Manage NuGet Packages search box. Install the Microsoft OCR Library as shown above.

  4. Accept the License and complete the installation.

    Accept the License

    Read the license terms and click on “I Accept” as shown in the preceding screen. Once you accept the license, the library is installed as shown in the following screen.

    install the Microsoft OCR Library

  5. Check for the added OCR reference under the References section of the project.

    Add Microsoft OCR Library

  6. Deploying the sample application.

    Since there are two projects targeting Windows 8.1 and Windows Phone 8.1, build both the projects and create packages for both. For Windows Phone 8.1, you can connect your Windows Phone device with the Windows Phone 8.1 OS and deploy the application directly onto the phone. If you would like to see the app onWindows 8, then you need a Windows 8.1 device with a rear facing camera. Therefore, you cannot run the app in a Windows 8 emulator or on your local machine. You can deploy the app on your tablets with Windows 8.1 running in it. This is because tablets have a rear facing camera and thereby the app will always work fine on them. Read and follow how to create and install Windows Store App packages (Creating and Installing Windows Store App Packages ).

  7. How the sample app works

    Since it is a Universal Windows App, it has a shared project that will be shared by both Windows 8.1 and Windows Phone 8.1 projects.

    shared project

    The preceding screen shows the Solution Explorer of the Microsoft OCR Library sample. You can see the “Shared” project in the solution that is nothing but the project shared by both of the Windows 8.1 and Windows Phone 8.1 projects. The Scenario1_ExtractText.xaml file and the code behind file of it have all the necessary code to extract text from the input image. The OcrEngine class implements all the methods responsible for Optical Character Recognition (OCR). Therefore the OcrEngine class is used to implement OCR within the Scenario1_ExtractText.xaml.cs file. The OcrEngine class is present in the WindowsPreview.Media.Ocr namespace. 


Similar Articles