tesseract  4.0.0-1-g2a2b
tesseract::CCUtil Class Reference

#include <ccutil.h>

Inheritance diagram for tesseract::CCUtil:
tesseract::CUtil tesseract::CCStruct tesseract::Classify tesseract::Wordrec tesseract::Tesseract

Public Member Functions

 CCUtil ()
 
virtual ~CCUtil ()
 
void main_setup (const char *argv0, const char *basename)
 CCUtil::main_setup - set location of tessdata and name of image. More...
 
ParamsVectorsparams ()
 

Public Attributes

STRING datadir
 
STRING imagebasename
 
STRING lang
 
STRING language_data_path_prefix
 
UNICHARSET unicharset
 
UnicharAmbigs unichar_ambigs
 
STRING imagefile
 
STRING directory
 
int ambigs_debug_level = 0
 
bool use_definite_ambigs_for_classifier = 0
 
bool use_ambigs_for_adaption = 0
 

Detailed Description

Definition at line 51 of file ccutil.h.

Constructor & Destructor Documentation

◆ CCUtil()

tesseract::CCUtil::CCUtil ( )

Definition at line 16 of file ccutil.cpp.

16  :
17  params_(),
18 #ifdef _WIN32
19  STRING_INIT_MEMBER(tessedit_module_name, WINDLLNAME,
20  "Module colocated with tessdata dir", &params_),
21 #endif
22  INT_INIT_MEMBER(ambigs_debug_level, 0, "Debug level for unichar ambiguities",
23  &params_),
25  " ambiguities when running character classifier", &params_),
26  BOOL_MEMBER(use_ambigs_for_adaption, 0, "Use ambigs for deciding"
27  " whether to adapt to a character", &params_) {
28 }
#define STRING_INIT_MEMBER(name, val, comment, vec)
Definition: params.h:306
bool use_ambigs_for_adaption
Definition: ccutil.h:88
bool use_definite_ambigs_for_classifier
Definition: ccutil.h:86
#define INT_INIT_MEMBER(name, val, comment, vec)
Definition: params.h:300
#define BOOL_MEMBER(name, val, comment, vec)
Definition: params.h:291
int ambigs_debug_level
Definition: ccutil.h:84

◆ ~CCUtil()

tesseract::CCUtil::~CCUtil ( )
virtualdefault

Member Function Documentation

◆ main_setup()

void tesseract::CCUtil::main_setup ( const char *  argv0,
const char *  basename 
)

CCUtil::main_setup - set location of tessdata and name of image.

Parameters
argv0- paths to the directory with language files and config files. An actual value of argv0 is used if not nullptr, otherwise TESSDATA_PREFIX is used if not nullptr, next try to use compiled in -DTESSDATA_PREFIX. If previous is not successful - use current directory.
basename- name of image

< name of image

Definition at line 48 of file mainblk.cpp.

48  {
49  imagebasename = basename;
51  char *tessdata_prefix = getenv("TESSDATA_PREFIX");
52 
53  if (argv0 != nullptr && *argv0 != '\0') {
54  /* Use tessdata prefix from the command line. */
55  datadir = argv0;
56  } else if (tessdata_prefix) {
57  /* Use tessdata prefix from the environment. */
58  datadir = tessdata_prefix;
59 #if defined(_WIN32)
60  } else if (datadir == nullptr || _access(datadir.string(), 0) != 0) {
61  /* Look for tessdata in directory of executable. */
62  char drive[_MAX_DRIVE];
63  char dir[_MAX_DIR];
64  char path[_MAX_PATH];
65  DWORD length = GetModuleFileName(nullptr, path, sizeof(path));
66  if (length > 0 && length < sizeof(path)) {
67  errno_t result = _splitpath_s(path, drive, sizeof(drive),
68  dir, sizeof(dir), nullptr, 0, nullptr, 0);
69  if (result == ERANGE) {
70  tprintf("Error: Path too long: %s\n", path);
71  }
72 
73  datadir = drive;
74  datadir += dir;
75  datadir += "/tessdata";
76  }
77 #endif /* _WIN32 */
78 #if defined(TESSDATA_PREFIX)
79  } else {
80 /* Use tessdata prefix which was compiled in. */
81 #define _STR(a) #a
82 #define _XSTR(a) _STR(a)
83  datadir = _XSTR(TESSDATA_PREFIX) "/tessdata";
84 #undef _XSTR
85 #undef _STR
86 #endif
87  }
88 
89  // datadir may still be empty:
90  if (datadir.length() == 0) {
91  datadir = "./";
92  }
93 
94  // check for missing directory separator
95  const char *lastchar = datadir.string();
96  lastchar += datadir.length() - 1;
97  if ((strcmp(lastchar, "/") != 0) && (strcmp(lastchar, "\\") != 0))
98  datadir += "/";
99 }
const char * string() const
Definition: strngs.cpp:196
STRING imagebasename
Definition: ccutil.h:65
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:37
STRING datadir
Definition: ccutil.h:64
int32_t length() const
Definition: strngs.cpp:191

◆ params()

ParamsVectors* tesseract::CCUtil::params ( )
inline

Definition at line 62 of file ccutil.h.

62 { return &params_; }

Member Data Documentation

◆ ambigs_debug_level

int tesseract::CCUtil::ambigs_debug_level = 0

"Debug level for unichar ambiguities"

Definition at line 84 of file ccutil.h.

◆ datadir

STRING tesseract::CCUtil::datadir

Definition at line 64 of file ccutil.h.

◆ directory

STRING tesseract::CCUtil::directory

Definition at line 71 of file ccutil.h.

◆ imagebasename

STRING tesseract::CCUtil::imagebasename

Definition at line 65 of file ccutil.h.

◆ imagefile

STRING tesseract::CCUtil::imagefile

Definition at line 70 of file ccutil.h.

◆ lang

STRING tesseract::CCUtil::lang

Definition at line 66 of file ccutil.h.

◆ language_data_path_prefix

STRING tesseract::CCUtil::language_data_path_prefix

Definition at line 67 of file ccutil.h.

◆ unichar_ambigs

UnicharAmbigs tesseract::CCUtil::unichar_ambigs

Definition at line 69 of file ccutil.h.

◆ unicharset

UNICHARSET tesseract::CCUtil::unicharset

Definition at line 68 of file ccutil.h.

◆ use_ambigs_for_adaption

bool tesseract::CCUtil::use_ambigs_for_adaption = 0

"Use ambigs for deciding whether to adapt to a character"

Definition at line 88 of file ccutil.h.

◆ use_definite_ambigs_for_classifier

bool tesseract::CCUtil::use_definite_ambigs_for_classifier = 0

"Use definite ambiguities when running character classifier"

Definition at line 86 of file ccutil.h.


The documentation for this class was generated from the following files: