RecAPI
|
General operations and data. More...
Classes | |
struct | KRECMODULEINFO |
Module info. More... | |
struct | PROGRESSMONITOR |
Progress information. More... | |
Modules | |
Error Handling Module | |
Error information. | |
Settings Manager Module | |
This is the manager of settings at the KernelAPI level. | |
Typedefs | |
typedef KRECMODULEINFO * | LPKRECMODULEINFO |
Pointer to a structure KRECMODULEINFO. | |
typedef PROGRESSMONITOR * | LPPROGRESSMONITOR |
Pointer to a PROGRESSMONITOR. | |
typedef RECERR RECKRNCALL | PROGMON_CB (LPPROGRESSMONITOR mod, void *pContext) |
The user-written progress monitoring callback function. | |
typedef PROGMON_CB * | LPPROGMON_CB |
Pointer to a callback PROGMON_CB. | |
Enumerations | |
enum | KRECMODULES { INFO_API = 0, INFO_MOR, INFO_DOT, INFO_BAR, INFO_OMR, INFO_HNR, INFO_DCM, INFO_IMG, INFO_IMF, INFO_CHR, INFO_DTXT, INFO_SPL, INFO_RSD, INFO_RER, INFO_MGR, INFO_MTX, INFO_MAT, INFO_RESERVED_P, INFO_PLUS2W, INFO_FRX, INFO_PLUS3W, INFO_ASN, INFO_XOCR, INFO_LFR, INFO_ASP, INFO_SIZE } |
Module identifiers. More... | |
enum | PROCESSID { PID_IMGINPUT = 0, PID_IMGSAVE, PID_IMGPREPROCESS, PID_DECOMPOSITION, PID_RECOGNITION1, PID_RECOGNITION2, PID_RECOGNITION3, PID_SPELLING, PID_FORMATTING, PID_WRITEFOUTDOC, PID_CONVERTIMG, PID_SCANNER_WARMUP } |
Progress identifiers. More... | |
Functions | |
RECERR RECAPIKRN | kRecSetSandboxHomePath (const char *homepath) |
Setting the Sandbox path on MacOS. | |
RECERR RECAPIKRN | kRecSetSandboxTempPath (const char *temppath) |
Setting the Sandbox temporary path on MacOS. | |
RECERR RECAPIKRN | kRecSetLicense (LPCTSTR pLicenseFile, LPCTSTR pCode) |
Setting the OEM license information. | |
RECERR RECAPIKRN | kRecInit (LPCTSTR pCompanyName, LPCTSTR pProductName) |
Initializing KernelAPI. | |
RECERR RECAPIKRN | kRecQuit (void) |
Closing KernelAPI. | |
RECERR RECAPIKRN | kRecSetUILang (const char *lang) |
Setting the language of displayed information. | |
RECERR RECAPIKRN | kRecGetUILang (char *langbuff, size_t buffersize) |
int RECAPIKRN | kRecCreateSettingsCollection (int sid) |
Creating a new Settings Collection. | |
RECERR RECAPIKRN | kRecDeleteSettingsCollection (int sid) |
Deleting a Settings Collection. | |
RECERR RECAPIKRN | kRecGetSerialNumber (LPTSTR pSn, size_t buflen) |
int RECAPIKRN | kRecGetVersion (void) |
Getting version. | |
RECERR RECAPIKRN | kRecSetCBProgMon (int sid, LPPROGMON_CB pCallBack, void *pContext) |
Setting progress monitor. | |
RECERR RECAPIKRN | kRecSetTimeOut (int sid, DWORD TimeOut) |
Setting timeout period. | |
RECERR RECAPIKRN | kRecGetTimeOut (int sid, LPDWORD pTimeOut) |
Getting timeout period. | |
RECERR RECAPIKRN | kRecFree (void *pArray) |
Freeing memory objects. | |
RECERR RECAPIKRN | kRecGetModulesInfo (LPKRECMODULEINFO *ppModules, size_t *pSize) |
Getting module information. | |
RECERR RECAPIKRN | kRecLoadSettings (int sid, LPCTSTR pFileName) |
Loading settings. | |
RECERR RECAPIKRN | kRecSaveSettings (int sid, LPCTSTR pFileName) |
Saving settings of KernelAPI. | |
RECERR RECAPIKRN | kRecSetDefaults (int sid) |
Changing settings of KernelAPI to default. |
General operations and data.
This module contains the basic types and functions necessary to use the general services of the KernelAPI. Initialization (kRecInit, kRecQuit) is an essential prerequisite for utilizing KernelAPI functionality. User authorization can also be performed in this module.
Useful information can be got about itself the Engine (e.g. accessible modules by kRecGetModulesInfo).
Most RecAPI operations work through Settings Collections. A Settings Collection acts as a kind of profile. It is a separate storage for operation settings (handled by Settings Manager Module). Distinct sessions can store different values for given settings. A Settings Collection is authorized by an identifier. This identifier must be passed to all operations using that Settings Collection. The Collection with the ID 0 is cretaed automatically during the initialization of the Capture SDK. Settings Collections can be user-created or deleted, using the functions kRecCreateSettingsCollection, kRecDeleteSettingsCollection, respectively. You can also save or load settings here.
The same Settings Collections can be used from different threads. (Multi-threading is supported on: Windows.) Furthermore, one thread can use more than one Settings Collection. For more information, see the topic Multi-threading in RecAPI.
Kernel.Timeout.Hard is an additional amount of time over the normal Kernel.Timeout time. The addition of the two values provides a hard timeout limit. This is designed this way in order to have a single kRecSetTimeOut call effectively change both the normal and hard timeout values. By default the hard timeout setting adds 10 seconds to the normal one.
Normally the timeout is checked at clean processing places inside recognition. If the engine detects that the normal timeout limit has been passed, it returns API_TIMEOUT_ERR if it can safely and cleanly return from the middle of a long recognition before the hard timeout is reached. If it cannot then a separate thread terminates the possible infinite loop when the additional hard timeout period is over and the engine returns API_HARDTIMEOUT_ERR. In this case the engine might be in an unstable state so further normal functioning is not guaranteed. We suggest that the user terminates and restarts the process to be in a clean state again.
See also timeout handling in the tutorial.
typedef RECERR RECKRNCALL PROGMON_CB(LPPROGRESSMONITOR mod, void *pContext) |
The user-written progress monitoring callback function.
This user-written callback procedure for progress monitoring must be registered by the kRecSetCBProgMon function. The Engine will continually invoke this registered callback procedure during different workflow processes (PROCESSID), providing a pointer to a PROGRESSMONITOR structure that contains the current processing stage and a percentage indicator value. The application can provide progress indication for this procedure.
[in] | mod | This variable holds the current state of the activated action (ProcessID, progress information etc). |
[in] | pContext | User data passed to the callback function by the Engine. The data to be passed can be set with kRecSetCBProgMon. |
API_PROCESS_ABORTED_ERR | The user has requested the current processing to be aborted: processing will stop at the first suitable moment. |
REC_OK | Process can be continued normally. |
enum KRECMODULES |
Module identifiers.
Use the kRecGetModulesInfo function to get information on the current Engine configuration.
enum PROCESSID |
Progress identifiers.
Identifiers of the most important internal processes of the Engine, such as image loading, image saving, recognizing, etc. Each process listed below represents one of the fundamental services provided by the Engine. Applications will use one or more of these processes. Each process can be initiated by the relevant function (see below). The PROGMON_CB callback function can be used to generate progress monitoring for any of these processes.
kRecSetXX
and kRecGetXX
),PID_IMGINPUT |
Identifies the Image loading process. The source can be the scanner, image file or image stored in the application buffer (application memory); kRecLoadImg, kRecLoadImgF. |
PID_IMGSAVE |
Identifies the image saving process. During this process the image or a part of it is saved to an image file; kRecSaveImg. |
PID_IMGPREPROCESS |
Identifies the Image preprocessing process; kRecPreprocessImg. |
PID_DECOMPOSITION |
Identifies the page-layout decomposition process; kRecLocateZones. |
PID_RECOGNITION1 |
Identifies the 1st pass of the Recognition process; kRecRecognize. |
PID_RECOGNITION2 |
Identifies the 2nd pass of the Recognition process; kRecRecognize using recognition engine PLUS2W or PLUS3W. |
PID_RECOGNITION3 |
3rd pass of the Recognition process using recognition engine PLUS3W. |
PID_SPELLING |
Identifies the Checking process. |
PID_FORMATTING |
Page and Document formatting. |
PID_WRITEFOUTDOC |
Identifies the process for writing the recognized text to the final output document (to file or to memory); RecConvert2Doc. |
PID_CONVERTIMG |
Identifies the image conversion process activated by the PID_WRITEFOUTDOC process for saving the image of a graphical image zone to the word processor output document; RecConvert2Doc. |
PID_SCANNER_WARMUP |
scanner is warming up. |
int RECAPIKRN kRecCreateSettingsCollection | ( | int | sid | ) |
Creating a new Settings Collection.
A Settings Collection is a container of the values of all settings of all modules of KernelAPI/APIPlus. See the settings API in KrnStsApi.h
. All functions that have an effect on settings or are affected by settings receive a Settings Collection ID in the parameter list.
[in] | sid | The parent collection. If it is -1, the new collection will contain the settings with their default values. If it is the ID of an already existing collection, the values will be copied from it. |
int | ID of the created Settings Collection. -1 means CSDK cannot create new Settings Collection. The upper limit of the number of Settings Collections is 100, however CSDK cannot create a new one also after kRecQuit (or before kRecInit). |
int kRecCreateSettingsCollection(int sid);
RECERR RECAPIKRN kRecDeleteSettingsCollection | ( | int | sid | ) |
Deleting a Settings Collection.
The kRecDeleteSettingsCollection function deletes the specified collection.
[in] | sid | Settings Collection ID. |
RECERR |
RECERR kRecDeleteSettingsCollection(int sid);
RECERR RECAPIKRN kRecFree | ( | void * | pArray | ) |
Freeing memory objects.
The kRecFree function frees the memory object previously made available to the application with the assistance of a KernelAPI function.
[in] | pArray | Pointer to the data to be released. |
RECERR |
pArray
could be a pointer retrieved by any of the following functions: kRecGetLetters, kRecGetChoiceStr, kRecGetSuggestionStr, kRecGetFontFaceStr, kRecGetLetterPalette, kRecGetOCRZoneText, kRecGetOCRTableCellText, kRecGetImgArea, kRecGetImgAreaEx, kRecRotateImgArea, kRecRemovePunchHoles, kRecGetZoneLayout, kRecGetOCRZoneLayout, kRecGetZoneNodeArray, kRecGetOCRZoneNodeArray, kRecGetHSplitters, kRecGetVSplitters, kRecGetZoneName, kRecGetOCRZoneName, kRecGetZoneAttribute, kRecGetOCRZoneAttribute, kRecGetNextZoneAttribute, kRecGetNextOCRZoneAttribute, kRecGetZoneFormFieldName, kRecGetOCRZoneFormFieldName, kRecGetFormTemplateName, kRecGetTemplateAttribute, kRecGetNextTemplateAttribute, kRecGetMatchingInfo, kRecGetLastErrorEx. RECERR RECAPIKRN kRecGetModulesInfo | ( | LPKRECMODULEINFO * | ppModules, |
size_t * | pSize | ||
) |
Getting module information.
The kRecGetModulesInfo function obtains information about the available modules of Engine.
[in] | ppModules | Address of a pointer to the module information array. |
[in] | pSize | Address of a variable holding the number of module information structures. |
RECERR |
LPKRECMODULEINFO pModules; size_t size; INTBOOL bOMR_available = FALSE; INTBOOL bPLUS_available = FALSE; RECERR rc; rc = kRecSetLicense(YOUR_LICENSE_FILE, YOUR_OEM_CODE); if (REC_OK) rc = kRecInit(YOUR_COMPANY, YOUR_PRODUCT); if ((rc != REC_OK) && (rc != API_INIT_WARN) && (rc != API_LICENSEVALIDATION_WARN)) { printf("Engine initialization failed: %d.\n", rc); return; } else if (rc == API_INIT_WARN) { printf("Warning. Module initialization problem.\n"); } else if (rc == API_LICENSEVALIDATION_WARN) { printf("End of grace period is coming...\n"); } rc = kRecGetModulesInfo(&pModules, &size); if (pModules[INFO_OMR].Version > 0) { bOMR_available = TRUE; } if (pModules[INFO_PLUS3W].Version > 0) { bPLUS_available = TRUE; }
RECERR kRecGetModulesInfo(out KRECMODULEINFO[] ppModules);
RECERR RECAPIKRN kRecGetSerialNumber | ( | LPTSTR | pSn, |
size_t | buflen | ||
) |
The kRecGetSerialNumber function is used to learn the serial number string of the OmniPage CSDK v20. The Serial number is unique for each OmniPage CSDK v20 package.
[out] | pSn | Pointer to a buffer containing the serial number string. |
[in] | buflen | Size of the buffer. |
RECERR |
RECERR kRecGetSerialNumber(out string sn);
RECERR RECAPIKRN kRecGetTimeOut | ( | int | sid, |
LPDWORD | pTimeOut | ||
) |
Getting timeout period.
The kRecGetTimeOut function gets the timeout period.
[in] | sid | Settings Collection ID. |
[out] | pTimeOut | Time out period in milliseconds. |
RECERR |
RECERR kRecGetTimeOut(int sid, out uint TimeOut);
RECERR RECAPIKRN kRecGetUILang | ( | char * | langbuff, |
size_t | buffersize | ||
) |
The kRecGetUILang function gets the language of message strings.
[out] | langbuff | Contains the ISO/DIS 639-3 3-letter language ID of the UI language with a terminating zero. The default value is the machine's UI language. |
[in] | buffersize | Size of the langbuff buffer. Should be 4 or more. |
RECERR |
RECERR kRecGetUILang(out string lang);
int RECAPIKRN kRecGetVersion | ( | void | ) |
Getting version.
The kRecGetVersion function gets the version of RecAPI.
int | The version number. |
int kRecGetVersion();
RECERR RECAPIKRN kRecInit | ( | LPCTSTR | pCompanyName, |
LPCTSTR | pProductName | ||
) |
Initializing KernelAPI.
The kRecInit function initializes the OmniPage CSDK. Except for (kRecSetLicense, kRecGetVersion) the functions of KernelAPI should not be called before initialization. This function enumerates the modules installed in the Engine Binary directory, determines the configuration of the Engine and initializes its modules. Use this function to implicitly bind the Engine to the application. When this function is used for the Engine initialization, the KernelAPI.lib
(on Windows), libkernelapi.so
(on Linux), or libkernelapi.dylib
(on Macintosh) import library must be linked to the application.
[in] | pCompanyName | Name of the User's Company. It can be NULL. Default value: on Windows systems is Nuance , on Linux systems is nuance , on Mac OS X is Nuance . It is used for creating a company-specific working folder for temporary and other files generated by KernelAPI. |
[in] | pProductName | Name of the Product or Application. It can be NULL. Default value: on Windows systems is OmniPageCSDK20 , on Linux systems is omnipage-csdk-20.0 , on Mac OS X is OmniPage-CSDK-20.0 . It is used for creating an application-specific working folder for temporary and other files generated by KernelAPI. |
RECERR |
RECERR kRecInit(string companyName, string productName);
RECERR RECAPIKRN kRecLoadSettings | ( | int | sid, |
LPCTSTR | pFileName | ||
) |
Loading settings.
This function loads settings from a settings file into StsMan.
[in] | sid | Settings Collection ID. |
[in] | pFileName | Filename of the setting file to be loaded. |
RECERR |
RECERR kRecLoadSettings(int sid, string pFileName);
RECERR RECAPIKRN kRecQuit | ( | void | ) |
Closing KernelAPI.
The kRecQuit function stops the OmniPage CSDK. It frees all the resources allocated by the Engine.
RECERR |
kRecQuit
removes all the Settings Collections, pending and user settings, and sets the remaining settings to default, so the setting states are the same after every subsequent kRecQuit - kRecInit
pair. In previous versions of CSDK the kRecQuit
did not perform these steps, thus after a subsequent kRecInit all the settings existed and had the same value as before the previous kRecQuit
. This behaviour can be simulated in CSDK v16 or later doing a workaround: Before kRecQuit:
kRecInit:
RECERR kRecQuit();
RECERR RECAPIKRN kRecSaveSettings | ( | int | sid, |
LPCTSTR | pFileName | ||
) |
Saving settings of KernelAPI.
This function saves the settings.
[in] | sid | Settings Collection ID. |
[in] | pFileName | File name of the setting file to be saved. |
RECERR |
NULL
for root HSETTING
with a FALSE save-all and a FALSE append parameter. kRecSaveSettings
is only for compatibility. RECERR kRecSaveSettings(int sid, string pFileName);
RECERR RECAPIKRN kRecSetCBProgMon | ( | int | sid, |
LPPROGMON_CB | pCallBack, | ||
void * | pContext | ||
) |
Setting progress monitor.
The kRecSetCBProgMon functions sets the progress monitor callback function. The callback function is implemented by the application.
[in] | sid | Settings Collection ID. |
[in] | pCallBack | Pointer to a function. This function will be called for every progress indication. |
[in] | pContext | This pointer value will be passed to the callback function as the 2nd parameter. |
RECERR |
// A callback function for progress monitoring RECERR RECKRNCALL ProgressIndi(LPPROGRESSMONITOR mon, void *pContext) { int id = (int)mon->ProcessId; wsprintf(buff, "PROCESSID: %d %d%%",id, mon->Percent); // Update progress monitoring status on the screen here! if (USER_ABORT) { return API_PROCESS_ABORTED_ERR; } ... return REC_OK; }
RECERR kRecSetCBProgMon(int sid, PROGMON_CB callback);
RECERR RECAPIKRN kRecSetDefaults | ( | int | sid | ) |
Changing settings of KernelAPI to default.
This function changes the settings of the KernelAPI (i.e. the subtree under the node "Kernel" of the setting tree) to their default values.
[in] | sid | Settings Collection ID. |
RECERR |
RECERR kRecSetDefaults(int sid);
RECERR RECAPIKRN kRecSetLicense | ( | LPCTSTR | pLicenseFile, |
LPCTSTR | pCode | ||
) |
Setting the OEM license information.
The kRecSetLicense function sets the OEM license information. In the case of an OEM distribution this function must be called before kRecInit.
[in] | pLicenseFile | Name of the license file or the fully qualified path to the license file (an LCX or LCXZ file). This parameter can be NULL if the OEM license file is loaded by OPLicMgr or the Nuance Licensing Tool (NLT), but this functioning is not suggested. |
[in] | pCode | OEM Code string. (It is a pointer to the string itself, not to the file name containing the OEM Code!) |
RECERR |
kRecInit
. RECERR kRecSetLicense(string pLicenseFile, string pCode);
RECERR RECAPIKRN kRecSetSandboxHomePath | ( | const char * | homepath | ) |
Setting the Sandbox path on MacOS.
The kRecSetSandboxHomePath function sets the Sandbox Home path. This function must be called before any other functions.
[in] | homepath | The application's Home path as returned by the NSHomeDirectory function. The string must be converted to UTF-8 by the UTF8String message. |
RECERR |
kRecSetSandboxHomePath([NSHomeDirectory() UTF8String]);
RECERR RECAPIKRN kRecSetSandboxTempPath | ( | const char * | temppath | ) |
Setting the Sandbox temporary path on MacOS.
The kRecSetSandboxTempPath function sets the Sandbox Temporary path. This function must be called after kRecSetSandboxHomePath and before any other functions.
[in] | temppath | The application's Temporary path as returned by the NSTemporaryDirectory function. The string must be converted to UTF-8 by the UTF8String message. |
RECERR |
kRecSetSandboxTempPath([NSTemporaryDirectory() UTF8String]);
RECERR RECAPIKRN kRecSetTimeOut | ( | int | sid, |
DWORD | TimeOut | ||
) |
Setting timeout period.
The kRecSetTimeOut function sets the time out period for different tasks.
[in] | sid | Settings Collection ID. |
[in] | TimeOut | Timeout period in milliseconds. The suggested minimum limit of this setting is 50 milliseconds, but it may be useful to set the timeout higher on server operating systems. |
RECERR |
RECERR kRecSetTimeOut(int sid, uint TimeOut);
RECERR RECAPIKRN kRecSetUILang | ( | const char * | lang | ) |
Setting the language of displayed information.
The kRecSetUILang function sets the language of message strings.
[in] | lang | ID of the language. This is any language description string accepted by kRecFindLanguage. Use NULL to reset to the default UI language of the user's machine. |
RECERR |
RECERR kRecSetUILang(string lang);