All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
tuning_params.h
Go to the documentation of this file.
1 /**********************************************************************
2  * File: tuning_params.h
3  * Description: Declaration of the Tuning Parameters Base Class
4  * Author: Ahmad Abdulkader
5  * Created: 2008
6  *
7  * (C) Copyright 2008, Google Inc.
8  ** Licensed under the Apache License, Version 2.0 (the "License");
9  ** you may not use this file except in compliance with the License.
10  ** You may obtain a copy of the License at
11  ** http://www.apache.org/licenses/LICENSE-2.0
12  ** Unless required by applicable law or agreed to in writing, software
13  ** distributed under the License is distributed on an "AS IS" BASIS,
14  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  ** See the License for the specific language governing permissions and
16  ** limitations under the License.
17  *
18  **********************************************************************/
19 
20 // The TuningParams class abstracts all the parameters that can be learned or
21 // tuned during the training process. It is a base class that all TuningParams
22 // classes should inherit from.
23 
24 #ifndef TUNING_PARAMS_H
25 #define TUNING_PARAMS_H
26 
27 #include <string>
28 #ifdef USE_STD_NAMESPACE
29 using std::string;
30 #endif
31 
32 namespace tesseract {
33 class TuningParams {
34  public:
36  NN,
38  };
39  enum type_feature {
40  BMP,
43  };
44 
46  virtual ~TuningParams() {}
47  // Accessor functions
48  inline double RecoWgt() const { return reco_wgt_; }
49  inline double SizeWgt() const { return size_wgt_; }
50  inline double CharBigramWgt() const { return char_bigrams_wgt_; }
51  inline double WordUnigramWgt() const { return word_unigrams_wgt_; }
52  inline int MaxSegPerChar() const { return max_seg_per_char_; }
53  inline int BeamWidth() const { return beam_width_; }
54  inline int TypeClassifier() const { return tp_classifier_; }
55  inline int TypeFeature() const { return tp_feat_; }
56  inline int ConvGridSize() const { return conv_grid_size_; }
57  inline int HistWindWid() const { return hist_wind_wid_; }
58  inline int MinConCompSize() const { return min_con_comp_size_; }
59  inline double MaxWordAspectRatio() const { return max_word_aspect_ratio_; }
60  inline double MinSpaceHeightRatio() const { return min_space_height_ratio_; }
61  inline double MaxSpaceHeightRatio() const { return max_space_height_ratio_; }
62  inline double CombinerRunThresh() const { return combiner_run_thresh_; }
63  inline double CombinerClassifierThresh() const {
65 
66  inline void SetRecoWgt(double wgt) { reco_wgt_ = wgt; }
67  inline void SetSizeWgt(double wgt) { size_wgt_ = wgt; }
68  inline void SetCharBigramWgt(double wgt) { char_bigrams_wgt_ = wgt; }
69  inline void SetWordUnigramWgt(double wgt) { word_unigrams_wgt_ = wgt; }
70  inline void SetMaxSegPerChar(int max_seg_per_char) {
71  max_seg_per_char_ = max_seg_per_char;
72  }
73  inline void SetBeamWidth(int beam_width) { beam_width_ = beam_width; }
74  inline void SetTypeClassifier(type_classifer tp_classifier) {
75  tp_classifier_ = tp_classifier;
76  }
77  inline void SetTypeFeature(type_feature tp_feat) {tp_feat_ = tp_feat;}
78  inline void SetHistWindWid(int hist_wind_wid) {
79  hist_wind_wid_ = hist_wind_wid;
80  }
81 
82  virtual bool Save(string file_name) = 0;
83  virtual bool Load(string file_name) = 0;
84 
85  protected:
86  // weight of recognition cost. This includes the language model cost
87  double reco_wgt_;
88  // weight of size cost
89  double size_wgt_;
90  // weight of character bigrams cost
92  // weight of word unigrams cost
94  // Maximum number of segments per character
96  // Beam width equal to the maximum number of nodes kept in the beam search
97  // trellis column after pruning
99  // Classifier type: See enum type_classifer for classifier types
101  // Feature types: See enum type_feature for feature types
103  // Grid size to scale a grapheme bitmap used by the BMP feature type
105  // Histogram window size as a ratio of the word height used in computing
106  // the vertical pixel density histogram in the segmentation algorithm
108  // Minimum possible size of a connected component
110  // Maximum aspect ratio of a word (width / height)
112  // Minimum ratio relative to the line height of a gap to be considered as
113  // a word break
115  // Maximum ratio relative to the line height of a gap to be considered as
116  // a definite word break
118  // When Cube and Tesseract are run in combined mode, only run
119  // combiner classifier when tesseract confidence is below this
120  // threshold. When Cube is run without Tesseract, this is ignored.
122  // When Cube and tesseract are run in combined mode, threshold on
123  // output of combiner binary classifier (chosen from ROC during
124  // combiner training). When Cube is run without Tesseract, this is ignored.
126 };
127 }
128 
129 #endif // TUNING_PARAMS_H
int HistWindWid() const
Definition: tuning_params.h:57
virtual bool Load(string file_name)=0
double MaxSpaceHeightRatio() const
Definition: tuning_params.h:61
double CombinerClassifierThresh() const
Definition: tuning_params.h:63
void SetHistWindWid(int hist_wind_wid)
Definition: tuning_params.h:78
double WordUnigramWgt() const
Definition: tuning_params.h:51
double MinSpaceHeightRatio() const
Definition: tuning_params.h:60
int MaxSegPerChar() const
Definition: tuning_params.h:52
void SetTypeFeature(type_feature tp_feat)
Definition: tuning_params.h:77
void SetBeamWidth(int beam_width)
Definition: tuning_params.h:73
virtual bool Save(string file_name)=0
double CharBigramWgt() const
Definition: tuning_params.h:50
int TypeFeature() const
Definition: tuning_params.h:55
void SetTypeClassifier(type_classifer tp_classifier)
Definition: tuning_params.h:74
void SetMaxSegPerChar(int max_seg_per_char)
Definition: tuning_params.h:70
void SetRecoWgt(double wgt)
Definition: tuning_params.h:66
void SetCharBigramWgt(double wgt)
Definition: tuning_params.h:68
double RecoWgt() const
Definition: tuning_params.h:48
void SetSizeWgt(double wgt)
Definition: tuning_params.h:67
double SizeWgt() const
Definition: tuning_params.h:49
double CombinerRunThresh() const
Definition: tuning_params.h:62
int MinConCompSize() const
Definition: tuning_params.h:58
int TypeClassifier() const
Definition: tuning_params.h:54
double MaxWordAspectRatio() const
Definition: tuning_params.h:59
type_classifer tp_classifier_
int ConvGridSize() const
Definition: tuning_params.h:56
void SetWordUnigramWgt(double wgt)
Definition: tuning_params.h:69