MCPcopy Create free account
hub / github.com/creatale/node-dv / UnicharClassifySample

Method UnicharClassifySample

deps/tesseract/ccmain/cubeclassifier.cpp:44–71  ·  view source on GitHub ↗

Classifies the given [training] sample, writing to results. See ShapeClassifier for a full description.

Source from the content-addressed store, hash-verified

42/// Classifies the given [training] sample, writing to results.
43/// See ShapeClassifier for a full description.
44int CubeClassifier::UnicharClassifySample(
45 const TrainingSample& sample, Pix* page_pix, int debug,
46 UNICHAR_ID keep_this, GenericVector<UnicharRating>* results) {
47 results->clear();
48 if (page_pix == NULL) return 0;
49
50 ASSERT_HOST(cube_cntxt_ != NULL);
51 const TBOX& char_box = sample.bounding_box();
52 CubeObject* cube_obj = new tesseract::CubeObject(
53 cube_cntxt_, page_pix, char_box.left(),
54 pixGetHeight(page_pix) - char_box.top(),
55 char_box.width(), char_box.height());
56 CharAltList* alt_list = cube_obj->RecognizeChar();
57 if (alt_list != NULL) {
58 alt_list->Sort();
59 CharSet* char_set = cube_cntxt_->CharacterSet();
60 for (int i = 0; i < alt_list->AltCount(); ++i) {
61 // Convert cube representation to a shape_id.
62 int alt_id = alt_list->Alt(i);
63 int unichar_id = char_set->UnicharID(char_set->ClassString(alt_id));
64 if (unichar_id >= 0)
65 results->push_back(UnicharRating(unichar_id, alt_list->AltProb(i)));
66 }
67 delete alt_list;
68 }
69 delete cube_obj;
70 return results->size();
71}
72
73/** Provides access to the ShapeTable that this classifier works with. */
74const ShapeTable* CubeClassifier::GetShapeTable() const {

Callers

nothing calls this directly

Calls 15

pixGetHeightFunction · 0.85
heightMethod · 0.80
RecognizeCharMethod · 0.80
CharacterSetMethod · 0.80
AltCountMethod · 0.80
UnicharIDMethod · 0.80
ClassStringMethod · 0.80
AltProbMethod · 0.80
UnicharRatingClass · 0.70
clearMethod · 0.45
bounding_boxMethod · 0.45
SortMethod · 0.45

Tested by

no test coverage detected