Nicomsoft OCR: Developer's Guide |
C++: | int Cfg_GetOption(HCFG CfgObj, int BlockType, UNICODECHAR* OptionPath, UNICODECHAR* OptionValue, int MaxLen) |
C#: | int Cfg_GetOption(int CfgObj, int BlockType, string OptionPath, out string OptionValue) |
Visual Basic: | Function Cfg_GetOption(ByVal CfgObj As Integer, ByVal BlockType As Integer, ByVal OptionPath As String, ByRef OptionValue As String) As Integer |
Java: | int Cfg_GetOption(HCFG CfgObj, int BlockType, String OptionPath, StringBuffer OptionValue) |
Delphi: | function Cfg_GetOption(CfgObj:HCFG; BlockType:integer; OptionPath:PWCHAR; OptionValue:PWCHAR; MaxLen:integer):integer |
CfgObj [IN] – the Config object. | |
BlockType [IN] – the Block type that defines which top-level configuration section will be used to retrieve the option. Use the BT_DEFAULT constant to read from the default section. See the Blk_SetType function for details about block types. | |
OptionPath [IN] – a Unicode, null-terminated string that contains the full path and name of the OCR option. | |
OptionValue [OUT] – the buffer that will get the Unicode, null-terminated string with the value of the specified OCR option. | |
MaxLen [IN] – the buffer size, in Unicode characters, including the null termination character. If 0, then the function will not copy anything to the buffer, but will only return the buffer size (in Unicode characters, without the null termination character) needed to store the option value. |
int CfgObj, n; Engine_Initialize(); //initialize OCR engine Cfg_Create(&CfgObj); //create CFG object Cfg_LoadOptions(CfgObj, L"Config.dat"); //load configuration n = Cfg_GetOption(CfgObj, BT_DEFAULT, L"ImgAlizer/AutoScale", NULL, 0) + 1; //get length in unicode characters plus terminating NULL character wchar_t* txt = (wchar_t*) malloc(2 * n); //allocate memory for option value string Cfg_GetOption(CfgObj, BT_DEFAULT, L"ImgAlizer/AutoScale", txt, n); //read option value //use "txt" variable now free(txt); //free memory Engine_Uninitialize(); //release all created objects and uninitialize OCR engine
//assume reference to NSOCR COM was added using NSOCR_NameSpace; //Add NSOCR namespace from "NSOCR.cs" file //... int CfgObj; string txt; NSOCRLib.NSOCRClass NsOCR = new NSOCRLib.NSOCRClass(); //create NSOCR COM object instance NsOCR.Engine_Initialize(); //initialize OCR engine NsOCR.Cfg_Create(out CfgObj); //create CFG object NsOCR.Cfg_LoadOptions(CfgObj, "Config.dat"); //load configuration NsOCR.Cfg_GetOption(CfgObj, TNSOCR.BT_DEFAULT, "ImgAlizer/AutoScale", out txt); //read option value //use "txt" variable now NsOCR.Engine_Uninitialize() 'release all created objects and uninitialize OCR engine
'assume reference to NSOCR COM was added 'assume "NSOCR.vb" file was added to project Dim CfgObj As Integer Dim val As String = "" Dim NsOCR As New NSOCRLib.NSOCRClass 'create NSOCR COM object instance NsOCR.Engine_Initialize() 'initialize OCR engine NsOCR.Cfg_Create(CfgObj) 'create CFG object NsOCR.Cfg_LoadOptions(CfgObj, "Config.dat") 'load configuration NsOCR.Cfg_GetOption(CfgObj, TNSOCR.BT_DEFAULT, "ImgAlizer/AutoScale", txt) 'read option value 'use "txt" variable now NsOCR.Engine_Uninitialize() 'release all created objects and uninitialize OCR engine
//assume NSOCR package was included //Java VM option "-Djava.library.path" must point to "Bin" folder (x86 platform) or to "Bin_64" folder (x64 platform) //... NSOCR.HCFG CfgObj = new NSOCR.HCFG(); StringBuffer txt = new StringBuffer(); NSOCR.Engine.Engine_Initialize(); //initialize OCR engine NSOCR.Engine.Cfg_Create(CfgObj); //create CFG object NSOCR.Engine.Cfg_LoadOptions(CfgObj, "Config.dat"); //load configuration NSOCR.Engine.Cfg_GetOption(CfgObj, NSOCR.Constant.BT_DEFAULT, "ImgAlizer/AutoScale", txt); //read option value System.out.println(txt.toString()); NSOCR.Engine.Engine_Uninitialize(); //release all created objects and uninitialize OCR engine