tesseract  v4.0.0-17-g361f3264
Open Source OCR Engine
ccutil.h
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:
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");
85  BOOL_VAR_H(use_definite_ambigs_for_classifier, 0,
86  "Use definite ambiguities when running character classifier");
87  BOOL_VAR_H(use_ambigs_for_adaption, 0,
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_
CCUtilMutex tprintfMutex
Definition: ccutil.cpp:59
STRING imagebasename
Definition: ccutil.h:65
Definition: params.h:43
Definition: unicharset.h:146
ParamsVectors params_
Definition: ccutil.h:74
CCUtilMutex()
Definition: ccutil.cpp:35
Definition: baseapi.cpp:94
pthread_mutex_t mutex_
Definition: ccutil.h:46
Definition: ccutil.h:51
STRING language_data_path_prefix
Definition: ccutil.h:67
UnicharAmbigs unichar_ambigs
Definition: ccutil.h:69
ParamsVectors * params()
Definition: ccutil.h:62
BOOL_VAR_H(textord_tabfind_find_tables, false, "run table detection")
Definition: ambigs.h:143
Definition: strngs.h:45
STRING lang
Definition: ccutil.h:66
STRING directory
Definition: ccutil.h:71
void Lock()
Definition: ccutil.cpp:43
void Unlock()
Definition: ccutil.cpp:51
Definition: ccutil.h:35
STRING imagefile
Definition: ccutil.h:70
UNICHARSET unicharset
Definition: ccutil.h:68
STRING datadir
Definition: ccutil.h:64