tesseract v5.3.3.20231005
publictypes.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// File: publictypes.h
3// Description: Types used in both the API and internally
4// Author: Ray Smith
5//
6// (C) Copyright 2010, Google Inc.
7// Licensed under the Apache License, Version 2.0 (the "License");
8// you may not use this file except in compliance with the License.
9// You may obtain a copy of the License at
10// http://www.apache.org/licenses/LICENSE-2.0
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
17#ifndef TESSERACT_CCSTRUCT_PUBLICTYPES_H_
18#define TESSERACT_CCSTRUCT_PUBLICTYPES_H_
19
20namespace tesseract {
21
22// This file contains types that are used both by the API and internally
23// to Tesseract. In order to decouple the API from Tesseract and prevent cyclic
24// dependencies, THIS FILE SHOULD NOT DEPEND ON ANY OTHER PART OF TESSERACT.
25// Restated: It is OK for low-level Tesseract files to include publictypes.h,
26// but not for the low-level tesseract code to include top-level API code.
27// This file should not use other Tesseract types, as that would drag
28// their includes into the API-level.
29
31constexpr int kPointsPerInch = 72;
36constexpr int kMinCredibleResolution = 70;
38constexpr int kMaxCredibleResolution = 2400;
43constexpr int kResolutionEstimationFactor = 10;
44
52 PT_UNKNOWN, // Type is not yet known. Keep as the first element.
53 PT_FLOWING_TEXT, // Text that lives inside a column.
54 PT_HEADING_TEXT, // Text that spans more than one column.
55 PT_PULLOUT_TEXT, // Text that is in a cross-column pull-out region.
56 PT_EQUATION, // Partition belonging to an equation region.
57 PT_INLINE_EQUATION, // Partition has inline equation.
58 PT_TABLE, // Partition belonging to a table region.
59 PT_VERTICAL_TEXT, // Text-line runs vertically.
60 PT_CAPTION_TEXT, // Text that belongs to an image.
61 PT_FLOWING_IMAGE, // Image that lives inside a column.
62 PT_HEADING_IMAGE, // Image that spans more than one column.
63 PT_PULLOUT_IMAGE, // Image that is in a cross-column pull-out region.
64 PT_HORZ_LINE, // Horizontal Line.
65 PT_VERT_LINE, // Vertical Line.
66 PT_NOISE, // Lies outside of any column.
68};
69
72 return type == PT_HORZ_LINE || type == PT_VERT_LINE;
73}
78}
81 return type == PT_FLOWING_TEXT || type == PT_HEADING_TEXT ||
85}
86// Returns true if PolyBlockType is of pullout(inter-column) type
89}
90
119};
120
133};
134
150};
151
159 PSM_AUTO_OSD = 1,
172 11,
174 PSM_RAW_LINE = 13,
176
177 PSM_COUNT
179
186inline bool PSM_OSD_ENABLED(int pageseg_mode) {
187 return pageseg_mode <= PSM_AUTO_OSD || pageseg_mode == PSM_SPARSE_TEXT_OSD;
188}
189inline bool PSM_ORIENTATION_ENABLED(int pageseg_mode) {
190 return pageseg_mode <= PSM_AUTO || pageseg_mode == PSM_SPARSE_TEXT_OSD;
191}
192inline bool PSM_COL_FIND_ENABLED(int pageseg_mode) {
193 return pageseg_mode >= PSM_AUTO_OSD && pageseg_mode <= PSM_AUTO;
194}
195inline bool PSM_SPARSE(int pageseg_mode) {
196 return pageseg_mode == PSM_SPARSE_TEXT || pageseg_mode == PSM_SPARSE_TEXT_OSD;
197}
198inline bool PSM_BLOCK_FIND_ENABLED(int pageseg_mode) {
199 return pageseg_mode >= PSM_AUTO_OSD && pageseg_mode <= PSM_SINGLE_COLUMN;
200}
201inline bool PSM_LINE_FIND_ENABLED(int pageseg_mode) {
202 return pageseg_mode >= PSM_AUTO_OSD && pageseg_mode <= PSM_SINGLE_BLOCK;
203}
204inline bool PSM_WORD_FIND_ENABLED(int pageseg_mode) {
205 return (pageseg_mode >= PSM_AUTO_OSD && pageseg_mode <= PSM_SINGLE_LINE) ||
206 pageseg_mode == PSM_SPARSE_TEXT || pageseg_mode == PSM_SPARSE_TEXT_OSD;
207}
208
215 RIL_BLOCK, // Block of text/image/separator line.
216 RIL_PARA, // Paragraph within a block.
217 RIL_TEXTLINE, // Line within a paragraph.
218 RIL_WORD, // Word within a textline.
219 RIL_SYMBOL // Symbol/character within a word.
221
251};
252
264 OEM_TESSERACT_ONLY, // Run Tesseract only - fastest; deprecated
265 OEM_LSTM_ONLY, // Run just the LSTM line recognizer.
266 OEM_TESSERACT_LSTM_COMBINED, // Run the LSTM recognizer, but allow fallback
267 // to Tesseract when things get difficult.
268 // deprecated
269 OEM_DEFAULT, // Specify this mode when calling init_*(),
270 // to indicate that any of the above modes
271 // should be automatically inferred from the
272 // variables in the language-specific config,
273 // command-line configs, or if not specified
274 // in any of the above should be set to the
275 // default OEM_TESSERACT_ONLY.
276 OEM_COUNT // Number of OEMs
278
279} // namespace tesseract.
280
281#endif // TESSERACT_CCSTRUCT_PUBLICTYPES_H_
constexpr int kResolutionEstimationFactor
Definition: publictypes.h:43
@ OEM_TESSERACT_LSTM_COMBINED
Definition: publictypes.h:266
@ OEM_TESSERACT_ONLY
Definition: publictypes.h:264
bool PTIsLineType(PolyBlockType type)
Definition: publictypes.h:71
@ TEXTLINE_ORDER_LEFT_TO_RIGHT
Definition: publictypes.h:147
@ TEXTLINE_ORDER_RIGHT_TO_LEFT
Definition: publictypes.h:148
@ TEXTLINE_ORDER_TOP_TO_BOTTOM
Definition: publictypes.h:149
bool PSM_OSD_ENABLED(int pageseg_mode)
Definition: publictypes.h:186
@ PSM_CIRCLE_WORD
Treat the image as a single word in a circle.
Definition: publictypes.h:169
@ PSM_OSD_ONLY
Orientation and script detection only.
Definition: publictypes.h:158
@ PSM_COUNT
Number of enum entries.
Definition: publictypes.h:177
@ PSM_SPARSE_TEXT
Find as much text as possible in no particular order.
Definition: publictypes.h:171
@ PSM_AUTO_ONLY
Automatic page segmentation, but no OSD, or OCR.
Definition: publictypes.h:161
@ PSM_SINGLE_BLOCK_VERT_TEXT
Definition: publictypes.h:164
@ PSM_SINGLE_CHAR
Treat the image as a single character.
Definition: publictypes.h:170
@ PSM_SINGLE_COLUMN
Assume a single column of text of variable sizes.
Definition: publictypes.h:163
@ PSM_AUTO
Fully automatic page segmentation, but no OSD.
Definition: publictypes.h:162
@ PSM_SINGLE_WORD
Treat the image as a single word.
Definition: publictypes.h:168
@ PSM_SINGLE_BLOCK
Assume a single uniform block of text. (Default.)
Definition: publictypes.h:166
@ PSM_SINGLE_LINE
Treat the image as a single text line.
Definition: publictypes.h:167
@ PSM_SPARSE_TEXT_OSD
Sparse text with orientation and script det.
Definition: publictypes.h:173
bool PSM_ORIENTATION_ENABLED(int pageseg_mode)
Definition: publictypes.h:189
bool PSM_LINE_FIND_ENABLED(int pageseg_mode)
Definition: publictypes.h:201
ParagraphJustification
Definition: publictypes.h:246
@ JUSTIFICATION_LEFT
Definition: publictypes.h:248
@ JUSTIFICATION_UNKNOWN
Definition: publictypes.h:247
@ JUSTIFICATION_RIGHT
Definition: publictypes.h:250
@ JUSTIFICATION_CENTER
Definition: publictypes.h:249
bool PSM_COL_FIND_ENABLED(int pageseg_mode)
Definition: publictypes.h:192
bool PTIsImageType(PolyBlockType type)
Definition: publictypes.h:75
@ ORIENTATION_PAGE_LEFT
Definition: publictypes.h:118
@ ORIENTATION_PAGE_DOWN
Definition: publictypes.h:117
@ ORIENTATION_PAGE_UP
Definition: publictypes.h:115
@ ORIENTATION_PAGE_RIGHT
Definition: publictypes.h:116
constexpr int kMaxCredibleResolution
Definition: publictypes.h:38
bool PSM_SPARSE(int pageseg_mode)
Definition: publictypes.h:195
bool PTIsPulloutType(PolyBlockType type)
Definition: publictypes.h:87
@ WRITING_DIRECTION_TOP_TO_BOTTOM
Definition: publictypes.h:132
@ WRITING_DIRECTION_LEFT_TO_RIGHT
Definition: publictypes.h:130
@ WRITING_DIRECTION_RIGHT_TO_LEFT
Definition: publictypes.h:131
constexpr int kMinCredibleResolution
Definition: publictypes.h:36
bool PTIsTextType(PolyBlockType type)
Definition: publictypes.h:80
bool PSM_WORD_FIND_ENABLED(int pageseg_mode)
Definition: publictypes.h:204
@ PT_VERTICAL_TEXT
Definition: publictypes.h:59
@ PT_PULLOUT_IMAGE
Definition: publictypes.h:63
@ PT_HEADING_IMAGE
Definition: publictypes.h:62
@ PT_CAPTION_TEXT
Definition: publictypes.h:60
@ PT_HORZ_LINE
Definition: publictypes.h:64
@ PT_FLOWING_IMAGE
Definition: publictypes.h:61
@ PT_VERT_LINE
Definition: publictypes.h:65
@ PT_INLINE_EQUATION
Definition: publictypes.h:57
@ PT_PULLOUT_TEXT
Definition: publictypes.h:55
@ PT_HEADING_TEXT
Definition: publictypes.h:54
@ PT_FLOWING_TEXT
Definition: publictypes.h:53
bool PSM_BLOCK_FIND_ENABLED(int pageseg_mode)
Definition: publictypes.h:198
constexpr int kPointsPerInch
Definition: publictypes.h:31
type
Definition: upload.py:458