Initializing the OCR Interface

Top  Previous  Next

The DTWAIN OCR Interface must first be initialized using DTWAIN_InitOCRInterface.

 

The DTWAIN_InitOCRInterface searches for any supported OCR engines.  Here are the various OCR engines, and what is required for DTWAIN_InitOCRInterface to correctly initialize them:

 

OCR Engine

Required module(s)

 

Transym OCR Engine (version 2.0. and higher)

TOCRDLL.DLL (must exist in an accessible path)



 

The DTWAIN_InitOCRInterface will attempt to find and initialize all of the supported OCR engines.   The DTWAIN_InitOCRInterface function returns TRUE on success, FALSE otherwise.

 

Once DTWAIN_InitOCRInterface returns, your application can query the OCR interfaces that were detected and initialized.

 

For example, the DTWAIN_EnumOCRInterfaces function loads into a DTWAIN_ARRAY all of the OCR interfaces.  The code below uses DTWAIN_InitOCRInterface and DTWAIN_EnumOCRInterfaces to display the Product Name of the OCR Engine.  The Product Name can then be used to select the OCR engine (DTWAIN_SelectOCREngineByName).

 

#include <stdio.h>

DTWAIN_ARRAY OCR;

DTWAIN_OCRENGINE theEngine;

char buffer[100];

//...

DTWAIN_InitOCRInterface( );

DTWAIN_EnumOCRInterfaces( &OCR );

LONG nCount = DTWAIN_ArrayGetCount( OCR );

 

for (LONG i = 0; i < nCount; ++i )

{

  DTWAIN_ArrayGetAtLong( OCR, i, &theEngine );

  DTWAIN_GetOCRProductName( theEngine, buffer, 99 );

   printf( "OCR Engine %d: %s\n", i, buffer );

}

 

DTWAIN_ArrayDestroy( OCR );

 

Note that the DTWAIN_OCRENGINE type is used to denote an OCR engine.

 

Next: Selecting an OCR engine for use