Skip to content

Commit

Permalink
Documentation comments for fully parameterized init method
Browse files Browse the repository at this point in the history
  • Loading branch information
timvandekamp committed Oct 16, 2013
1 parent 908f6a2 commit a9d5e02
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
34 changes: 34 additions & 0 deletions Classes/Tesseract.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,40 @@ extern NSString * const OcrEngineModeDefault;

+ (NSString *)version;

/**
* Returns <code>NO</code> or <code>nil</code> on failure. On success, Returns
* an initialized <code>Tesseract</code> object set up to use the given tessdata
* path, language, and OCR engine mode, configured with the given variables and
* configuration filenames.
*
* @param dataPath
* The name of the parent directory of tessdata. Must end in / . Any name after
* the last / will be stripped.
* @param language
* An ISO 639-3 string or nil, which will default to eng.
* 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.
* @param mode
* The OcrEngineMode to use or nil, which is equivalent to OcrEngineModeDefault
* @param configFilenames
* The names (including paths) of config files to use. Example config files can
* be found at
* http://code.google.com/p/tesseract-ocr/source/browse/#svn/trunk/tessdata/configs
* @param variables
* A dictionary of tesseract variables to set. Each key must be an NSString
* instance corresponding to a tesseract variable, and each value must be an
* NSString instance containing a valid value for that variable.
* Eg @{@"tessedit_char_whitelist" : @"0123456789.-"}
* @param setOnlyNonDebugParams
* If true, only params that do not contain "debug" in the name will be set.
*/
- (id)initWithDataPath:(NSString *)dataPath
language:(NSString *)language
ocrEngineMode:(NSString *)mode
Expand Down
2 changes: 0 additions & 2 deletions Classes/Tesseract.mm
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ - (BOOL)initEngine {
GenericVector<STRING> values;

if (_configFilenames && _configFilenames.count > 0) {
// completely untested
configs = (char**) malloc(_configFilenames.count * sizeof(char*));
for (; configs_size < _configFilenames.count; configs_size++) {
configs[configs_size] = (char*) malloc((((NSString*)(_configFilenames[configs_size])).length + 1) * sizeof(char));
Expand All @@ -127,7 +126,6 @@ - (BOOL)initEngine {
&values,
_setOnlyNonDebugParams);
if (configs) {
// completely untested
for (int filenameIndex = 0; filenameIndex < configs_size; filenameIndex++) {
free(configs[filenameIndex]);
}
Expand Down

0 comments on commit a9d5e02

Please sign in to comment.