Tesseract  3.02
tesseract::CubeTessClassifier Class Reference

#include <cubeclassifier.h>

Inheritance diagram for tesseract::CubeTessClassifier:
tesseract::ShapeClassifier

List of all members.

Public Member Functions

 CubeTessClassifier (Tesseract *tesseract)
virtual ~CubeTessClassifier ()
virtual int ClassifySample (const TrainingSample &sample, Pix *page_pix, int debug, int keep_this, GenericVector< ShapeRating > *results)
virtual const ShapeTableGetShapeTable () const

Detailed Description

Definition at line 57 of file cubeclassifier.h.


Constructor & Destructor Documentation

tesseract::CubeTessClassifier::CubeTessClassifier ( tesseract::Tesseract tesseract) [explicit]

Definition at line 79 of file cubeclassifier.cpp.

    : cube_cntxt_(tesseract->GetCubeRecoContext()),
      shape_table_(*tesseract->shape_table()),
      pruner_(new TessClassifier(true, tesseract)) {
}
tesseract::CubeTessClassifier::~CubeTessClassifier ( ) [virtual]

Definition at line 84 of file cubeclassifier.cpp.

                                        {
  delete pruner_;
}

Member Function Documentation

int tesseract::CubeTessClassifier::ClassifySample ( const TrainingSample sample,
Pix *  page_pix,
int  debug,
int  keep_this,
GenericVector< ShapeRating > *  results 
) [virtual]

Implements tesseract::ShapeClassifier.

Definition at line 90 of file cubeclassifier.cpp.

                                                                            {
  int num_results = pruner_->ClassifySample(sample, page_pix, debug, keep_this,
                                            results);
  if (page_pix == NULL) return num_results;

  ASSERT_HOST(cube_cntxt_ != NULL);
  const TBOX& char_box = sample.bounding_box();
  CubeObject* cube_obj = new tesseract::CubeObject(
      cube_cntxt_, page_pix, char_box.left(),
      pixGetHeight(page_pix) - char_box.top(),
      char_box.width(), char_box.height());
  CharAltList* alt_list = cube_obj->RecognizeChar();
  CharSet* char_set = cube_cntxt_->CharacterSet();
  if (alt_list != NULL) {
    for (int r = 0; r < num_results; ++r) {
      const Shape& shape = shape_table_.GetShape((*results)[r].shape_id);
      // Get the best cube probability of all unichars in the shape.
      double best_prob = 0.0;
      for (int i = 0; i < alt_list->AltCount(); ++i) {
        int alt_id = alt_list->Alt(i);
        int unichar_id = char_set->UnicharID(char_set->ClassString(alt_id));
        if (shape.ContainsUnichar(unichar_id) &&
            alt_list->AltProb(i) > best_prob) {
          best_prob = alt_list->AltProb(i);
        }
      }
      (*results)[r].rating = best_prob;
    }
    delete alt_list;
    // Re-sort by rating.
    results->sort(&ShapeRating::SortDescendingRating);
  }
  delete cube_obj;
  return results->size();
}
const ShapeTable * tesseract::CubeTessClassifier::GetShapeTable ( ) const [virtual]

Implements tesseract::ShapeClassifier.

Definition at line 129 of file cubeclassifier.cpp.

                                                          {
  return &shape_table_;
}

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