Tesseract  3.02
tesseract-ocr/ccstruct/publictypes.h
Go to the documentation of this file.
00001 
00002 // File:        publictypes.h
00003 // Description: Types used in both the API and internally
00004 // Author:      Ray Smith
00005 // Created:     Wed Mar 03 09:22:53 PST 2010
00006 //
00007 // (C) Copyright 2010, Google Inc.
00008 // Licensed under the Apache License, Version 2.0 (the "License");
00009 // you may not use this file except in compliance with the License.
00010 // You may obtain a copy of the License at
00011 // http://www.apache.org/licenses/LICENSE-2.0
00012 // Unless required by applicable law or agreed to in writing, software
00013 // distributed under the License is distributed on an "AS IS" BASIS,
00014 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015 // See the License for the specific language governing permissions and
00016 // limitations under the License.
00017 //
00019 
00020 #ifndef TESSERACT_CCSTRUCT_PUBLICTYPES_H__
00021 #define TESSERACT_CCSTRUCT_PUBLICTYPES_H__
00022 
00023 // This file contains types that are used both by the API and internally
00024 // to Tesseract. In order to decouple the API from Tesseract and prevent cyclic
00025 // dependencies, THIS FILE SHOULD NOT DEPEND ON ANY OTHER PART OF TESSERACT.
00026 // Restated: It is OK for low-level Tesseract files to include publictypes.h,
00027 // but not for the low-level tesseract code to include top-level API code.
00028 // This file should not use other Tesseract types, as that would drag
00029 // their includes into the API-level.
00030 // API-level code should include apitypes.h in preference to this file.
00031 
00033 const int kPointsPerInch = 72;
00034 
00041 enum PolyBlockType {
00042   PT_UNKNOWN,        // Type is not yet known. Keep as the first element.
00043   PT_FLOWING_TEXT,   // Text that lives inside a column.
00044   PT_HEADING_TEXT,   // Text that spans more than one column.
00045   PT_PULLOUT_TEXT,   // Text that is in a cross-column pull-out region.
00046   PT_EQUATION,       // Partition belonging to an equation region.
00047   PT_INLINE_EQUATION,  // Partition has inline equation.
00048   PT_TABLE,          // Partition belonging to a table region.
00049   PT_VERTICAL_TEXT,  // Text-line runs vertically.
00050   PT_CAPTION_TEXT,   // Text that belongs to an image.
00051   PT_FLOWING_IMAGE,  // Image that lives inside a column.
00052   PT_HEADING_IMAGE,  // Image that spans more than one column.
00053   PT_PULLOUT_IMAGE,  // Image that is in a cross-column pull-out region.
00054   PT_HORZ_LINE,      // Horizontal Line.
00055   PT_VERT_LINE,      // Vertical Line.
00056   PT_NOISE,          // Lies outside of any column.
00057   PT_COUNT
00058 };
00059 
00061 inline bool PTIsLineType(PolyBlockType type) {
00062   return type == PT_HORZ_LINE || type == PT_VERT_LINE;
00063 }
00065 inline bool PTIsImageType(PolyBlockType type) {
00066   return type == PT_FLOWING_IMAGE || type == PT_HEADING_IMAGE ||
00067          type == PT_PULLOUT_IMAGE;
00068 }
00070 inline bool PTIsTextType(PolyBlockType type) {
00071   return type == PT_FLOWING_TEXT || type == PT_HEADING_TEXT ||
00072          type == PT_PULLOUT_TEXT || type == PT_TABLE ||
00073          type == PT_VERTICAL_TEXT || type == PT_CAPTION_TEXT ||
00074          type == PT_INLINE_EQUATION;
00075 }
00076 
00078 extern const char* kPolyBlockNames[];
00079 
00080 namespace tesseract {
00104 enum Orientation {
00105   ORIENTATION_PAGE_UP = 0,
00106   ORIENTATION_PAGE_RIGHT = 1,
00107   ORIENTATION_PAGE_DOWN = 2,
00108   ORIENTATION_PAGE_LEFT = 3,
00109 };
00110 
00119 enum WritingDirection {
00120   WRITING_DIRECTION_LEFT_TO_RIGHT = 0,
00121   WRITING_DIRECTION_RIGHT_TO_LEFT = 1,
00122   WRITING_DIRECTION_TOP_TO_BOTTOM = 2,
00123 };
00124 
00136 enum TextlineOrder {
00137   TEXTLINE_ORDER_LEFT_TO_RIGHT = 0,
00138   TEXTLINE_ORDER_RIGHT_TO_LEFT = 1,
00139   TEXTLINE_ORDER_TOP_TO_BOTTOM = 2,
00140 };
00141 
00147 enum PageSegMode {
00148   PSM_OSD_ONLY,       
00149   PSM_AUTO_OSD,       
00150 
00151   PSM_AUTO_ONLY,      
00152   PSM_AUTO,           
00153   PSM_SINGLE_COLUMN,  
00154   PSM_SINGLE_BLOCK_VERT_TEXT,  
00155 
00156   PSM_SINGLE_BLOCK,   
00157   PSM_SINGLE_LINE,    
00158   PSM_SINGLE_WORD,    
00159   PSM_CIRCLE_WORD,    
00160   PSM_SINGLE_CHAR,    
00161 
00162   PSM_COUNT           
00163 };
00164 
00170 #define PSM_OSD_ENABLED(pageseg_mode) ((pageseg_mode) <= PSM_AUTO_OSD)
00171 #define PSM_COL_FIND_ENABLED(pageseg_mode) \
00172   ((pageseg_mode) >= PSM_AUTO_OSD && (pageseg_mode) <= PSM_AUTO)
00173 #define PSM_BLOCK_FIND_ENABLED(pageseg_mode) \
00174   ((pageseg_mode) >= PSM_AUTO_OSD && (pageseg_mode) <= PSM_SINGLE_COLUMN)
00175 #define PSM_LINE_FIND_ENABLED(pageseg_mode) \
00176   ((pageseg_mode) >= PSM_AUTO_OSD && (pageseg_mode) <= PSM_SINGLE_BLOCK)
00177 #define PSM_WORD_FIND_ENABLED(pageseg_mode) \
00178   ((pageseg_mode) >= PSM_AUTO_OSD && (pageseg_mode) <= PSM_SINGLE_LINE)
00179 
00185 enum PageIteratorLevel {
00186   RIL_BLOCK,     // Block of text/image/separator line.
00187   RIL_PARA,      // Paragraph within a block.
00188   RIL_TEXTLINE,  // Line within a paragraph.
00189   RIL_WORD,      // Word within a textline.
00190   RIL_SYMBOL     // Symbol/character within a word.
00191 };
00192 
00217 enum ParagraphJustification {
00218   JUSTIFICATION_UNKNOWN,
00219   JUSTIFICATION_LEFT,
00220   JUSTIFICATION_CENTER,
00221   JUSTIFICATION_RIGHT,
00222 };
00223 
00234 enum OcrEngineMode {
00235   OEM_TESSERACT_ONLY,           // Run Tesseract only - fastest
00236   OEM_CUBE_ONLY,                // Run Cube only - better accuracy, but slower
00237   OEM_TESSERACT_CUBE_COMBINED,  // Run both and combine results - best accuracy
00238   OEM_DEFAULT                   // Specify this mode when calling init_*(),
00239                                 // to indicate that any of the above modes
00240                                 // should be automatically inferred from the
00241                                 // variables in the language-specific config,
00242                                 // command-line configs, or if not specified
00243                                 // in any of the above should be set to the
00244                                 // default OEM_TESSERACT_ONLY.
00245 };
00246 
00247 }  // namespace tesseract.
00248 
00249 #endif  // TESSERACT_CCSTRUCT_PUBLICTYPES_H__