 | OcrApiInit(Languages, String, OcrEngineMode, String, String, String, Boolean) Method |
Initialize the OCR SDK library
Namespace: Patagames.OcrAssembly: Patagames.Ocr (in Patagames.Ocr.dll) Version: 4.6.411
Syntaxpublic void Init(
Languages[] language,
string dataPath = "tessdata",
OcrEngineMode oem = OcrEngineMode.OEM_DEFAULT,
string[] configs = null,
string[] varsVec = null,
string[] varsValues = null,
bool setOnlyNonDebugParams = false
)
Public Sub Init (
language As Languages(),
Optional dataPath As String = "tessdata",
Optional oem As OcrEngineMode = OcrEngineMode.OEM_DEFAULT,
Optional configs As String() = Nothing,
Optional varsVec As String() = Nothing,
Optional varsValues As String() = Nothing,
Optional setOnlyNonDebugParams As Boolean = false
)
public:
void Init(
array<Languages>^ language,
String^ dataPath = L"tessdata",
OcrEngineMode oem = OcrEngineMode::OEM_DEFAULT,
array<String^>^ configs = nullptr,
array<String^>^ varsVec = nullptr,
array<String^>^ varsValues = nullptr,
bool setOnlyNonDebugParams = false
)
member Init :
language : Languages[] *
?dataPath : string *
?oem : OcrEngineMode *
?configs : string[] *
?varsVec : string[] *
?varsValues : string[] *
?setOnlyNonDebugParams : bool
(* Defaults:
let _dataPath = defaultArg dataPath "tessdata"
let _oem = defaultArg oem OcrEngineMode.OEM_DEFAULT
let _configs = defaultArg configs null
let _varsVec = defaultArg varsVec null
let _varsValues = defaultArg varsValues null
let _setOnlyNonDebugParams = defaultArg setOnlyNonDebugParams false
*)
-> unit public void Init(
Languages[] language,
String dataPath = "tessdata",
OcrEngineMode oem = OcrEngineMode.OEM_DEFAULT,
String[] configs = null,
String[] varsVec = null,
String[] varsValues = null,
boolean setOnlyNonDebugParams = false
)
function Init(language, dataPath, oem, configs, varsVec, varsValues, setOnlyNonDebugParams);
Parameters
- language Languages
- The language.
- dataPath String (Optional)
- Path to the directory with language files and config files. If null - TESSDATA_PREFIX environment variable is used. If variable is not set current directory is used.
- oem OcrEngineMode (Optional)
- Ocr engine mode. See OcrEngineMode for detail
- configs String (Optional)
- An array of names of configuration files. Configuration file must be placed in configs or tessconfigs subfolders in dataPath
- varsVec String (Optional)
- An array of variables (names)
- varsValues String (Optional)
- An array of variables (values)
- setOnlyNonDebugParams Boolean (Optional)
- If true, only params that do not contain "debug" in the name will be set
Remarks Note |
|---|
|
Instances are mostly thread-safe and totally independent,
but some global parameters remain. Basically it is safe to use multiple
OcrApis in different threads in parallel, UNLESS:
you use SetVariable(String, String, Boolean) on some of the Params in classify and textord.
If you do, then the effect will be to change it for all your instances.
|
For full list of tesseract variables see this article: Tesseract.Net parameters
That the only members that may be called before Init are those listed below:
It is entirely safe (and eventually will be efficient too) to call
Init multiple times on the same instance to change language, or just
to reset the classifier.
The language may be a string of the form [~]lang[+[~]lang]* indicating
that multiple languages are to be loaded.Eg hin+eng will load Hindi and
English.Languages may specify internally that they want to be loaded
with one or more other languages, so the ~sign is available to override
that.Eg if hin were set to load eng by default, then hin+~eng would force
loading only hin.The number of loaded languages is limited only by
memory, with the caveat that loading additional languages will impact
both speed and accuracy, as there is more work to do to decide on the
applicable language, and there is more chance of hallucinating incorrect words.
Note |
|---|
|
WARNING: On changing languages, all Tesseract parameters are reset
back to their default values. (Which may vary between languages.)
If you have a rare need to set a Variable that controls
initialization for a second call to Init you should explicitly
call Release and then use SetVariable before Init.This is only a very
rare use case, since there are very few uses that require any parameters
to be set before Init.
|
See Also