tesseract  4.00.00dev
publictypes.h
Go to the documentation of this file.
1 // File: publictypes.h
3 // Description: Types used in both the API and internally
4 // Author: Ray Smith
5 // Created: Wed Mar 03 09:22:53 PST 2010
6 //
7 // (C) Copyright 2010, 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 //
19 
20 #ifndef TESSERACT_CCSTRUCT_PUBLICTYPES_H_
21 #define TESSERACT_CCSTRUCT_PUBLICTYPES_H_
22 
23 // This file contains types that are used both by the API and internally
24 // to Tesseract. In order to decouple the API from Tesseract and prevent cyclic
25 // dependencies, THIS FILE SHOULD NOT DEPEND ON ANY OTHER PART OF TESSERACT.
26 // Restated: It is OK for low-level Tesseract files to include publictypes.h,
27 // but not for the low-level tesseract code to include top-level API code.
28 // This file should not use other Tesseract types, as that would drag
29 // their includes into the API-level.
30 // API-level code should include apitypes.h in preference to this file.
31 
33 const int kPointsPerInch = 72;
34 
42  PT_UNKNOWN, // Type is not yet known. Keep as the first element.
43  PT_FLOWING_TEXT, // Text that lives inside a column.
44  PT_HEADING_TEXT, // Text that spans more than one column.
45  PT_PULLOUT_TEXT, // Text that is in a cross-column pull-out region.
46  PT_EQUATION, // Partition belonging to an equation region.
47  PT_INLINE_EQUATION, // Partition has inline equation.
48  PT_TABLE, // Partition belonging to a table region.
49  PT_VERTICAL_TEXT, // Text-line runs vertically.
50  PT_CAPTION_TEXT, // Text that belongs to an image.
51  PT_FLOWING_IMAGE, // Image that lives inside a column.
52  PT_HEADING_IMAGE, // Image that spans more than one column.
53  PT_PULLOUT_IMAGE, // Image that is in a cross-column pull-out region.
54  PT_HORZ_LINE, // Horizontal Line.
55  PT_VERT_LINE, // Vertical Line.
56  PT_NOISE, // Lies outside of any column.
58 };
59 
61 inline bool PTIsLineType(PolyBlockType type) {
62  return type == PT_HORZ_LINE || type == PT_VERT_LINE;
63 }
65 inline bool PTIsImageType(PolyBlockType type) {
66  return type == PT_FLOWING_IMAGE || type == PT_HEADING_IMAGE ||
67  type == PT_PULLOUT_IMAGE;
68 }
70 inline bool PTIsTextType(PolyBlockType type) {
71  return type == PT_FLOWING_TEXT || type == PT_HEADING_TEXT ||
72  type == PT_PULLOUT_TEXT || type == PT_TABLE ||
73  type == PT_VERTICAL_TEXT || type == PT_CAPTION_TEXT ||
74  type == PT_INLINE_EQUATION;
75 }
76 // Returns true if PolyBlockType is of pullout(inter-column) type
77 inline bool PTIsPulloutType(PolyBlockType type) {
78  return type == PT_PULLOUT_IMAGE || type == PT_PULLOUT_TEXT;
79 }
80 
82 extern const char* kPolyBlockNames[];
83 
84 namespace tesseract {
113 };
114 
127 };
128 
144 };
145 
154  PSM_AUTO_ONLY,
168 
171 };
172 
179 inline bool PSM_OSD_ENABLED(int pageseg_mode) {
180  return pageseg_mode <= PSM_AUTO_OSD || pageseg_mode == PSM_SPARSE_TEXT_OSD;
181 }
182 inline bool PSM_ORIENTATION_ENABLED(int pageseg_mode) {
183  return pageseg_mode <= PSM_AUTO || pageseg_mode == PSM_SPARSE_TEXT_OSD;
184 }
185 inline bool PSM_COL_FIND_ENABLED(int pageseg_mode) {
186  return pageseg_mode >= PSM_AUTO_OSD && pageseg_mode <= PSM_AUTO;
187 }
188 inline bool PSM_SPARSE(int pageseg_mode) {
189  return pageseg_mode == PSM_SPARSE_TEXT || pageseg_mode == PSM_SPARSE_TEXT_OSD;
190 }
191 inline bool PSM_BLOCK_FIND_ENABLED(int pageseg_mode) {
192  return pageseg_mode >= PSM_AUTO_OSD && pageseg_mode <= PSM_SINGLE_COLUMN;
193 }
194 inline bool PSM_LINE_FIND_ENABLED(int pageseg_mode) {
195  return pageseg_mode >= PSM_AUTO_OSD && pageseg_mode <= PSM_SINGLE_BLOCK;
196 }
197 inline bool PSM_WORD_FIND_ENABLED(int pageseg_mode) {
198  return (pageseg_mode >= PSM_AUTO_OSD && pageseg_mode <= PSM_SINGLE_LINE) ||
199  pageseg_mode == PSM_SPARSE_TEXT || pageseg_mode == PSM_SPARSE_TEXT_OSD;
200 }
201 
208  RIL_BLOCK, // Block of text/image/separator line.
209  RIL_PARA, // Paragraph within a block.
210  RIL_TEXTLINE, // Line within a paragraph.
211  RIL_WORD, // Word within a textline.
212  RIL_SYMBOL // Symbol/character within a word.
213 };
214 
244 };
245 
257  OEM_TESSERACT_ONLY, // Run Tesseract only - fastest
258  OEM_LSTM_ONLY, // Run just the LSTM line recognizer.
259  OEM_TESSERACT_LSTM_COMBINED, // Run the LSTM recognizer, but allow fallback
260  // to Tesseract when things get difficult.
261  OEM_DEFAULT, // Specify this mode when calling init_*(),
262  // to indicate that any of the above modes
263  // should be automatically inferred from the
264  // variables in the language-specific config,
265  // command-line configs, or if not specified
266  // in any of the above should be set to the
267  // default OEM_TESSERACT_ONLY.
268  OEM_CUBE_ONLY, // Run Cube only - better accuracy, but slower
269  OEM_TESSERACT_CUBE_COMBINED, // Run both and combine results - best accuracy
270 };
271 
272 } // namespace tesseract.
273 
274 #endif // TESSERACT_CCSTRUCT_PUBLICTYPES_H_
bool PTIsLineType(PolyBlockType type)
Definition: publictypes.h:61
bool PSM_SPARSE(int pageseg_mode)
Definition: publictypes.h:188
bool PSM_BLOCK_FIND_ENABLED(int pageseg_mode)
Definition: publictypes.h:191
Treat the image as a single word.
Definition: publictypes.h:162
bool PSM_OSD_ENABLED(int pageseg_mode)
Definition: publictypes.h:179
bool PTIsPulloutType(PolyBlockType type)
Definition: publictypes.h:77
PolyBlockType
Definition: publictypes.h:41
Treat the image as a single character.
Definition: publictypes.h:164
Assume a single uniform block of text. (Default.)
Definition: publictypes.h:160
Number of enum entries.
Definition: publictypes.h:170
bool PSM_LINE_FIND_ENABLED(int pageseg_mode)
Definition: publictypes.h:194
Assume a single column of text of variable sizes.
Definition: publictypes.h:157
Treat the image as a single text line.
Definition: publictypes.h:161
Automatic page segmentation, but no OSD, or OCR.
Definition: publictypes.h:155
Treat the image as a single word in a circle.
Definition: publictypes.h:163
bool PSM_WORD_FIND_ENABLED(int pageseg_mode)
Definition: publictypes.h:197
const char * kPolyBlockNames[]
Definition: publictypes.cpp:23
Find as much text as possible in no particular order.
Definition: publictypes.h:165
bool PSM_COL_FIND_ENABLED(int pageseg_mode)
Definition: publictypes.h:185
bool PTIsImageType(PolyBlockType type)
Definition: publictypes.h:65
bool PTIsTextType(PolyBlockType type)
Definition: publictypes.h:70
Fully automatic page segmentation, but no OSD.
Definition: publictypes.h:156
ParagraphJustification
Definition: publictypes.h:239
Orientation and script detection only.
Definition: publictypes.h:152
const int kPointsPerInch
Definition: publictypes.h:33
bool PSM_ORIENTATION_ENABLED(int pageseg_mode)
Definition: publictypes.h:182
Sparse text with orientation and script det.
Definition: publictypes.h:166