tesseract  4.00.00dev
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
 
char * m_data_sub_dir = "tessdata/"
 
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_(),
19  "tessdata/", "Directory for data files", &params_),
20 #ifdef _WIN32
21  STRING_INIT_MEMBER(tessedit_module_name, WINDLLNAME,
22  "Module colocated with tessdata dir", &params_),
23 #endif
24  INT_INIT_MEMBER(ambigs_debug_level, 0, "Debug level for unichar ambiguities",
25  &params_),
27  " ambiguities when running character classifier", &params_),
28  BOOL_MEMBER(use_ambigs_for_adaption, 0, "Use ambigs for deciding"
29  " whether to adapt to a character", &params_) {
30 }
int ambigs_debug_level
Definition: ccutil.h:85
char * m_data_sub_dir
Definition: ccutil.h:80
bool use_ambigs_for_adaption
Definition: ccutil.h:89
bool use_definite_ambigs_for_classifier
Definition: ccutil.h:87
#define INT_INIT_MEMBER(name, val, comment, vec)
Definition: params.h:312
#define STRING_INIT_MEMBER(name, val, comment, vec)
Definition: params.h:318
#define BOOL_MEMBER(name, val, comment, vec)
Definition: params.h:303

◆ ~CCUtil()

tesseract::CCUtil::~CCUtil ( )
virtual

Definition at line 32 of file ccutil.cpp.

32  {
33 }

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 NULL, otherwise TESSDATA_PREFIX is used if not NULL, next try to use compiled in -DTESSDATA_PREFIX. If previous is not successful - use current directory.
basename- name of image

< name of image

< data directory

Definition at line 53 of file mainblk.cpp.

53  {
54  imagebasename = basename;
56  char *tessdata_prefix = getenv("TESSDATA_PREFIX");
57 
58  if (argv0 != NULL && *argv0 != '\0') {
59  /* Use tessdata prefix from the command line. */
60  datadir = argv0;
61  } else if (tessdata_prefix) {
62  /* Use tessdata prefix from the environment. */
63  datadir = tessdata_prefix;
64 #if defined(_WIN32)
65  } else if (datadir == NULL || access(datadir.string(), 0) != 0) {
66  /* Look for tessdata in directory of executable. */
67  static char dir[128];
68  static char exe[128];
69  DWORD length = GetModuleFileName(NULL, exe, sizeof(exe));
70  if (length > 0 && length < sizeof(exe)) {
71  _splitpath(exe, NULL, dir, NULL, NULL);
72  datadir = dir;
73  }
74 #endif /* _WIN32 */
75 #if defined(TESSDATA_PREFIX)
76  } else {
77 /* Use tessdata prefix which was compiled in. */
78 #define _STR(a) #a
79 #define _XSTR(a) _STR(a)
80  datadir = _XSTR(TESSDATA_PREFIX);
81 #undef _XSTR
82 #undef _STR
83 #endif
84  }
85 
86  // datadir may still be empty:
87  if (datadir.length() == 0) {
88  datadir = "./";
89  } else {
90  // Remove tessdata from the end if present, as we will add it back!
91  int length = datadir.length();
92  if (length >= 8 && strcmp(&datadir[length - 8], "tessdata") == 0)
93  datadir.truncate_at(length - 8);
94  else if (length >= 9 && strcmp(&datadir[length - 9], "tessdata/") == 0)
95  datadir.truncate_at(length - 9);
96  }
97 
98  // check for missing directory separator
99  const char *lastchar = datadir.string();
100  lastchar += datadir.length() - 1;
101  if ((strcmp(lastchar, "/") != 0) && (strcmp(lastchar, "\\") != 0))
102  datadir += "/";
103 
105 }
void truncate_at(inT32 index)
Definition: strngs.cpp:269
const char * string() const
Definition: strngs.cpp:198
char * m_data_sub_dir
Definition: ccutil.h:80
inT32 length() const
Definition: strngs.cpp:193
STRING imagebasename
Definition: ccutil.h:65
STRING datadir
Definition: ccutil.h:64

◆ 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 85 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.

◆ m_data_sub_dir

char* tesseract::CCUtil::m_data_sub_dir = "tessdata/"

"Directory for data files"

Definition at line 80 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 89 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 87 of file ccutil.h.


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