tesseract
3.03
|
00001 // Copyright 2011 Google Inc. All Rights Reserved. 00002 // Author: rays@google.com (Ray Smith) 00004 // File: cubeclassifier.h 00005 // Description: Cube implementation of a ShapeClassifier. 00006 // Author: Ray Smith 00007 // Created: Wed Nov 23 10:36:32 PST 2011 00008 // 00009 // (C) Copyright 2011, Google Inc. 00010 // Licensed under the Apache License, Version 2.0 (the "License"); 00011 // you may not use this file except in compliance with the License. 00012 // You may obtain a copy of the License at 00013 // http://www.apache.org/licenses/LICENSE-2.0 00014 // Unless required by applicable law or agreed to in writing, software 00015 // distributed under the License is distributed on an "AS IS" BASIS, 00016 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00017 // See the License for the specific language governing permissions and 00018 // limitations under the License. 00019 // 00021 00022 #ifndef THIRD_PARTY_TESSERACT_CCMAIN_CUBECLASSIFIER_H_ 00023 #define THIRD_PARTY_TESSERACT_CCMAIN_CUBECLASSIFIER_H_ 00024 00025 #include "shapeclassifier.h" 00026 00027 namespace tesseract { 00028 00029 class Classify; 00030 class CubeRecoContext; 00031 class ShapeTable; 00032 class TessClassifier; 00033 class Tesseract; 00034 class TrainingSample; 00035 struct UnicharRating; 00036 00037 // Cube implementation of a ShapeClassifier. 00038 class CubeClassifier : public ShapeClassifier { 00039 public: 00040 explicit CubeClassifier(Tesseract* tesseract); 00041 virtual ~CubeClassifier(); 00042 00043 // Classifies the given [training] sample, writing to results. 00044 // See ShapeClassifier for a full description. 00045 virtual int UnicharClassifySample(const TrainingSample& sample, Pix* page_pix, 00046 int debug, UNICHAR_ID keep_this, 00047 GenericVector<UnicharRating>* results); 00048 // Provides access to the ShapeTable that this classifier works with. 00049 virtual const ShapeTable* GetShapeTable() const; 00050 00051 private: 00052 // Cube objects. 00053 CubeRecoContext* cube_cntxt_; 00054 const ShapeTable& shape_table_; 00055 }; 00056 00057 // Combination of Tesseract class pruner with scoring by cube. 00058 class CubeTessClassifier : public ShapeClassifier { 00059 public: 00060 explicit CubeTessClassifier(Tesseract* tesseract); 00061 virtual ~CubeTessClassifier(); 00062 00063 // Classifies the given [training] sample, writing to results. 00064 // See ShapeClassifier for a full description. 00065 virtual int UnicharClassifySample(const TrainingSample& sample, Pix* page_pix, 00066 int debug, UNICHAR_ID keep_this, 00067 GenericVector<UnicharRating>* results); 00068 // Provides access to the ShapeTable that this classifier works with. 00069 virtual const ShapeTable* GetShapeTable() const; 00070 00071 private: 00072 // Cube objects. 00073 CubeRecoContext* cube_cntxt_; 00074 const ShapeTable& shape_table_; 00075 TessClassifier* pruner_; 00076 }; 00077 00078 } // namespace tesseract 00079 00080 #endif /* THIRD_PARTY_TESSERACT_CCMAIN_CUBECLASSIFIER_H_ */