Tesseract
3.02
|
00001 00002 // File: ccutil.h 00003 // Description: ccutil class. 00004 // Author: Samuel Charron 00005 // 00006 // (C) Copyright 2006, Google Inc. 00007 // Licensed under the Apache License, Version 2.0 (the "License"); 00008 // you may not use this file except in compliance with the License. 00009 // You may obtain a copy of the License at 00010 // http://www.apache.org/licenses/LICENSE-2.0 00011 // Unless required by applicable law or agreed to in writing, software 00012 // distributed under the License is distributed on an "AS IS" BASIS, 00013 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 // See the License for the specific language governing permissions and 00015 // limitations under the License. 00016 // 00018 00019 #ifndef TESSERACT_CCUTIL_CCUTIL_H__ 00020 #define TESSERACT_CCUTIL_CCUTIL_H__ 00021 00022 #include "ambigs.h" 00023 #include "errcode.h" 00024 #include "strngs.h" 00025 #include "tessdatamanager.h" 00026 #include "params.h" 00027 #include "unicharset.h" 00028 00029 #ifdef _WIN32 00030 #include <windows.h> 00031 #else 00032 #include <pthread.h> 00033 #include <semaphore.h> 00034 #endif 00035 00036 namespace tesseract { 00037 00038 class CCUtilMutex { 00039 public: 00040 CCUtilMutex(); 00041 00042 void Lock(); 00043 00044 void Unlock(); 00045 private: 00046 #ifdef _WIN32 00047 HANDLE mutex_; 00048 #else 00049 pthread_mutex_t mutex_; 00050 #endif 00051 }; 00052 00053 00054 class CCUtil { 00055 public: 00056 CCUtil(); 00057 virtual ~CCUtil(); 00058 00059 public: 00060 // Read the arguments and set up the data path. 00061 void main_setup( 00062 const char *argv0, // program name 00063 const char *basename // name of image 00064 ); 00065 ParamsVectors *params() { return ¶ms_; } 00066 00067 STRING datadir; // dir for data files 00068 STRING imagebasename; // name of image 00069 STRING lang; 00070 STRING language_data_path_prefix; 00071 TessdataManager tessdata_manager; 00072 UNICHARSET unicharset; 00073 UnicharAmbigs unichar_ambigs; 00074 STRING imagefile; // image file name 00075 STRING directory; // main directory 00076 00077 private: 00078 ParamsVectors params_; 00079 00080 public: 00081 // Member parameters. 00082 // These have to be declared and initialized after params_ member, since 00083 // params_ should be initialized before parameters are added to it. 00084 STRING_VAR_H(m_data_sub_dir, "tessdata/", "Directory for data files"); 00085 #ifdef _WIN32 00086 STRING_VAR_H(tessedit_module_name, WINDLLNAME, 00087 "Module colocated with tessdata dir"); 00088 #endif 00089 INT_VAR_H(ambigs_debug_level, 0, "Debug level for unichar ambiguities"); 00090 BOOL_VAR_H(use_definite_ambigs_for_classifier, 0, 00091 "Use definite ambiguities when running character classifier"); 00092 BOOL_VAR_H(use_ambigs_for_adaption, 0, 00093 "Use ambigs for deciding whether to adapt to a character"); 00094 }; 00095 00096 extern CCUtilMutex tprintfMutex; // should remain global 00097 } // namespace tesseract 00098 00099 #endif // TESSERACT_CCUTIL_CCUTIL_H__