~ubuntu-branches/ubuntu/utopic/tesseract/utopic-proposed

« back to all changes in this revision

Viewing changes to ccstruct/publictypes.h

  • Committer: Package Import Robot
  • Author(s): Jeff Breidenbach
  • Date: 2012-10-23 23:25:05 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20121023232505-01pfq6trlgqtagwj
Tags: 3.02.02-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
// their includes into the API-level.
30
30
// API-level code should include apitypes.h in preference to this file.
31
31
 
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;
34
34
 
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.
 
35
/**
 
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.
 
40
*/
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.
55
57
  PT_COUNT
56
58
};
57
59
 
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;
61
63
}
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;
66
68
}
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;
73
75
}
74
76
 
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[];
77
79
 
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.
83
 
//  |                2 |
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.
87
 
//  | < #######  c   c |
88
 
//  | < #######  .   c |  Upright Chinese characters are represented C and c.
89
 
//  | 3 #######      c |
90
 
//  +------------------+  NOTA BENE: enum values here should match goodoc.proto
 
81
/**
 
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.
 
86
 *  |                2 |
 
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.
 
90
 *  | < #######  c   c |
 
91
 *  | < #######  .   c |  Upright Chinese characters are represented C and c.
 
92
 *  | 3 #######      c |
 
93
 *  +------------------+  NOTA BENE: enum values here should match goodoc.proto
91
94
 
92
 
// If you orient your head so that "up" aligns with Orientation,
93
 
// then the characters will appear "right side up" and readable.
94
 
//
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).
98
 
//
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.
 
97
 *
 
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).
 
101
 *
 
102
 * The values of this enum match the convention of Tesseract's osdetect.h
 
103
*/
100
104
enum Orientation {
101
105
  ORIENTATION_PAGE_UP = 0,
102
106
  ORIENTATION_PAGE_RIGHT = 1,
104
108
  ORIENTATION_PAGE_LEFT = 3,
105
109
};
106
110
 
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".
110
 
//
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.
 
111
/**
 
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".
 
115
 *
 
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.
 
118
*/
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,
117
123
};
118
124
 
119
 
// The text lines are read in the given sequence.
120
 
//
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.
125
 
//
126
 
// Note that only some combinations make sense.  For example,
127
 
// WRITING_DIRECTION_LEFT_TO_RIGHT implies TEXTLINE_ORDER_TOP_TO_BOTTOM
 
125
/**
 
126
 * The text lines are read in the given sequence.
 
127
 *
 
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.
 
132
 *
 
133
 * Note that only some combinations make sense.  For example,
 
134
 * WRITING_DIRECTION_LEFT_TO_RIGHT implies TEXTLINE_ORDER_TOP_TO_BOTTOM
 
135
*/
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,
132
140
};
133
141
 
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.
 
142
/**
 
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.
 
146
*/
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.
153
163
};
154
164
 
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.*
 
165
/**
 
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.*
 
169
*/
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)
167
179
 
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.
 
180
/**
 
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.
 
184
*/
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.
177
191
};
178
192
 
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.
183
 
//
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.
188
 
//
189
 
// Interpretation for text read in vertical lines:
190
 
//   "Left" is wherever the starting reading position is.
191
 
//
192
 
// JUSTIFICATION_LEFT
193
 
//   Each line, except possibly the first, is flush to the same left tab stop.
194
 
//
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.
198
 
//
199
 
// JUSTIFICATION_RIGHT
200
 
//   Each line, except possibly the first, is flush to the same right tab stop.
 
193
/**
 
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.
 
198
 *
 
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.
 
203
 *
 
204
 * Interpretation for text read in vertical lines:
 
205
 *   "Left" is wherever the starting reading position is.
 
206
 *
 
207
 * JUSTIFICATION_LEFT
 
208
 *   Each line, except possibly the first, is flush to the same left tab stop.
 
209
 *
 
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.
 
213
 *
 
214
 * JUSTIFICATION_RIGHT
 
215
 *   Each line, except possibly the first, is flush to the same right tab stop.
 
216
*/
201
217
enum ParagraphJustification {
202
218
  JUSTIFICATION_UNKNOWN,
203
219
  JUSTIFICATION_LEFT,
205
221
  JUSTIFICATION_RIGHT,
206
222
};
207
223
 
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.
211
 
//
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.
 
224
/**
 
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.
 
228
 *
 
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.
 
233
*/
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