Tesseract
3.02
|
00001 /********************************************************************** 00002 * File: cube_line_object.h 00003 * Description: Declaration of the Cube Line Object Class 00004 * Author: Ahmad Abdulkader 00005 * Created: 2007 00006 * 00007 * (C) Copyright 2008, 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 * 00018 **********************************************************************/ 00019 00020 // The CubeLineObject implements an objects that holds a line of text 00021 // Each line is broken into phrases. Phrases are blocks within the line that 00022 // are unambiguously separate collections of words 00023 00024 #ifndef CUBE_LINE_OBJECT_H 00025 #define CUBE_LINE_OBJECT_H 00026 00027 #include "cube_reco_context.h" 00028 #include "cube_object.h" 00029 #include "allheaders.h" 00030 00031 namespace tesseract { 00032 class CubeLineObject { 00033 public: 00034 CubeLineObject(CubeRecoContext *cntxt, Pix *pix); 00035 ~CubeLineObject(); 00036 00037 // accessors 00038 inline int PhraseCount() { 00039 if (!processed_ && !Process()) { 00040 return 0; 00041 } 00042 return phrase_cnt_; 00043 } 00044 inline CubeObject **Phrases() { 00045 if (!processed_ && !Process()) { 00046 return NULL; 00047 } 00048 return phrases_; 00049 } 00050 00051 private: 00052 CubeRecoContext *cntxt_; 00053 bool own_pix_; 00054 bool processed_; 00055 Pix *line_pix_; 00056 CubeObject **phrases_; 00057 int phrase_cnt_; 00058 bool Process(); 00059 // Compute the least word breaking threshold that is required to produce a 00060 // valid set of phrases. Phrases are validated using the Aspect ratio 00061 // constraints specified in the language specific Params object 00062 int ComputeWordBreakThreshold(int con_comp_cnt, ConComp **con_comps, 00063 bool rtl); 00064 }; 00065 } 00066 00067 #endif // CUBE_LINE_OBJECT_H