FineReader Engines Pool - Multithreading Sample

Language:
EN
Product-Line:
FineReader Engine
Version:
10, 11
Platform:
Windows
KB-Type:
Code Samples Collection
KB-Topic:
Programming Aspects
Category:
Recognition, OCR: Speed & Quality
Image:
image: icon_batchprocessingrecognition.gif

This sample on the one hand provides a complete reusable solution for a pool of Engines in a multi-threaded application, and on the other hand demonstrates the gain in speed when using multiprocessing.

Description

The sample processes images from a predefined folder (SampleImages\MultiProcessingRecognition). It creates a pool of Engine objects, which recognize images from this folder in parallel. The default number of threads equals the number of CPU cores. You can reduce it to compare the difference in speed.

To run the sample, click Go.

The sample uses the following procedure for initialization of a processor:

  • Use the OutprocLoader object to load the Engine object as an out-of-process server:
    1. Create a new OutprocLoader for each thread you want to start.
    2. Create an instance of Engine object using the GetEngineObject method of the OutprocLoader object.
  • For each worker thread:
    1. Load a predefined profile for your scenario using the LoadPredefinedProfile method of the Engine object.
    2. Call the CreateFRDocument method of the Engine object to create the FRDocument object.
    3. Add images to the document using AddImageFile method of the FRDocument object.
    4. [optional] Create the DocumentProcessingParams object and set the parameters of analysis, recognition, and synthesis.
    5. Call the Process method of the FRDocument object.
    6. [optional] Create an export parameter object of the type you need. The type of this object depends on the format of the output file you would like to use (FileExportFormatEnum). The default object values are the ones used most frequently, but you may set the export parameters as you like.
    7. Call the Export method of the FRDocument object to save the document into a file of the specified format.
    8. Close the FRDocument object using the Close method.
    9. Unload each FineReader Engine — use the ExplicitlyUnload method of the OutprocLoader object.

Please refer to the source code for implementation details.


Back To:

This website uses cookies which enable you to see pages or use other functions of our websites. You can turn off such cookies in your browser’s settings. If you continue to use these pages, you consent to the use of cookies.