tesseract  5.0.0
tesseract::CCUtil Class Reference

#include <ccutil.h>

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

Public Member Functions

 CCUtil ()
 
virtual ~CCUtil ()
 
void main_setup (const std::string &argv0, const std::string &basename)
 CCUtil::main_setup - set location of tessdata and name of image. More...
 
ParamsVectorsparams ()
 
 INT_VAR_H (ambigs_debug_level)
 
 BOOL_VAR_H (use_ambigs_for_adaption)
 

Public Attributes

std::string datadir
 
std::string imagebasename
 
std::string lang
 
std::string language_data_path_prefix
 
UNICHARSET unicharset
 
UnicharAmbigs unichar_ambigs
 
std::string imagefile
 
std::string directory
 

Detailed Description

Definition at line 43 of file ccutil.h.

Constructor & Destructor Documentation

◆ CCUtil()

tesseract::CCUtil::CCUtil ( )

Definition at line 16 of file ccutil.cpp.

17  : params_()
18  , INT_INIT_MEMBER(ambigs_debug_level, 0, "Debug level for unichar ambiguities", &params_)
19  , BOOL_MEMBER(use_ambigs_for_adaption, false,
20  "Use ambigs for deciding"
21  " whether to adapt to a character",
22  &params_) {}
#define INT_INIT_MEMBER(name, val, comment, vec)
Definition: params.h:376
#define BOOL_MEMBER(name, val, comment, vec)
Definition: params.h:370

◆ ~CCUtil()

tesseract::CCUtil::~CCUtil ( )
virtualdefault

Member Function Documentation

◆ BOOL_VAR_H()

tesseract::CCUtil::BOOL_VAR_H ( use_ambigs_for_adaption  )

◆ INT_VAR_H()

tesseract::CCUtil::INT_VAR_H ( ambigs_debug_level  )

◆ main_setup()

void tesseract::CCUtil::main_setup ( const std::string &  argv0,
const std::string &  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 40 of file mainblk.cpp.

40  {
41  imagebasename = basename;
43  char *tessdata_prefix = getenv("TESSDATA_PREFIX");
44 
45  if (!argv0.empty()) {
46  /* Use tessdata prefix from the command line. */
47  datadir = argv0;
48  } else if (tessdata_prefix) {
49  /* Use tessdata prefix from the environment. */
50  datadir = tessdata_prefix;
51 #if defined(_WIN32)
52  } else if (datadir.empty() || _access(datadir.c_str(), 0) != 0) {
53  /* Look for tessdata in directory of executable. */
54  char path[_MAX_PATH];
55  DWORD length = GetModuleFileName(nullptr, path, sizeof(path));
56  if (length > 0 && length < sizeof(path)) {
57  char *separator = std::strrchr(path, '\\');
58  if (separator != nullptr) {
59  *separator = '\0';
60  datadir = path;
61  datadir += "/tessdata";
62  }
63  }
64 #elif defined(__riscos__)
65  } else if (datadir.empty() != 0) {
66  char path[PATH_MAX] = "<Tesseract$Dir>.tessdata";
67  /* Look for tessdata in directory of executable. */
68  datadir = __unixify(path, 0, NULL, 0, 0);
69 #endif /* _WIN32 */
70 #if defined(TESSDATA_PREFIX) && !defined(__riscos__)
71  } else {
72  // Use tessdata prefix which was compiled in.
73  datadir = TESSDATA_PREFIX "/tessdata";
74 #endif
75  }
76 
77  // datadir may still be empty:
78  if (datadir.empty()) {
79  datadir = "./";
80  }
81 
82  // check for missing directory separator
83  const char *lastchar = datadir.c_str();
84  lastchar += datadir.length() - 1;
85  if ((strcmp(lastchar, "/") != 0) && (strcmp(lastchar, "\\") != 0)) {
86  datadir += "/";
87  }
88 }
std::string imagebasename
Definition: ccutil.h:58
std::string datadir
Definition: ccutil.h:57

◆ params()

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

Definition at line 53 of file ccutil.h.

53  {
54  return &params_;
55  }

Member Data Documentation

◆ datadir

std::string tesseract::CCUtil::datadir

Definition at line 57 of file ccutil.h.

◆ directory

std::string tesseract::CCUtil::directory

Definition at line 66 of file ccutil.h.

◆ imagebasename

std::string tesseract::CCUtil::imagebasename

Definition at line 58 of file ccutil.h.

◆ imagefile

std::string tesseract::CCUtil::imagefile

Definition at line 65 of file ccutil.h.

◆ lang

std::string tesseract::CCUtil::lang

Definition at line 59 of file ccutil.h.

◆ language_data_path_prefix

std::string tesseract::CCUtil::language_data_path_prefix

Definition at line 60 of file ccutil.h.

◆ unichar_ambigs

UnicharAmbigs tesseract::CCUtil::unichar_ambigs

Definition at line 63 of file ccutil.h.

◆ unicharset

UNICHARSET tesseract::CCUtil::unicharset

Definition at line 61 of file ccutil.h.


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