Tesseract
3.02
|
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 00036 // Cube implementation of a ShapeClassifier. 00037 class CubeClassifier : public ShapeClassifier { 00038 public: 00039 explicit CubeClassifier(Tesseract* tesseract); 00040 virtual ~CubeClassifier(); 00041 00042 // Classifies the given [training] sample, writing to results. 00043 // See ShapeClassifier for a full description. 00044 virtual int ClassifySample(const TrainingSample& sample, Pix* page_pix, 00045 int debug, int keep_this, 00046 GenericVector<ShapeRating>* results); 00047 // Provides access to the ShapeTable that this classifier works with. 00048 virtual const ShapeTable* GetShapeTable() const; 00049 00050 private: 00051 // Cube objects. 00052 CubeRecoContext* cube_cntxt_; 00053 const ShapeTable& shape_table_; 00054 }; 00055 00056 // Combination of Tesseract class pruner with scoring by cube. 00057 class CubeTessClassifier : public ShapeClassifier { 00058 public: 00059 explicit CubeTessClassifier(Tesseract* tesseract); 00060 virtual ~CubeTessClassifier(); 00061 00062 // Classifies the given [training] sample, writing to results. 00063 // See ShapeClassifier for a full description. 00064 virtual int ClassifySample(const TrainingSample& sample, Pix* page_pix, 00065 int debug, int keep_this, 00066 GenericVector<ShapeRating>* results); 00067 // Provides access to the ShapeTable that this classifier works with. 00068 virtual const ShapeTable* GetShapeTable() const; 00069 00070 private: 00071 // Cube objects. 00072 CubeRecoContext* cube_cntxt_; 00073 const ShapeTable& shape_table_; 00074 TessClassifier* pruner_; 00075 }; 00076 00077 } // namespace tesseract 00078 00079 #endif /* THIRD_PARTY_TESSERACT_CCMAIN_CUBECLASSIFIER_H_ */