Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
tesseract::BlobMatchTable Class Reference

`#include <matchtab.h>`

List of all members.

## Public Member Functions
| BlobMatchTable ()
| ~BlobMatchTable ()
void | init_match_table ()
void | end_match_table ()
void | put_match (TBLOB *blob, BLOB_CHOICE_LIST *ratings)
BLOB_CHOICE_LIST * | get_match (TBLOB *blob)
BLOB_CHOICE_LIST * | get_match_by_box (const TBOX &box)
void | add_to_match (TBLOB *blob, BLOB_CHOICE_LIST *ratings)

## Detailed Description

Definition at line 42 of file matchtab.h.

## Constructor & Destructor Documentation

tesseract::BlobMatchTable::BlobMatchTable | ( |  | ) |

Definition at line 38 of file matchtab.cpp.

: been_initialized_(false), match_table_(NULL) {
init_match_table();
}

tesseract::BlobMatchTable::~BlobMatchTable | ( |  | ) |

Definition at line 43 of file matchtab.cpp.

{
end_match_table();
}

## Member Function Documentation

void tesseract::BlobMatchTable::add_to_match | ( | TBLOB * | blob,
|  | BLOB_CHOICE_LIST * | ratings
| ) |  |

Definition at line 183 of file matchtab.cpp.

{
TBOX bbox = blob->bounding_box();
int start = Hash(bbox);
int x = start;
do {
if (IsEmpty(x)) {
fprintf(stderr, "Can not update uninitialized entry in match_table\n");
ASSERT_HOST(!IsEmpty(x));
}
if (match_table_[x].box == bbox) {
// Copy new ratings to match_table_[x].rating.
BLOB_CHOICE_IT it;
it.set_to_list(match_table_[x].rating);
BLOB_CHOICE_IT new_it;
new_it.set_to_list(ratings);
assert(it.length() <= new_it.length());
for (it.mark_cycle_pt(), new_it.mark_cycle_pt();
!it.cycled_list() && !new_it.cycled_list(); new_it.forward()) {
if (it.data()->unichar_id() == new_it.data()->unichar_id()) {
it.forward();
} else {
it.add_before_stay_put(new BLOB_CHOICE(*(new_it.data())));
}
}
return;
}
if (++x >= NUM_MATCH_ENTRIES)
x = 0;
} while (x != start);
}

void tesseract::BlobMatchTable::end_match_table | ( |  | ) |

Definition at line 71 of file matchtab.cpp.

{
if (been_initialized_) {
init_match_table();
delete[] match_table_;
match_table_ = NULL;
been_initialized_ = false;
}
}

BLOB_CHOICE_LIST * tesseract::BlobMatchTable::get_match | ( | TBLOB * | blob | ) |

Definition at line 118 of file matchtab.cpp.

{
return get_match_by_box(blob->bounding_box());
}

BLOB_CHOICE_LIST * tesseract::BlobMatchTable::get_match_by_box | ( | const TBOX & | box | ) |

Definition at line 150 of file matchtab.cpp.

{
int start = Hash(box);
int x = start;
/* Search for match */
do {
/* Not found when blank */
if (IsEmpty(x))
break;
/* Is this the match ? */
if (match_table_[x].box == box) {
BLOB_CHOICE_LIST *blist = new BLOB_CHOICE_LIST();
blist->deep_copy(match_table_[x].rating, &BLOB_CHOICE::deep_copy);
return blist;
}
if (++x >= NUM_MATCH_ENTRIES)
x = 0;
} while (x != start);
return NULL;
}

void tesseract::BlobMatchTable::init_match_table | ( |  | ) |

Definition at line 52 of file matchtab.cpp.

{
if (been_initialized_) {
/* Reclaim old choices */
for (int x = 0; x < NUM_MATCH_ENTRIES; x++) {
if (!IsEmpty(x)) {
match_table_[x].rating->clear();
delete match_table_[x].rating;
// Reinitialize the entry.
match_table_[x].box = TBOX();
match_table_[x].rating = NULL;
}
}
} else {
/* Allocate memory once */
match_table_ = new MATCH[NUM_MATCH_ENTRIES];
been_initialized_ = true;
}
}

void tesseract::BlobMatchTable::put_match | ( | TBLOB * | blob,
|  | BLOB_CHOICE_LIST * | ratings
| ) |  |

Definition at line 87 of file matchtab.cpp.

{
if (!blob) return;
/* Hash into table */
TBOX bbox(blob->bounding_box());
int start = Hash(bbox);
/* Look for empty */
int x = start;
do {
if (IsEmpty(x)) {
/* Add this entry */
match_table_[x].box = bbox;
// Copy ratings to match_table_[x].rating
match_table_[x].rating = new BLOB_CHOICE_LIST();
match_table_[x].rating->deep_copy(ratings, &BLOB_CHOICE::deep_copy);
return;
}
if (++x >= NUM_MATCH_ENTRIES)
x = 0;
} while (x != start);
cprintf ("error: Match table is full\n");
}

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

- /mnt/data/src/tesseract-ocr/wordrec/matchtab.h
- /mnt/data/src/tesseract-ocr/wordrec/matchtab.cpp