All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ccutil.h
Go to the documentation of this file.
1 // File: ccutil.h
3 // Description: ccutil class.
4 // Author: Samuel Charron
5 //
6 // (C) Copyright 2006, Google Inc.
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
18 
19 #ifndef TESSERACT_CCUTIL_CCUTIL_H__
20 #define TESSERACT_CCUTIL_CCUTIL_H__
21 
22 #include "ambigs.h"
23 #include "errcode.h"
24 #include "strngs.h"
25 #include "tessdatamanager.h"
26 #include "params.h"
27 #include "unicharset.h"
28 
29 #ifdef _WIN32
30 #include <windows.h>
31 #else
32 #include <pthread.h>
33 #include <semaphore.h>
34 #endif
35 
36 namespace tesseract {
37 
38 class CCUtilMutex {
39  public:
40  CCUtilMutex();
41 
42  void Lock();
43 
44  void Unlock();
45  private:
46 #ifdef _WIN32
47  HANDLE mutex_;
48 #else
49  pthread_mutex_t mutex_;
50 #endif
51 };
52 
53 
54 class CCUtil {
55  public:
56  CCUtil();
57  virtual ~CCUtil();
58 
59  public:
60  // Read the arguments and set up the data path.
61  void main_setup(
62  const char *argv0, // program name
63  const char *basename // name of image
64  );
65  ParamsVectors *params() { return &params_; }
66 
67  STRING datadir; // dir for data files
68  STRING imagebasename; // name of image
74  STRING imagefile; // image file name
75  STRING directory; // main directory
76 
77  private:
78  ParamsVectors params_;
79 
80  public:
81  // Member parameters.
82  // These have to be declared and initialized after params_ member, since
83  // params_ should be initialized before parameters are added to it.
84  STRING_VAR_H(m_data_sub_dir, "tessdata/", "Directory for data files");
85  #ifdef _WIN32
86  STRING_VAR_H(tessedit_module_name, WINDLLNAME,
87  "Module colocated with tessdata dir");
88  #endif
89  INT_VAR_H(ambigs_debug_level, 0, "Debug level for unichar ambiguities");
91  "Use definite ambiguities when running character classifier");
93  "Use ambigs for deciding whether to adapt to a character");
94 };
95 
96 extern CCUtilMutex tprintfMutex; // should remain global
97 } // namespace tesseract
98 
99 #endif // TESSERACT_CCUTIL_CCUTIL_H__
STRING directory
Definition: ccutil.h:75
STRING imagebasename
Definition: ccutil.h:68
CCUtilMutex tprintfMutex
Definition: ccutil.cpp:51
#define INT_VAR_H(name, val, comment)
Definition: params.h:265
virtual ~CCUtil()
Definition: ccutil.cpp:23
UNICHARSET unicharset
Definition: ccutil.h:72
STRING imagefile
Definition: ccutil.h:74
TessdataManager tessdata_manager
Definition: ccutil.h:71
UnicharAmbigs unichar_ambigs
Definition: ccutil.h:73
#define STRING_VAR_H(name, val, comment)
Definition: params.h:271
char * m_data_sub_dir
Definition: ccutil.h:84
STRING datadir
Definition: ccutil.h:67
STRING language_data_path_prefix
Definition: ccutil.h:70
ParamsVectors * params()
Definition: ccutil.h:65
void main_setup(const char *argv0, const char *basename)
CCUtil::main_setup - set location of tessdata and name of image.
Definition: mainblk.cpp:53
STRING lang
Definition: ccutil.h:69
Definition: strngs.h:44
bool use_ambigs_for_adaption
Definition: ccutil.h:93
bool use_definite_ambigs_for_classifier
Definition: ccutil.h:91
int ambigs_debug_level
Definition: ccutil.h:89
#define BOOL_VAR_H(name, val, comment)
Definition: params.h:268