ABBYY Mobile OCR Engine 4

Go to: Contents | Guided Tour

How to Use the ABBYY Mobile OCR Engine Native Library

The ABBYY Mobile OCR Engine native library may be used for testing. The ABBYY Mobile OCR Engine library supplied as DLL and static library and as a wrapper of the library for Android and iOS may be found in the appropriate distributions.

This section contains description of how to work with DLL and static library.

Go to the Native Library API Reference section for detailed description of the ABBYY Mobile OCR Engine native library functions and structures.

Loading the library

You start your work with ABBYY Mobile OCR Engine by loading the library with help of the FineInitialize function. It allows you to specify memory allocation/de-allocation functions and a logging function. Then you need to specify the license information (see the Licensing section for details).

Note: If you use a trial license, the word "ABBYY" will appear in every 20th line in the recognized text and in every third recognized business card.

  1. [optional] Implement custom memory management functions and a logging function if you wish to use them.
  2. Call the FineInitialize function, passing these functions as input parameters. If you do not wish to use custom functions, pass 0 for the corresponding parameters.
  3. Load the license file into memory.
  4. Create a CFineLicenseInfo structure. Assign the pointer to the loaded license data to the LicenseData field and the size of loaded data to the DataLength field. Assign the name of your application to the ApplicationID field. It must correspond to the name of the application that is specified in the license file.
  5. Call the FineSetLicenseInfo function, passing to it the constant pointer to the CFineLicenseInfo structure you just configured.
  6. After specifying the license you can work with the library until the FineDeinitialize function is called.

Sample code of library initialization

Important! All functions of the ABBYY Mobile OCR Engine library should only be called from the thread in which the library was initialized. You cannot initialize the library in several threads simultaneously without deinitialization.

Opening and processing the images

Below is a description of a typical procedure performed by ABBYY Mobile OCR Engine:

  1. Load the image for recognition. You can open the image file with the help of the FineLoadImageFromFile function or load it from the input stream using the FineLoadImageFromInputStream function. These functions convert the image in JPEG or PNG format into CFineImage internal format of ABBYY Mobile OCR Engine. If you need to load an image in any other format, you must load it into memory and convert it into CFineImage format on your side. The functions which perform recognition work with the image in this format.
  2. Recognize the image. We will use the FineRecognizeImage function as an example. Configure the parameters in the following way:
  3. The CFineLayout structure you receive after the operation is completed contains all recognized text and its coordinates. Iterate through the blocks, the text lines within them, and the characters within text lines; save the text in the format you need, search it for keywords or work with it in any other way.

Note: By default, recognition operations will be performed in parallel, using up to 4 threads. You can change this limitation by calling the FineSetRecognizerThreadsCount after library initialization. Pass 1 for the threadsCount parameter to turn off multi-threading, or increase the number of threads if you need faster processing. However, the number of threads working simultaneously can never exceed the number of CPU cores the device provides.

See also

Description of the Native Sample