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