ImageGear for C and C++ on Windows v19.9 - Updated
OCR an Image or Document
User Guide > How to Work with... > OCR > How to... > OCR an Image or Document

The recognition process is initiated by the IG_REC_image_recognize() function.

The IG_REC_image_recognize() function processes the single image identified by hImg parameter. The function takes the zone list of the image or if it is empty, automatically calls the page-layout decomposition process (auto-zoning).

Internally this function operates on a bi-tonal image. If the hImg image is not bi-tonal or the Image despeckle mode setting is enabled, an implicit secondary image conversion step is performed automatically to create a secondary image. This implicit image conversion can be influenced with previous calls to the IG_REC_secondary_reduction_mode_set() and IG_REC_despeckle_mode_set() functions.

The IG_REC_image_recognize() function enumerates the zones in the zone list and activates the appropriate recognition modules for them. The recognition modules are given the calculated Character Set information zone by zone.

After the recognition, the recognized data is attached to the HIG_REC_IMAGE. Recognition data contains the recognized character codes, position of each character on the image and various character formatting attributes, such as size, font type, etc. The data can be obtained using IG_REC_letters_get and modified using IG_REC_letters_set functions. It also can be either saved in recognition data file or converted to one of the supported text or document output formats.

Text output (simple or formatted) is available via the IG_REC_output_direct_text_write function. Calling IG_REC_output_direct_text_write repeatedly for different images with the same file argument appends the text being recognized to that file. The function also allows saving several pages being recognized in the same file at once. See Exporting Recognized Data Directly to Text Formats section for an example.

Output to document formats, such as Microsoft Word, WordPerfect, HTML, etc., is available via the document output API. Note that this API requires additional licensing.

Recognizing a Multi-Page Document

In order to allow saving multi-page documents, the Recognition component provides a document structure for the recognized pages. The document API allows creating a new document, opening an existing one, appending, removing, and updating pages. A document can be saved to various output formats, as well as to the native data format. See Exporting to a Formatted Output Document for more information and an example.