tesseract  4.0.0-1-g2a2b
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 "params.h"
26 #include "unicharset.h"
27 
28 #ifndef _WIN32
29 #include <pthread.h>
30 #include <semaphore.h>
31 #endif
32 
33 namespace tesseract {
34 
35 class CCUtilMutex {
36  public:
37  CCUtilMutex();
38 
39  void Lock();
40 
41  void Unlock();
42  private:
43 #ifdef _WIN32
44  HANDLE mutex_;
45 #else
46  pthread_mutex_t mutex_;
47 #endif
48 };
49 
50 
51 class CCUtil {
52  public:
53  CCUtil();
54  virtual ~CCUtil();
55 
56  public:
57  // Read the arguments and set up the data path.
58  void main_setup(
59  const char *argv0, // program name
60  const char *basename // name of image
61  );
62  ParamsVectors *params() { return &params_; }
63 
64  STRING datadir; // dir for data files
65  STRING imagebasename; // name of image
70  STRING imagefile; // image file name
71  STRING directory; // main directory
72 
73  private:
74  ParamsVectors params_;
75 
76  public:
77  // Member parameters.
78  // These have to be declared and initialized after params_ member, since
79  // params_ should be initialized before parameters are added to it.
80  #ifdef _WIN32
81  STRING_VAR_H(tessedit_module_name, WINDLLNAME,
82  "Module colocated with tessdata dir");
83  #endif
84  INT_VAR_H(ambigs_debug_level, 0, "Debug level for unichar ambiguities");
86  "Use definite ambiguities when running character classifier");
88  "Use ambigs for deciding whether to adapt to a character");
89 };
90 
91 extern CCUtilMutex tprintfMutex; // should remain global
92 } // namespace tesseract
93 
94 #endif // TESSERACT_CCUTIL_CCUTIL_H_
#define INT_VAR_H(name, val, comment)
Definition: params.h:264
#define BOOL_VAR_H(name, val, comment)
Definition: params.h:267
bool use_ambigs_for_adaption
Definition: ccutil.h:88
STRING imagebasename
Definition: ccutil.h:65
STRING language_data_path_prefix
Definition: ccutil.h:67
bool use_definite_ambigs_for_classifier
Definition: ccutil.h:86
#define STRING_VAR_H(name, val, comment)
Definition: params.h:270
int ambigs_debug_level
Definition: ccutil.h:84
UNICHARSET unicharset
Definition: ccutil.h:68
STRING lang
Definition: ccutil.h:66
CCUtilMutex tprintfMutex
Definition: ccutil.cpp:59
ParamsVectors * params()
Definition: ccutil.h:62
STRING imagefile
Definition: ccutil.h:70
STRING directory
Definition: ccutil.h:71
Definition: strngs.h:45
STRING datadir
Definition: ccutil.h:64
void main_setup(const char *argv0, const char *basename)
CCUtil::main_setup - set location of tessdata and name of image.
Definition: mainblk.cpp:48
UnicharAmbigs unichar_ambigs
Definition: ccutil.h:69