tesseract 4.1.1
Loading...
Searching...
No Matches
tessclassifier.h
Go to the documentation of this file.
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
27namespace tesseract {
28
29class Classify;
30class 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 ~TessClassifier() override = default;
41
42 // Classifies the given [training] sample, writing to results.
43 // See ShapeClassifier for a full description.
44 int UnicharClassifySample(const TrainingSample& sample, Pix* page_pix,
45 int debug, UNICHAR_ID keep_this,
46 GenericVector<UnicharRating>* results) override;
47 // Provides access to the ShapeTable that this classifier works with.
48 const ShapeTable* GetShapeTable() const override;
49 // Provides access to the UNICHARSET that this classifier works with.
50 // Only needs to be overridden if GetShapeTable() can return nullptr.
51 const UNICHARSET& GetUnicharset() const override;
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 int DisplayClassifyAs(const TrainingSample& sample, Pix* page_pix,
59 int unichar_id, int index,
60 PointerVector<ScrollView>* windows) override;
61
62 private:
63 // Indicates that this classifier is to use just the ClassPruner, or the
64 // full classifier if false.
65 bool pruner_only_;
66 // Borrowed pointer to the actual Tesseract classifier.
67 tesseract::Classify* classify_;
68};
69
70
71} // namespace tesseract
72
73
74
75
76
77#endif /* THIRD_PARTY_TESSERACT_CLASSIFY_TESSCLASSIFIER_H_ */
int UNICHAR_ID
Definition: unichar.h:34
Definition: cluster.h:32
TessClassifier(bool pruner_only, tesseract::Classify *classify)
const ShapeTable * GetShapeTable() const override
int UnicharClassifySample(const TrainingSample &sample, Pix *page_pix, int debug, UNICHAR_ID keep_this, GenericVector< UnicharRating > *results) override
int DisplayClassifyAs(const TrainingSample &sample, Pix *page_pix, int unichar_id, int index, PointerVector< ScrollView > *windows) override
~TessClassifier() override=default
const UNICHARSET & GetUnicharset() const override