tesseract  v4.0.0-17-g361f3264
Open Source OCR Engine
publictypes.h
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 constexpr int kPointsPerInch = 72;
38 constexpr int kMinCredibleResolution = 70;
40 constexpr int kMaxCredibleResolution = 2400;
45 constexpr int kResolutionEstimationFactor = 10;
46 
53 enum PolyBlockType {
54  PT_UNKNOWN, // Type is not yet known. Keep as the first element.
55  PT_FLOWING_TEXT, // Text that lives inside a column.
56  PT_HEADING_TEXT, // Text that spans more than one column.
57  PT_PULLOUT_TEXT, // Text that is in a cross-column pull-out region.
58  PT_EQUATION, // Partition belonging to an equation region.
59  PT_INLINE_EQUATION, // Partition has inline equation.
60  PT_TABLE, // Partition belonging to a table region.
61  PT_VERTICAL_TEXT, // Text-line runs vertically.
62  PT_CAPTION_TEXT, // Text that belongs to an image.
63  PT_FLOWING_IMAGE, // Image that lives inside a column.
64  PT_HEADING_IMAGE, // Image that spans more than one column.
65  PT_PULLOUT_IMAGE, // Image that is in a cross-column pull-out region.
66  PT_HORZ_LINE, // Horizontal Line.
67  PT_VERT_LINE, // Vertical Line.
68  PT_NOISE, // Lies outside of any column.
69  PT_COUNT
70 };
71 
73 inline bool PTIsLineType(PolyBlockType type) {
74  return type == PT_HORZ_LINE || type == PT_VERT_LINE;
75 }
77 inline bool PTIsImageType(PolyBlockType type) {
78  return type == PT_FLOWING_IMAGE || type == PT_HEADING_IMAGE ||
79  type == PT_PULLOUT_IMAGE;
80 }
82 inline bool PTIsTextType(PolyBlockType type) {
83  return type == PT_FLOWING_TEXT || type == PT_HEADING_TEXT ||
84  type == PT_PULLOUT_TEXT || type == PT_TABLE ||
85  type == PT_VERTICAL_TEXT || type == PT_CAPTION_TEXT ||
86  type == PT_INLINE_EQUATION;
87 }
88 // Returns true if PolyBlockType is of pullout(inter-column) type
89 inline bool PTIsPulloutType(PolyBlockType type) {
90  return type == PT_PULLOUT_IMAGE || type == PT_PULLOUT_TEXT;
91 }
92 
94 extern const char* kPolyBlockNames[];
95 
96 namespace tesseract {
125 };
126 
139 };
140 
156 };
157 
166  PSM_AUTO_ONLY,
180 
183 };
184 
191 inline bool PSM_OSD_ENABLED(int pageseg_mode) {
192  return pageseg_mode <= PSM_AUTO_OSD || pageseg_mode == PSM_SPARSE_TEXT_OSD;
193 }
194 inline bool PSM_ORIENTATION_ENABLED(int pageseg_mode) {
195  return pageseg_mode <= PSM_AUTO || pageseg_mode == PSM_SPARSE_TEXT_OSD;
196 }
197 inline bool PSM_COL_FIND_ENABLED(int pageseg_mode) {
198  return pageseg_mode >= PSM_AUTO_OSD && pageseg_mode <= PSM_AUTO;
199 }
200 inline bool PSM_SPARSE(int pageseg_mode) {
201  return pageseg_mode == PSM_SPARSE_TEXT || pageseg_mode == PSM_SPARSE_TEXT_OSD;
202 }
203 inline bool PSM_BLOCK_FIND_ENABLED(int pageseg_mode) {
204  return pageseg_mode >= PSM_AUTO_OSD && pageseg_mode <= PSM_SINGLE_COLUMN;
205 }
206 inline bool PSM_LINE_FIND_ENABLED(int pageseg_mode) {
207  return pageseg_mode >= PSM_AUTO_OSD && pageseg_mode <= PSM_SINGLE_BLOCK;
208 }
209 inline bool PSM_WORD_FIND_ENABLED(int pageseg_mode) {
210  return (pageseg_mode >= PSM_AUTO_OSD && pageseg_mode <= PSM_SINGLE_LINE) ||
211  pageseg_mode == PSM_SPARSE_TEXT || pageseg_mode == PSM_SPARSE_TEXT_OSD;
212 }
213 
220  RIL_BLOCK, // Block of text/image/separator line.
221  RIL_PARA, // Paragraph within a block.
222  RIL_TEXTLINE, // Line within a paragraph.
223  RIL_WORD, // Word within a textline.
224  RIL_SYMBOL // Symbol/character within a word.
225 };
226 
256 };
257 
269  OEM_TESSERACT_ONLY, // Run Tesseract only - fastest; deprecated
270  OEM_LSTM_ONLY, // Run just the LSTM line recognizer.
271  OEM_TESSERACT_LSTM_COMBINED, // Run the LSTM recognizer, but allow fallback
272  // to Tesseract when things get difficult.
273  // deprecated
274  OEM_DEFAULT, // Specify this mode when calling init_*(),
275  // to indicate that any of the above modes
276  // should be automatically inferred from the
277  // variables in the language-specific config,
278  // command-line configs, or if not specified
279  // in any of the above should be set to the
280  // default OEM_TESSERACT_ONLY.
281  OEM_COUNT // Number of OEMs
282 };
283 
284 } // namespace tesseract.
285 
286 #endif // TESSERACT_CCSTRUCT_PUBLICTYPES_H_
Treat the image as a single text line.
Definition: publictypes.h:173
WritingDirection
Definition: publictypes.h:135
Definition: publictypes.h:138
Definition: publictypes.h:221
bool PSM_COL_FIND_ENABLED(int pageseg_mode)
Definition: publictypes.h:197
bool PSM_ORIENTATION_ENABLED(int pageseg_mode)
Definition: publictypes.h:194
Definition: publictypes.h:269
Treat the image as a single word.
Definition: publictypes.h:174
Fully automatic page segmentation, but no OSD.
Definition: publictypes.h:168
bool PSM_SPARSE(int pageseg_mode)
Definition: publictypes.h:200
Definition: publictypes.h:271
Find as much text as possible in no particular order.
Definition: publictypes.h:177
Definition: publictypes.h:123
Definition: publictypes.h:179
bool PSM_OSD_ENABLED(int pageseg_mode)
Definition: publictypes.h:191
Definition: publictypes.h:122
Definition: baseapi.cpp:94
Sparse text with orientation and script det.
Definition: publictypes.h:178
PageIteratorLevel
Definition: publictypes.h:219
Definition: publictypes.h:124
Definition: publictypes.h:223
Automatic page segmentation, but no OSD, or OCR.
Definition: publictypes.h:167
Definition: publictypes.h:153
Definition: publictypes.h:281
Definition: publictypes.h:136
Orientation and script detection only.
Definition: publictypes.h:164
Definition: publictypes.h:137
Treat the image as a single character.
Definition: publictypes.h:176
ParagraphJustification
Definition: publictypes.h:251
Definition: publictypes.h:220
Definition: publictypes.h:222
bool PSM_WORD_FIND_ENABLED(int pageseg_mode)
Definition: publictypes.h:209
Orientation
Definition: publictypes.h:120
Definition: publictypes.h:170
Definition: publictypes.h:255
Treat the image as a single word in a circle.
Definition: publictypes.h:175
Definition: publictypes.h:254
bool PSM_BLOCK_FIND_ENABLED(int pageseg_mode)
Definition: publictypes.h:203
Definition: publictypes.h:154
bool PSM_LINE_FIND_ENABLED(int pageseg_mode)
Definition: publictypes.h:206
TextlineOrder
Definition: publictypes.h:152
Definition: publictypes.h:252
Definition: publictypes.h:165
Assume a single column of text of variable sizes.
Definition: publictypes.h:169
Number of enum entries.
Definition: publictypes.h:182
Definition: publictypes.h:155
Definition: publictypes.h:253
Definition: publictypes.h:224
OcrEngineMode
Definition: publictypes.h:268
Assume a single uniform block of text. (Default.)
Definition: publictypes.h:172
Definition: publictypes.h:121
Definition: publictypes.h:274
PageSegMode
Definition: publictypes.h:163
Definition: publictypes.h:270