tesseract  4.00.00dev
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  STRING_VAR_H(m_data_sub_dir, "tessdata/", "Directory for data files");
81  #ifdef _WIN32
82  STRING_VAR_H(tessedit_module_name, WINDLLNAME,
83  "Module colocated with tessdata dir");
84  #endif
85  INT_VAR_H(ambigs_debug_level, 0, "Debug level for unichar ambiguities");
86  BOOL_VAR_H(use_definite_ambigs_for_classifier, 0,
87  "Use definite ambiguities when running character classifier");
88  BOOL_VAR_H(use_ambigs_for_adaption, 0,
89  "Use ambigs for deciding whether to adapt to a character");
90 };
91 
92 extern CCUtilMutex tprintfMutex; // should remain global
93 } // namespace tesseract
94 
95 #endif // TESSERACT_CCUTIL_CCUTIL_H_
ParamsVectors * params()
Definition: ccutil.h:62
CCUtilMutex tprintfMutex
Definition: ccutil.cpp:60
STRING language_data_path_prefix
Definition: ccutil.h:67
STRING lang
Definition: ccutil.h:66
Definition: strngs.h:45
UNICHARSET unicharset
Definition: ccutil.h:68
STRING imagebasename
Definition: ccutil.h:65
STRING imagefile
Definition: ccutil.h:70
#define STRING_VAR_H(name, val, comment)
Definition: params.h:270
#define INT_VAR_H(name, val, comment)
Definition: params.h:264
STRING datadir
Definition: ccutil.h:64
#define BOOL_VAR_H(name, val, comment)
Definition: params.h:267
UnicharAmbigs unichar_ambigs
Definition: ccutil.h:69
STRING directory
Definition: ccutil.h:71