tesseract  v4.0.0-17-g361f3264
Open Source OCR Engine
tessclassifier.h
1 // Copyright 2011 Google Inc. All Rights Reserved.
2 // Author: rays@google.com (Ray Smith)
4 // File: tessclassifier.h
5 // Description: Tesseract implementation of a ShapeClassifier.
6 // Author: Ray Smith
7 // Created: Tue Nov 22 14:10:45 PST 2011
8 //
9 // (C) Copyright 2011, Google Inc.
10 // Licensed under the Apache License, Version 2.0 (the "License");
11 // you may not use this file except in compliance with the License.
12 // You may obtain a copy of the License at
13 // http://www.apache.org/licenses/LICENSE-2.0
14 // Unless required by applicable law or agreed to in writing, software
15 // distributed under the License is distributed on an "AS IS" BASIS,
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 // See the License for the specific language governing permissions and
18 // limitations under the License.
19 //
21 
22 #ifndef THIRD_PARTY_TESSERACT_CLASSIFY_TESSCLASSIFIER_H_
23 #define THIRD_PARTY_TESSERACT_CLASSIFY_TESSCLASSIFIER_H_
24 
25 #include "shapeclassifier.h"
26 
27 namespace tesseract {
28 
29 class Classify;
30 class TrainingSample;
31 
32 // Tesseract implementation of a ShapeClassifier.
33 // Due to limitations in the content of TrainingSample, this currently
34 // only works for the static classifier and only works if the ShapeTable
35 // in classify is not nullptr.
37  public:
38  TessClassifier(bool pruner_only, tesseract::Classify* classify)
39  : pruner_only_(pruner_only), classify_(classify) {}
40  virtual ~TessClassifier() = default;
41 
42  // Classifies the given [training] sample, writing to results.
43  // See ShapeClassifier for a full description.
44  virtual int UnicharClassifySample(const TrainingSample& sample, Pix* page_pix,
45  int debug, UNICHAR_ID keep_this,
47  // Provides access to the ShapeTable that this classifier works with.
48  virtual const ShapeTable* GetShapeTable() const;
49  // Provides access to the UNICHARSET that this classifier works with.
50  // Only needs to be overridden if GetShapeTable() can return nullptr.
51  virtual const UNICHARSET& GetUnicharset() const;
52 
53  // Displays classification as the given shape_id. Creates as many windows
54  // as it feels fit, using index as a guide for placement. Adds any created
55  // windows to the windows output and returns a new index that may be used
56  // by any subsequent classifiers. Caller waits for the user to view and
57  // then destroys the windows by clearing the vector.
58  virtual int DisplayClassifyAs(const TrainingSample& sample, Pix* page_pix,
59  int unichar_id, int index,
60  PointerVector<ScrollView>* windows);
61 
62  private:
63  // Indicates that this classifier is to use just the ClassPruner, or the
64  // full classifier if false.
66  // Borrowed pointer to the actual Tesseract classifier.
68 };
69 
70 
71 } // namespace tesseract
72 
73 
74 
75 
76 
77 #endif /* THIRD_PARTY_TESSERACT_CLASSIFY_TESSCLASSIFIER_H_ */
virtual const ShapeTable * GetShapeTable() const
Definition: tessclassifier.cpp:54
Definition: cluster.h:32
Definition: classify.h:103
tesseract::Classify * classify_
Definition: tessclassifier.h:67
Definition: unicharset.h:146
virtual int DisplayClassifyAs(const TrainingSample &sample, Pix *page_pix, int unichar_id, int index, PointerVector< ScrollView > *windows)
Definition: tessclassifier.cpp:68
Definition: baseapi.cpp:94
virtual ~TessClassifier()=default
virtual int UnicharClassifySample(const TrainingSample &sample, Pix *page_pix, int debug, UNICHAR_ID keep_this, GenericVector< UnicharRating > *results)
Definition: tessclassifier.cpp:31
Definition: shapetable.h:262
virtual const UNICHARSET & GetUnicharset() const
Definition: tessclassifier.cpp:59
Definition: shapeclassifier.h:43
Definition: genericvector.h:457
Definition: tessclassifier.h:36
TessClassifier(bool pruner_only, tesseract::Classify *classify)
Definition: tessclassifier.h:38
Definition: trainingsample.h:53
bool pruner_only_
Definition: tessclassifier.h:65