tesseract  4.1.0
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 #ifndef _WIN32
23 #include <pthread.h>
24 #include <semaphore.h>
25 #endif
26 
27 #include "ambigs.h"
28 #include "errcode.h"
29 #ifdef _WIN32
30 #include "host.h" // windows.h for HANDLE, ...
31 #endif
32 #include "strngs.h"
33 #include "params.h"
34 #include "unicharset.h"
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
73  STRING imagefile; // image file name
74  STRING directory; // main directory
75 
76  private:
77  ParamsVectors params_;
78 
79  public:
80  // Member parameters.
81  // These have to be declared and initialized after params_ member, since
82  // params_ should be initialized before parameters are added to it.
83  INT_VAR_H(ambigs_debug_level, 0, "Debug level for unichar ambiguities");
84  BOOL_VAR_H(use_definite_ambigs_for_classifier, false,
85  "Use definite ambiguities when running character classifier");
86  BOOL_VAR_H(use_ambigs_for_adaption, false,
87  "Use ambigs for deciding whether to adapt to a character");
88 };
89 
90 extern CCUtilMutex tprintfMutex; // should remain global
91 } // namespace tesseract
92 
93 #endif // TESSERACT_CCUTIL_CCUTIL_H_
#define BOOL_VAR_H(name, val, comment)
Definition: params.h:297
ParamsVectors * params()
Definition: ccutil.h:65
Definition: strngs.h:45
CCUtilMutex tprintfMutex
Definition: ccutil.cpp:55
UnicharAmbigs unichar_ambigs
Definition: ccutil.h:72
UNICHARSET unicharset
Definition: ccutil.h:71
#define INT_VAR_H(name, val, comment)
Definition: params.h:295
STRING directory
Definition: ccutil.h:74
STRING lang
Definition: ccutil.h:69
STRING datadir
Definition: ccutil.h:67
STRING imagebasename
Definition: ccutil.h:68
STRING imagefile
Definition: ccutil.h:73
STRING language_data_path_prefix
Definition: ccutil.h:70