Click or drag to resize
OcrApiInit Method (String, String, OcrEngineMode, String, String, String, Boolean, Boolean)
Initialize the OCR SDK library

Namespace: Patagames.Ocr
Assembly: Patagames.Ocr (in Patagames.Ocr.dll) Version: 1.7.0.341
Syntax
public void Init(
	string dataPath = null,
	string language = null,
	OcrEngineMode oem = OcrEngineMode.OEM_DEFAULT,
	string[] configs = null,
	string[] varsVec = null,
	string[] varsValues = null,
	bool setOnlyNonDebugParams = false,
	bool checkLanguage = true
)

Parameters

dataPath (Optional)
Type: SystemString
The datapath must be the name of the parent directory of tessdata and must end in / . Any name after the last / will be stripped. NULL will default to current folder.
language (Optional)
Type: SystemString
The language is (usually) an ISO 639-3 string or NULL will default to eng.
oem (Optional)
Type: Patagames.Ocr.EnumsOcrEngineMode
Ocr engine mode. See OcrEngineMode for detail
configs (Optional)
Type: SystemString
An array of names of configuration files. Configuration file must be placed in configs or tessconfigs subfolders in dataPath
varsVec (Optional)
Type: SystemString
An array of variables (names)
varsValues (Optional)
Type: SystemString
An array of variables (values)
setOnlyNonDebugParams (Optional)
Type: SystemBoolean
If true, only params that do not contain "debug" in the name will be set
checkLanguage (Optional)
Type: SystemBoolean
If true then engine will check the availability of requested language prior initialization.
Remarks
Note 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 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