tesseract v5.3.3.20231005
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 24 of file ccutil.cpp.

25 : params_()
26 , INT_INIT_MEMBER(ambigs_debug_level, 0, "Debug level for unichar ambiguities", &params_)
27 , BOOL_MEMBER(use_ambigs_for_adaption, false,
28 "Use ambigs for deciding"
29 " whether to adapt to a character",
30 &params_) {}
#define INT_INIT_MEMBER(name, val, comment, vec)
Definition: params.h:377
#define BOOL_MEMBER(name, val, comment, vec)
Definition: params.h:371

◆ ~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 46 of file ccutil.cpp.

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