tesseract  5.0.0-alpha-619-ge9db
tesseract::TessClassifier Class Reference

#include <tessclassifier.h>

Inheritance diagram for tesseract::TessClassifier:
tesseract::ShapeClassifier

Public Member Functions

 TessClassifier (bool pruner_only, tesseract::Classify *classify)
 
 ~TessClassifier () override=default
 
int UnicharClassifySample (const TrainingSample &sample, Pix *page_pix, int debug, UNICHAR_ID keep_this, GenericVector< UnicharRating > *results) override
 
const ShapeTableGetShapeTable () const override
 
const UNICHARSETGetUnicharset () const override
 
int DisplayClassifyAs (const TrainingSample &sample, Pix *page_pix, int unichar_id, int index, PointerVector< ScrollView > *windows) override
 
- Public Member Functions inherited from tesseract::ShapeClassifier
virtual ~ShapeClassifier ()=default
 
virtual int BestShapeForUnichar (const TrainingSample &sample, Pix *page_pix, UNICHAR_ID unichar_id, ShapeRating *result)
 
virtual void DebugDisplay (const TrainingSample &sample, Pix *page_pix, UNICHAR_ID unichar_id)
 
virtual void UnicharPrintResults (const char *context, const GenericVector< UnicharRating > &results) const
 
virtual void PrintResults (const char *context, const GenericVector< ShapeRating > &results) const
 

Additional Inherited Members

- Protected Member Functions inherited from tesseract::ShapeClassifier
virtual int ClassifySample (const TrainingSample &sample, Pix *page_pix, int debug, UNICHAR_ID keep_this, GenericVector< ShapeRating > *results)
 
void FilterDuplicateUnichars (GenericVector< ShapeRating > *results) const
 

Detailed Description

Definition at line 36 of file tessclassifier.h.

Constructor & Destructor Documentation

◆ TessClassifier()

tesseract::TessClassifier::TessClassifier ( bool  pruner_only,
tesseract::Classify classify 
)
inline

Definition at line 38 of file tessclassifier.h.

39  : pruner_only_(pruner_only), classify_(classify) {}

◆ ~TessClassifier()

tesseract::TessClassifier::~TessClassifier ( )
overridedefault

Member Function Documentation

◆ DisplayClassifyAs()

int tesseract::TessClassifier::DisplayClassifyAs ( const TrainingSample sample,
Pix *  page_pix,
int  unichar_id,
int  index,
PointerVector< ScrollView > *  windows 
)
overridevirtual

Reimplemented from tesseract::ShapeClassifier.

Definition at line 68 of file tessclassifier.cpp.

70  {
71  int shape_id = unichar_id;
72  // TODO(rays) Fix this so it works with both flat and real shapetables.
73  // if (GetShapeTable() != nullptr)
74  // shape_id = BestShapeForUnichar(sample, page_pix, unichar_id, nullptr);
75  if (shape_id < 0) return index;
76  if (UnusedClassIdIn(classify_->PreTrainedTemplates, shape_id)) {
77  tprintf("No built-in templates for class/shape %d\n", shape_id);
78  return index;
79  }
80  classify_->ShowBestMatchFor(shape_id, sample.features(),
81  sample.num_features());
82  return index;
83 }

◆ GetShapeTable()

const ShapeTable * tesseract::TessClassifier::GetShapeTable ( ) const
overridevirtual

Implements tesseract::ShapeClassifier.

Definition at line 54 of file tessclassifier.cpp.

54  {
55  return classify_->shape_table();
56 }

◆ GetUnicharset()

const UNICHARSET & tesseract::TessClassifier::GetUnicharset ( ) const
overridevirtual

Reimplemented from tesseract::ShapeClassifier.

Definition at line 59 of file tessclassifier.cpp.

59  {
60  return classify_->unicharset;
61 }

◆ UnicharClassifySample()

int tesseract::TessClassifier::UnicharClassifySample ( const TrainingSample sample,
Pix *  page_pix,
int  debug,
UNICHAR_ID  keep_this,
GenericVector< UnicharRating > *  results 
)
overridevirtual

Reimplemented from tesseract::ShapeClassifier.

Definition at line 31 of file tessclassifier.cpp.

33  {
34  const int old_matcher_level = classify_->matcher_debug_level;
35  const int old_matcher_flags = classify_->matcher_debug_flags;
36  const int old_classify_level = classify_->classify_debug_level;
37  if (debug) {
38  // Explicitly set values of various control parameters to generate debug
39  // output if required, restoring the old values after classifying.
40  classify_->matcher_debug_level.set_value(2);
41  classify_->matcher_debug_flags.set_value(25);
42  classify_->classify_debug_level.set_value(3);
43  }
44  classify_->CharNormTrainingSample(pruner_only_, keep_this, sample, results);
45  if (debug) {
46  classify_->matcher_debug_level.set_value(old_matcher_level);
47  classify_->matcher_debug_flags.set_value(old_matcher_flags);
48  classify_->classify_debug_level.set_value(old_classify_level);
49  }
50  return results->size();
51 }

The documentation for this class was generated from the following files:
tesseract::Classify::matcher_debug_level
int matcher_debug_level
Definition: classify.h:453
tesseract::Classify::shape_table
const ShapeTable * shape_table() const
Definition: classify.h:111
tesseract::CCUtil::unicharset
UNICHARSET unicharset
Definition: ccutil.h:57
sample
Definition: cluster.h:31
tesseract::Classify::CharNormTrainingSample
int CharNormTrainingSample(bool pruner_only, int keep_this, const TrainingSample &sample, GenericVector< UnicharRating > *results)
Definition: adaptmatch.cpp:1329
tprintf
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:34
tesseract::Classify::PreTrainedTemplates
INT_TEMPLATES PreTrainedTemplates
Definition: classify.h:514
tesseract::Classify::matcher_debug_flags
int matcher_debug_flags
Definition: classify.h:454
tesseract::Classify::ShowBestMatchFor
void ShowBestMatchFor(int shape_id, const INT_FEATURE_STRUCT *features, int num_features)
Definition: adaptmatch.cpp:2159
UnusedClassIdIn
#define UnusedClassIdIn(T, c)
Definition: intproto.h:176
GenericVector::size
int size() const
Definition: genericvector.h:71
tesseract::Classify::classify_debug_level
int classify_debug_level
Definition: classify.h:430