29
29
// their includes into the API-level.
30
30
// API-level code should include apitypes.h in preference to this file.
32
// Number of printers' points in an inch. The unit of the pointsize return.
32
/** Number of printers' points in an inch. The unit of the pointsize return. */
33
33
const int kPointsPerInch = 72;
35
// Possible types for a POLY_BLOCK or ColPartition.
36
// Must be kept in sync with kPBColors in polyblk.cpp and PTIs*Type functions
37
// below, as well as kPolyBlockNames in publictypes.cpp.
38
// Used extensively by ColPartition, and POLY_BLOCK.
36
* Possible types for a POLY_BLOCK or ColPartition.
37
* Must be kept in sync with kPBColors in polyblk.cpp and PTIs*Type functions
38
* below, as well as kPolyBlockNames in publictypes.cpp.
39
* Used extensively by ColPartition, and POLY_BLOCK.
39
41
enum PolyBlockType {
40
42
PT_UNKNOWN, // Type is not yet known. Keep as the first element.
41
43
PT_FLOWING_TEXT, // Text that lives inside a column.
58
// Returns true if PolyBlockType is of horizontal line type
60
/** Returns true if PolyBlockType is of horizontal line type */
59
61
inline bool PTIsLineType(PolyBlockType type) {
60
62
return type == PT_HORZ_LINE || type == PT_VERT_LINE;
62
// Returns true if PolyBlockType is of image type
64
/** Returns true if PolyBlockType is of image type */
63
65
inline bool PTIsImageType(PolyBlockType type) {
64
66
return type == PT_FLOWING_IMAGE || type == PT_HEADING_IMAGE ||
65
67
type == PT_PULLOUT_IMAGE;
67
// Returns true if PolyBlockType is of text type
69
/** Returns true if PolyBlockType is of text type */
68
70
inline bool PTIsTextType(PolyBlockType type) {
69
71
return type == PT_FLOWING_TEXT || type == PT_HEADING_TEXT ||
70
72
type == PT_PULLOUT_TEXT || type == PT_TABLE ||
72
74
type == PT_INLINE_EQUATION;
75
// String name for each block type. Keep in sync with PolyBlockType.
77
/** String name for each block type. Keep in sync with PolyBlockType. */
76
78
extern const char* kPolyBlockNames[];
78
80
namespace tesseract {
79
// +------------------+ Orientation Example:
80
// | 1 Aaaa Aaaa Aaaa | ====================
81
// | Aaa aa aaa aa | To left is a diagram of some (1) English and
82
// | aaaaaa A aa aaa. | (2) Chinese text and a (3) photo credit.
84
// | ####### c c C | Upright Latin characters are represented as A and a.
85
// | ####### c c c | '<' represents a latin character rotated
86
// | < ####### c c c | anti-clockwise 90 degrees.
88
// | < ####### . c | Upright Chinese characters are represented C and c.
90
// +------------------+ NOTA BENE: enum values here should match goodoc.proto
82
* +------------------+ Orientation Example:
83
* | 1 Aaaa Aaaa Aaaa | ====================
84
* | Aaa aa aaa aa | To left is a diagram of some (1) English and
85
* | aaaaaa A aa aaa. | (2) Chinese text and a (3) photo credit.
87
* | ####### c c C | Upright Latin characters are represented as A and a.
88
* | ####### c c c | '<' represents a latin character rotated
89
* | < ####### c c c | anti-clockwise 90 degrees.
91
* | < ####### . c | Upright Chinese characters are represented C and c.
93
* +------------------+ NOTA BENE: enum values here should match goodoc.proto
92
// If you orient your head so that "up" aligns with Orientation,
93
// then the characters will appear "right side up" and readable.
95
// In the example above, both the English and Chinese paragraphs are oriented
96
// so their "up" is the top of the page (page up). The photo credit is read
97
// with one's head turned leftward ("up" is to page left).
99
// The values of this enum match the convention of Tesseract's osdetect.h
95
* If you orient your head so that "up" aligns with Orientation,
96
* then the characters will appear "right side up" and readable.
98
* In the example above, both the English and Chinese paragraphs are oriented
99
* so their "up" is the top of the page (page up). The photo credit is read
100
* with one's head turned leftward ("up" is to page left).
102
* The values of this enum match the convention of Tesseract's osdetect.h
100
104
enum Orientation {
101
105
ORIENTATION_PAGE_UP = 0,
102
106
ORIENTATION_PAGE_RIGHT = 1,
104
108
ORIENTATION_PAGE_LEFT = 3,
107
// The grapheme clusters within a line of text are laid out logically
108
// in this direction, judged when looking at the text line rotated so that
109
// its Orientation is "page up".
111
// For English text, the writing direction is left-to-right. For the
112
// Chinese text in the above example, the writing direction is top-to-bottom.
112
* The grapheme clusters within a line of text are laid out logically
113
* in this direction, judged when looking at the text line rotated so that
114
* its Orientation is "page up".
116
* For English text, the writing direction is left-to-right. For the
117
* Chinese text in the above example, the writing direction is top-to-bottom.
113
119
enum WritingDirection {
114
120
WRITING_DIRECTION_LEFT_TO_RIGHT = 0,
115
121
WRITING_DIRECTION_RIGHT_TO_LEFT = 1,
116
122
WRITING_DIRECTION_TOP_TO_BOTTOM = 2,
119
// The text lines are read in the given sequence.
121
// In English, the order is top-to-bottom.
122
// In Chinese, vertical text lines are read right-to-left. Mongolian is
123
// written in vertical columns top to bottom like Chinese, but the lines
124
// order left-to right.
126
// Note that only some combinations make sense. For example,
127
// WRITING_DIRECTION_LEFT_TO_RIGHT implies TEXTLINE_ORDER_TOP_TO_BOTTOM
126
* The text lines are read in the given sequence.
128
* In English, the order is top-to-bottom.
129
* In Chinese, vertical text lines are read right-to-left. Mongolian is
130
* written in vertical columns top to bottom like Chinese, but the lines
131
* order left-to right.
133
* Note that only some combinations make sense. For example,
134
* WRITING_DIRECTION_LEFT_TO_RIGHT implies TEXTLINE_ORDER_TOP_TO_BOTTOM
128
136
enum TextlineOrder {
129
137
TEXTLINE_ORDER_LEFT_TO_RIGHT = 0,
130
138
TEXTLINE_ORDER_RIGHT_TO_LEFT = 1,
131
139
TEXTLINE_ORDER_TOP_TO_BOTTOM = 2,
134
// Possible modes for page layout analysis. These *must* be kept in order
135
// of decreasing amount of layout analysis to be done, except for OSD_ONLY,
136
// so that the inequality test macros below work.
143
* Possible modes for page layout analysis. These *must* be kept in order
144
* of decreasing amount of layout analysis to be done, except for OSD_ONLY,
145
* so that the inequality test macros below work.
137
147
enum PageSegMode {
138
148
PSM_OSD_ONLY, ///< Orientation and script detection only.
139
149
PSM_AUTO_OSD, ///< Automatic page segmentation with orientation and
152
162
PSM_COUNT ///< Number of enum entries.
155
// Macros that act on a PageSegMode to determine whether components of
156
// layout analysis are enabled.
157
// *Depend critically on the order of elements of PageSegMode.*
166
* Macros that act on a PageSegMode to determine whether components of
167
* layout analysis are enabled.
168
* *Depend critically on the order of elements of PageSegMode.*
158
170
#define PSM_OSD_ENABLED(pageseg_mode) ((pageseg_mode) <= PSM_AUTO_OSD)
159
171
#define PSM_COL_FIND_ENABLED(pageseg_mode) \
160
172
((pageseg_mode) >= PSM_AUTO_OSD && (pageseg_mode) <= PSM_AUTO)
165
177
#define PSM_WORD_FIND_ENABLED(pageseg_mode) \
166
178
((pageseg_mode) >= PSM_AUTO_OSD && (pageseg_mode) <= PSM_SINGLE_LINE)
168
// enum of the elements of the page hierarchy, used in ResultIterator
169
// to provide functions that operate on each level without having to
170
// have 5x as many functions.
181
* enum of the elements of the page hierarchy, used in ResultIterator
182
* to provide functions that operate on each level without having to
183
* have 5x as many functions.
171
185
enum PageIteratorLevel {
172
186
RIL_BLOCK, // Block of text/image/separator line.
173
187
RIL_PARA, // Paragraph within a block.
176
190
RIL_SYMBOL // Symbol/character within a word.
179
// JUSTIFICATION_UNKNONW
180
// The alignment is not clearly one of the other options. This could happen
181
// for example if there are only one or two lines of text or the text looks
182
// like source code or poetry.
184
// NOTA BENE: Fully justified paragraphs (text aligned to both left and right
185
// margins) are marked by Tesseract with JUSTIFICATION_LEFT if their text
186
// is written with a left-to-right script and with JUSTIFICATION_RIGHT if
187
// their text is written in a right-to-left script.
189
// Interpretation for text read in vertical lines:
190
// "Left" is wherever the starting reading position is.
192
// JUSTIFICATION_LEFT
193
// Each line, except possibly the first, is flush to the same left tab stop.
195
// JUSTIFICATION_CENTER
196
// The text lines of the paragraph are centered about a line going
197
// down through their middle of the text lines.
199
// JUSTIFICATION_RIGHT
200
// Each line, except possibly the first, is flush to the same right tab stop.
194
* JUSTIFICATION_UNKNONW
195
* The alignment is not clearly one of the other options. This could happen
196
* for example if there are only one or two lines of text or the text looks
197
* like source code or poetry.
199
* NOTA BENE: Fully justified paragraphs (text aligned to both left and right
200
* margins) are marked by Tesseract with JUSTIFICATION_LEFT if their text
201
* is written with a left-to-right script and with JUSTIFICATION_RIGHT if
202
* their text is written in a right-to-left script.
204
* Interpretation for text read in vertical lines:
205
* "Left" is wherever the starting reading position is.
208
* Each line, except possibly the first, is flush to the same left tab stop.
210
* JUSTIFICATION_CENTER
211
* The text lines of the paragraph are centered about a line going
212
* down through their middle of the text lines.
214
* JUSTIFICATION_RIGHT
215
* Each line, except possibly the first, is flush to the same right tab stop.
201
217
enum ParagraphJustification {
202
218
JUSTIFICATION_UNKNOWN,
203
219
JUSTIFICATION_LEFT,
205
221
JUSTIFICATION_RIGHT,
208
// When Tesseract/Cube is initialized we can choose to instantiate/load/run
209
// only the Tesseract part, only the Cube part or both along with the combiner.
210
// The preference of which engine to use is stored in tessedit_ocr_engine_mode.
212
// ATTENTION: When modifying this enum, please make sure to make the
213
// appropriate changes to all the enums mirroring it (e.g. OCREngine in
214
// cityblock/workflow/detection/detection_storage.proto). Such enums will
215
// mention the connection to OcrEngineMode in the comments.
225
* When Tesseract/Cube is initialized we can choose to instantiate/load/run
226
* only the Tesseract part, only the Cube part or both along with the combiner.
227
* The preference of which engine to use is stored in tessedit_ocr_engine_mode.
229
* ATTENTION: When modifying this enum, please make sure to make the
230
* appropriate changes to all the enums mirroring it (e.g. OCREngine in
231
* cityblock/workflow/detection/detection_storage.proto). Such enums will
232
* mention the connection to OcrEngineMode in the comments.
216
234
enum OcrEngineMode {
217
235
OEM_TESSERACT_ONLY, // Run Tesseract only - fastest
218
236
OEM_CUBE_ONLY, // Run Cube only - better accuracy, but slower