Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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:
35 enum type_classifer {
36 NN,
37 HYBRID_NN
38 };
39 enum type_feature {
40 BMP,
41 CHEBYSHEV,
42 HYBRID
43 };
44
45 TuningParams() {}
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 {
64 return combiner_classifier_thresh_; }
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
91 double char_bigrams_wgt_;
92 // weight of word unigrams cost
93 double word_unigrams_wgt_;
94 // Maximum number of segments per character
95 int max_seg_per_char_;
96 // Beam width equal to the maximum number of nodes kept in the beam search
97 // trellis column after pruning
98 int beam_width_;
99 // Classifier type: See enum type_classifer for classifier types
100 type_classifer tp_classifier_;
101 // Feature types: See enum type_feature for feature types
102 type_feature tp_feat_;
103 // Grid size to scale a grapheme bitmap used by the BMP feature type
104 int conv_grid_size_;
105 // Histogram window size as a ratio of the word height used in computing
106 // the vertical pixel density histogram in the segmentation algorithm
107 int hist_wind_wid_;
108 // Minimum possible size of a connected component
109 int min_con_comp_size_;
110 // Maximum aspect ratio of a word (width / height)
111 double max_word_aspect_ratio_;
112 // Minimum ratio relative to the line height of a gap to be considered as
113 // a word break
114 double min_space_height_ratio_;
115 // Maximum ratio relative to the line height of a gap to be considered as
116 // a definite word break
117 double max_space_height_ratio_;
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.
121 double combiner_run_thresh_;
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.
125 double combiner_classifier_thresh_;
126 };
127 }
128
129 #endif // TUNING_PARAMS_H