tesseract
3.03
|
00001 // Copyright 2011 Google Inc. All Rights Reserved. 00002 // Author: rays@google.com (Ray Smith) 00004 // File: tessclassifier.h 00005 // Description: Tesseract implementation of a ShapeClassifier. 00006 // Author: Ray Smith 00007 // Created: Tue Nov 22 14:10:45 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_CLASSIFY_TESSCLASSIFIER_H_ 00023 #define THIRD_PARTY_TESSERACT_CLASSIFY_TESSCLASSIFIER_H_ 00024 00025 #include "shapeclassifier.h" 00026 00027 namespace tesseract { 00028 00029 class Classify; 00030 class TrainingSample; 00031 00032 // Tesseract implementation of a ShapeClassifier. 00033 // Due to limitations in the content of TrainingSample, this currently 00034 // only works for the static classifier and only works if the ShapeTable 00035 // in classify is not NULL. 00036 class TessClassifier : public ShapeClassifier { 00037 public: 00038 TessClassifier(bool pruner_only, tesseract::Classify* classify) 00039 : pruner_only_(pruner_only), classify_(classify) {} 00040 virtual ~TessClassifier() {} 00041 00042 // Classifies the given [training] sample, writing to results. 00043 // See ShapeClassifier for a full description. 00044 virtual int UnicharClassifySample(const TrainingSample& sample, Pix* page_pix, 00045 int debug, UNICHAR_ID keep_this, 00046 GenericVector<UnicharRating>* results); 00047 // Provides access to the ShapeTable that this classifier works with. 00048 virtual const ShapeTable* GetShapeTable() const; 00049 // Provides access to the UNICHARSET that this classifier works with. 00050 // Only needs to be overridden if GetShapeTable() can return NULL. 00051 virtual const UNICHARSET& GetUnicharset() const; 00052 00053 // Displays classification as the given shape_id. Creates as many windows 00054 // as it feels fit, using index as a guide for placement. Adds any created 00055 // windows to the windows output and returns a new index that may be used 00056 // by any subsequent classifiers. Caller waits for the user to view and 00057 // then destroys the windows by clearing the vector. 00058 virtual int DisplayClassifyAs(const TrainingSample& sample, Pix* page_pix, 00059 int unichar_id, int index, 00060 PointerVector<ScrollView>* windows); 00061 00062 private: 00063 // Indicates that this classifier is to use just the ClassPruner, or the 00064 // full classifier if false. 00065 bool pruner_only_; 00066 // Borrowed pointer to the actual Tesseract classifier. 00067 tesseract::Classify* classify_; 00068 }; 00069 00070 00071 } // namespace tesseract 00072 00073 00074 00075 00076 00077 #endif /* THIRD_PARTY_TESSERACT_CLASSIFY_TESSCLASSIFIER_H_ */