Tesseract
3.02
|
#include <cubeclassifier.h>
Public Member Functions | |
CubeClassifier (Tesseract *tesseract) | |
virtual | ~CubeClassifier () |
virtual int | ClassifySample (const TrainingSample &sample, Pix *page_pix, int debug, int keep_this, GenericVector< ShapeRating > *results) |
virtual const ShapeTable * | GetShapeTable () const |
Definition at line 37 of file cubeclassifier.h.
tesseract::CubeClassifier::CubeClassifier | ( | tesseract::Tesseract * | tesseract | ) | [explicit] |
Definition at line 35 of file cubeclassifier.cpp.
: cube_cntxt_(tesseract->GetCubeRecoContext()), shape_table_(*tesseract->shape_table()) { }
tesseract::CubeClassifier::~CubeClassifier | ( | ) | [virtual] |
Definition at line 39 of file cubeclassifier.cpp.
{ }
int tesseract::CubeClassifier::ClassifySample | ( | const TrainingSample & | sample, |
Pix * | page_pix, | ||
int | debug, | ||
int | keep_this, | ||
GenericVector< ShapeRating > * | results | ||
) | [virtual] |
Implements tesseract::ShapeClassifier.
Definition at line 44 of file cubeclassifier.cpp.
{ results->clear(); if (page_pix == NULL) return 0; 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(); alt_list->Sort(); CharSet* char_set = cube_cntxt_->CharacterSet(); if (alt_list != NULL) { for (int i = 0; i < alt_list->AltCount(); ++i) { // Convert cube representation to a shape_id. int alt_id = alt_list->Alt(i); int unichar_id = char_set->UnicharID(char_set->ClassString(alt_id)); int shape_id = shape_table_.FindShape(unichar_id, -1); if (shape_id >= 0) results->push_back(ShapeRating(shape_id, alt_list->AltProb(i))); } delete alt_list; } delete cube_obj; return results->size(); }
const ShapeTable * tesseract::CubeClassifier::GetShapeTable | ( | ) | const [virtual] |
Implements tesseract::ShapeClassifier.
Definition at line 75 of file cubeclassifier.cpp.
{
return &shape_table_;
}