tesseract  4.0.0-1-g2a2b
tesseract::TessClassifier Class Reference

#include <tessclassifier.h>

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

Public Member Functions

 TessClassifier (bool pruner_only, tesseract::Classify *classify)
 
virtual ~TessClassifier ()=default
 
virtual int UnicharClassifySample (const TrainingSample &sample, Pix *page_pix, int debug, UNICHAR_ID keep_this, GenericVector< UnicharRating > *results)
 
virtual const ShapeTableGetShapeTable () const
 
virtual const UNICHARSETGetUnicharset () const
 
virtual int DisplayClassifyAs (const TrainingSample &sample, Pix *page_pix, int unichar_id, int index, PointerVector< ScrollView > *windows)
 
- 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()

virtual tesseract::TessClassifier::~TessClassifier ( )
virtualdefault

Member Function Documentation

◆ DisplayClassifyAs()

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

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 }
Definition: cluster.h:32
#define UnusedClassIdIn(T, c)
Definition: intproto.h:175
void ShowBestMatchFor(int shape_id, const INT_FEATURE_STRUCT *features, int num_features)
INT_TEMPLATES PreTrainedTemplates
Definition: classify.h:510
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:37

◆ GetShapeTable()

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

Implements tesseract::ShapeClassifier.

Definition at line 54 of file tessclassifier.cpp.

54  {
55  return classify_->shape_table();
56 }
const ShapeTable * shape_table() const
Definition: classify.h:111

◆ GetUnicharset()

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

Reimplemented from tesseract::ShapeClassifier.

Definition at line 59 of file tessclassifier.cpp.

59  {
60  return classify_->unicharset;
61 }
UNICHARSET unicharset
Definition: ccutil.h:68

◆ UnicharClassifySample()

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

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 }
int size() const
Definition: genericvector.h:71
Definition: cluster.h:32
int CharNormTrainingSample(bool pruner_only, int keep_this, const TrainingSample &sample, GenericVector< UnicharRating > *results)

The documentation for this class was generated from the following files: