RecAPI
|
Performing Optical Character Recognition. More...
Topics | |
Recognition Engines having own functions | |
There are some recognition engines having one or more own functions or types. | |
Classes | |
struct | STATISTIC |
Recognition statistics. More... | |
struct | _RPPERRORS |
Error list item. More... | |
Typedefs | |
typedef STATISTIC * | LPSTATISTIC |
Pointer type to a STATISTIC type variable. | |
typedef INTBOOL RECKRNCALL | ONETOUCH_CB(INTBOOL bMore, void *pContext, LPCTSTR *notused) |
The user-written "One-touch" callback function. | |
typedef ONETOUCH_CB * | LPONETOUCH_CB |
Pointer to a ONETOUCH_CB callback function. | |
typedef struct _RPPERRORS | RPPERRORS |
Error list item. | |
Enumerations | |
enum | RMTRADEOFF { TO_ACCURATE , TO_BALANCED , TO_FAST } |
Trade-off setting. More... | |
enum | PDF_REC_MODE { PDF_RM_ALWAYSRECOGNIZE , PDF_RM_MOSTLYGETTEXT , PDF_RM_ALWAYSGETTEXT } |
PDF recognition mode. More... | |
enum | PDF_PROC_MODE { PDF_PM_AUTO , PDF_PM_NORMAL , PDF_PM_GRAPHICS_ONLY , PDF_PM_TEXT_ONLY , PDF_PM_TEXT_ONLY_EXT , PDF_PM_AS_IMAGE } |
PDF processing mode. More... | |
Functions | |
RECERR RECAPIKRN | kRecSetRMTradeoff (int sid, RMTRADEOFF Tradeoff) |
Changing trade-off setting. | |
RECERR RECAPIKRN | kRecGetRMTradeoff (int sid, RMTRADEOFF *pTradeoff) |
Getting trade-off setting. | |
RECERR RECAPIKRN | kRecSetDefaultFillingMethod (int sid, FILLINGMETHOD type) |
Changing default filling method. | |
RECERR RECAPIKRN | kRecGetDefaultFillingMethod (int sid, FILLINGMETHOD *ptype) |
Getting default filling method. | |
RECERR RECAPIKRN | kRecSetDefaultRecognitionModule (int sid, RECOGNITIONMODULE rm) |
Changing the default recognition module. | |
RECERR RECAPIKRN | kRecGetDefaultRecognitionModule (int sid, RECOGNITIONMODULE *rm) |
Getting the default recognition module. | |
RECERR RECAPIKRN | kRecSetTrainingFileName (int sid, LPCTSTR pFileName) |
Setting the training file. | |
RECERR RECAPIKRN | kRecGetTrainingFileName (int sid, LPTSTR pFileName, size_t iSize) |
Getting the name of the training file. | |
RECERR RECAPIKRN | kRecRecognize (int sid, HPAGE hPage, LPCTSTR pFilename) |
Recognizing a page. | |
RECERR RECAPIKRN | kRecProcessPages (int sid, LPCTSTR pDocFile, LPCTSTR *pImageFiles, LPONETOUCH_CB pCallback, void *pContext, LPCTSTR pTemplate) |
Process multiple pages and convert them to a single document. | |
RECERR RECAPIKRN | kRecProcessPagesEx (int sid, LPCTSTR pDocFile, LPCTSTR *pImageFiles, LPONETOUCH_CB pCallback, void *pContext, LPCTSTR pTemplate) |
Process multiple pages and convert them to a single document using multiple recognition threads. | |
RECERR RECAPIKRN | kRecGetRPPErrorList (RPPERRORS **rppErrs) |
Getting errors from last kRecProcessPagesEx. | |
RECERR RECAPIKRN | kRecGetStatistics (int sid, LPSTATISTIC pStat) |
Getting statistics about processing. | |
Performing Optical Character Recognition.
The Engine can load several recognition engines. The User License determines which ones are available. Select which available engine to run in a given ZONE. According to your choice, the application is able to perform "multi-module" recognition on any image.
The enum RECOGNITIONMODULE lists recognition modules. These are tightly integrated to the Engine.
You can set an additional RECOGNITIONMODULE value: RM_AUTO. If you set this, the Engine will choose the module that is most likely to be appropriate. The decision of the Engine is primarily based on the filling method set for the zone.
The filling method describes the type of data expected in the zone, e.g. a barcode, handprinted or machine generated text. A certain degree of auto-detection is available for setting the filling method: see the Detection of filling method of zones section. You might find this particularly useful when you cannot be sure in advance precisely what filling method to use on the incoming documents. It is essential to specify a valid recognition module-filling method pair. Any incorrectly set zone will have no recognition result. Some filling methods can be linked successfully with one and only one recognition module (e.g. FM_OMR with RM_OMR). Other recognition modules support more than one filling method, and some filling methods are accepted by more than one recognition module. For example, if you work with a medium quality, 9-pin dot-matrix text, either the RM_DOT or one of the omnifont modules could give better results. On a medium quality, 24-pin dot-matrix text, try RM_OMNIFONT_MOR with FM_DRAFTDOT24 and FM_OMNIFONT.
For details on the above and recognition engines see OCR Engines.
RM_AUTO reads the filling method of the zone; if only one recognition module is suitable, that one is used. When there is a choice of recognition modules, RM_AUTO uses various checks (character set, image size, etc.) to select the best one. This way, it prevents an invalid Filling method - Recognition module pair.
If the recognition module is not present when it is needed, the recognition function (kRecRecognize) returns with API_MODULEMISSING_ERR, and there will be no recognized data for the zone in question. To avoid this, call kRecGetModulesInfo just after Engine initialization. This will check the presence and correct installation of the necessary recognition modules.
The working of the Recognition Modules can be adjusted with settings in some points.
PDF files can be separated into two basic classes: image-only PDF and normal PDF. Recognition of image-only PDF is exactly the same as that of any other image format. The normal PDF contains both image and text data. This textual information can be retrieved from the file and used as an aid to the recognition.
In general, the text residing in a PDF file is reliable, thus even a less accurate OCR result combined with this text may be enough to achieve good accuracy. When performing this, the User can adjust the PDF trade-off setting (Kernel.OcrMgr.PDF.TradeOff). Furthermore, the User can specify the mode for handling the text located in a PDF file (PDF_REC_MODE).
The textual information divides the page into graphic and text areas. The User can select which one should be recognized during the OCR process (PDF_PROC_MODE).
typedef INTBOOL RECKRNCALL ONETOUCH_CB(INTBOOL bMore, void *pContext, LPCTSTR *notused) |
The user-written "One-touch" callback function.
It allows user intervention in the "One-touch" processing functions. This user-written function is called by the Engine after each processed page, either by the kRecProcessPages or by the kRecScanPages functions (furthermore by RecAPIPlus function RecProcessPagesEx).
[in] | bMore | After processing each page, the Engine calls this function with this parameter indicating whether there are further pages to be processed (i.e. whether or not an ADF still has paper, or whether or not there are further pages in a multi-page image file). |
[in] | pContext | User data passed to the callback function by the Engine. The data to be passed can be set with kRecSetCBProgMon. |
[out] | notused | Not used. |
TRUE | The Engine is to continue with the next page. |
FALSE | The Engine is to abort processing pages. |
typedef struct _RPPERRORS RPPERRORS |
Error list item.
This struct contains an item of the error list retrieved by kRecGetRPPErrorList or RecGetRPPErrorList.
enum PDF_PROC_MODE |
PDF processing mode.
This setting specifies the processing mode of graphic and text areas of PDF files. See PDF recognition for details. See the setting Kernel.OcrMgr.PDF.ProcessingMode.
PDF_PM_TEXT_ONLY_EXT
. PDF_PM_AS_IMAGE
and IMF_PDF_AS_IMAGE mode of IMF PDF load flags are different. Both are slower than normal PDF mode and both process the PDF file as an image. However in PDF_PM_AS_IMAGE
mode recognition combines the text information coming from the PDF with the raw result of the OCR process. enum PDF_REC_MODE |
PDF recognition mode.
This setting specifies the usage of text data coming from normal PDF files (non-image-only PDF). See PDF recognition for details. See the setting Kernel.OcrMgr.PDF.RecognitionMode.
enum RMTRADEOFF |
Trade-off setting.
This specifies the possible Engine trade-off settings to be applied during the recognition at page level. This setting has a trade-off influence between the accuracy and the speed of recognition. The precise influence depends on the recognition module used. This setting may also influence which auto-zoning and pre-process algorithm will be applied.
Kernel.OcrMgr.TradeOff
can be set by calling kRecSetRMTradeoff kRecLocateZones
is not called, or when a one-step function is called (e.g. kRecProcessPages or RecProcessPagesEx). In such a case, setting Kernel.OcrMgr.TradeOff.PreProc to TO_ACCURATE and Kernel.Decomp.Method to DCM_STANDARD will ensure preprocess and zoning to run in default independently from the value of trade-off. Enumerator | |
---|---|
TO_ACCURATE | Most accurate recognition (Default). |
TO_BALANCED | Mid-level accuracy/speed recognition. |
TO_FAST | Fast recognition. |
RECERR RECAPIKRN kRecGetDefaultFillingMethod | ( | int | sid, |
FILLINGMETHOD * | ptype ) |
Getting default filling method.
The kRecGetDefaultFillingMethod function gets the default filling method setting.
[in] | sid | Settings Collection ID. |
[out] | ptype | Address of a variable to get the default filling method setting. |
RECERR |
RECERR RECAPIKRN kRecGetDefaultRecognitionModule | ( | int | sid, |
RECOGNITIONMODULE * | rm ) |
Getting the default recognition module.
The kRecGetDefaultRecognitionModule function retrieves the default recognition module setting.
[in] | sid | Settings Collection ID. |
[in] | rm | Pointer of a variable to store the default recognition module. |
RECERR |
RECERR RECAPIKRN kRecGetRMTradeoff | ( | int | sid, |
RMTRADEOFF * | pTradeoff ) |
Getting trade-off setting.
The kRecGetRMTradeoff function provides the current recognition algorithm trade-off setting. See kRecSetRMTradeoff.
[in] | sid | Settings Collection ID. |
[out] | pTradeoff | Pointer of a variable to get the current recognition algorithm trade-off setting. |
RECERR |
Getting errors from last kRecProcessPagesEx.
The kRecGetRPPErrorList function returns the error list of last kRecProcessPages or kRecProcessPagesEx call.
[out] | rppErrs | Pointer of a variable to store a pointer of an internal array. This array contains data for the errors that happened. |
RECERR |
RECERR RECAPIKRN kRecGetStatistics | ( | int | sid, |
LPSTATISTIC | pStat ) |
Getting statistics about processing.
The kRecGetStatistics function returns information about the accuracy and timing data of the latest recognition process in a structure STATISTIC.
[in] | sid | Settings Collection ID. |
[out] | pStat | Address of a structure to hold the statistical information. |
RECERR |
RECERR RECAPIKRN kRecGetTrainingFileName | ( | int | sid, |
LPTSTR | pFileName, | ||
size_t | iSize ) |
Getting the name of the training file.
The kRecGetTrainingFileName function gets the current training file name setting.
[in] | sid | Settings Collection ID. |
[out] | pFileName | Pointer of a buffer where the training file name setting will be copied to. |
[in] | iSize | Character count of the buffer. The buffer must be large enough to hold all the characters and a terminating zero. |
RECERR |
RECERR RECAPIKRN kRecProcessPages | ( | int | sid, |
LPCTSTR | pDocFile, | ||
LPCTSTR * | pImageFiles, | ||
LPONETOUCH_CB | pCallback, | ||
void * | pContext, | ||
LPCTSTR | pTemplate ) |
Process multiple pages and convert them to a single document.
This function performs recognition on more than one image file using the Direct TXT output converter to export the results in one common document. If there is more than one page in the specified image file or there are more image files, export can be done only to appendable DirectTXT formats (DTXTOUTPUTFORMATS).
[in] | sid | Settings Collection ID. |
[in] | pDocFile | Full path of the output document file. |
[in] | pImageFiles | This is the pointer of an array of full paths of the input files. If this is NULL the input is a scanner. The latest path must be a NULL pointer indicating the end of the input list. |
[in] | pCallback | Callback function's pointer, which is called after each page. Can be NULL. |
[in] | pContext | Context value for passing to the callback function. Can be NULL. |
[in] | pTemplate | Full path of a zone file to be loaded before recognition of each image. |
RECERR |
RECERR RECAPIKRN kRecProcessPagesEx | ( | int | sid, |
LPCTSTR | pDocFile, | ||
LPCTSTR * | pImageFiles, | ||
LPONETOUCH_CB | pCallback, | ||
void * | pContext, | ||
LPCTSTR | pTemplate ) |
Process multiple pages and convert them to a single document using multiple recognition threads.
This function performs recognition on more than one image file using the Direct TXT output converter module to export the results in one common document. If there is more than one page in the specified image file or there are more image files, export can be done only to appendable DirectTXT formats (DTXTOUTPUTFORMATS).
[in] | sid | Settings Collection ID. |
[in] | pDocFile | Full path of the output document file or output folder. By default, the function appends all processed page to one output file specified in pDocFile parameter. Set the setting Kernel.RPP.OutputFileName to 1, if multiple output files are intended to create for each input in the given folder. The folder must exist. When the pDocFile parameter specifies only a path, ending path separator must be there. HSETTING hOF = NULL;
kRecSettingGetHandle(NULL, "Kernel.RPP.OutputFileName", &hOF, NULL);
kRecSettingSetInt(0, hOF, 1);
RECERR RSTSAPI kRecSettingGetHandle(HSETTING root_of_query, const char *symb_name, HSETTING *ret_handle, INTBOOL *has_setting) Getting the handle of a node. RECERR RSTSAPI kRecSettingSetInt(int sid, HSETTING sett, int new_value) Setting the value of an STS_INT or STS_ENUM or STS_BOOL setting. |
[in] | pImageFiles | This is the array pointer of the input files' full paths. If this is NULL the input is a scanner. The latest path must be a NULL pointer indicating the end of the input list. |
[in] | pCallback | Callback function's pointer, called after each page. Can be NULL. |
[in] | pContext | Context value for passing to the callback function. Can be NULL. |
[in] | pTemplate | Full path of a zone file to be loaded before recognition of each image. Can be NULL. |
RECERR |
pImageFile
parameter of the ONETOUCH_CB callback function at all. Recognizing a page.
The kRecRecognize function performs the recognition task for a page in the engine's authority.
The function utilizes the zone information to activate the appropriate recognition module on every zone. Each recognition module recognizes the image parts assigned to it in the zone list. If the OCR zone list of the page is empty the PID_DECOMPOSITION page-layout decomposition process will be activated automatically in order to create a zone list for the image, before recognition.
The function offers the services of the checking module for either marking suspicious characters and words, or making the recognition result better.
After having recognized all the zones on the page, the function collects the necessary information about the recognized characters into a homogeneous structure, called the recognition result. It is stored in the HPAGE.
The kRecRecognize function may activate one or more of the processes PID_RECOGNITION1, PID_RECOGNITION2, PID_RECOGNITION3 and PID_SPELLING.
[in] | sid | Settings Collection ID. |
[in] | hPage | Handle of the page to be recognized. |
[in] | pFilename | Specifies how the recognition result must be stored. If this is not NULL, it must be a real file name with a full path; the recognition result will be stored in this file. |
RECERR |
pFilename
does not exist, it will be created, otherwise the newly recognized information is appended to the existing one, if that is an appendable format. For more information about available formats, see kRecConvert2DTXT. pFilename
should be NULL
.kRecConvert2DTXT
can accept array of HPAGEs. Or we want to do something with the HPAGE
between kRecRecognize
and kRecConvert2DTXT
function calls.NULL
pFilename
and call kRecConvert2DTXTEx
always for creating PDF files.HPAGE
will be inserted an HDOC using RecInsertPage. RECERR RECAPIKRN kRecSetDefaultFillingMethod | ( | int | sid, |
FILLINGMETHOD | type ) |
Changing default filling method.
The kRecSetDefaultFillingMethod
function specifies the default filling method. The default filling method is applied to all zones on the page with the FM_DEFAULT value in their ZONE::fm field. This substitution of the filling method happens at the beginning of the kRecRecognize calls.
[in] | sid | Settings Collection ID. |
[in] | type | Default filling method. |
RECERR |
RECERR RECAPIKRN kRecSetDefaultRecognitionModule | ( | int | sid, |
RECOGNITIONMODULE | rm ) |
Changing the default recognition module.
The kRecSetDefaultRecognitionModule function specifies the default recognition module setting. This setting is used to determine the recognition module to be applied for the zones with RM_AUTO in their ZONE::rm field.
[in] | sid | Settings Collection ID. |
[in] | rm | Default recognition module. |
RECERR |
RM_AUTO
, take care to use compatible filling method / recognition module combinations only. RECERR RECAPIKRN kRecSetRMTradeoff | ( | int | sid, |
RMTRADEOFF | Tradeoff ) |
Changing trade-off setting.
The kRecSetRMTradeoff function specifies a trade-off setting to be applied during preprocessing, auto-zoning and recognition. This setting applies to all recognition modules that can interpret a speed-accuracy trade-off setting.
[in] | sid | Settings Collection ID. |
[in] | Tradeoff | Recognition algorithm trade-off setting to be set. |
RECERR |
TO_ACCURATE
is applied. Kernel.OcrMgr.TradeOff
. RECERR RECAPIKRN kRecSetTrainingFileName | ( | int | sid, |
LPCTSTR | pFileName ) |
Setting the training file.
The kRecSetTrainingFileName function specifies and loads a training file for the omnifont recognition modules. A training file contains the results of a previous training session, and its use may influence the behavior of these recognition modules.
[in] | sid | Settings Collection ID. |
[in] | pFileName | Name of the training file, or NULL. The NULL is used for disabling the use of a previously loaded training file. |
RECERR |