#include <shapetable.h>
|
| | ShapeTable () |
| |
| | ShapeTable (const UNICHARSET &unicharset) |
| |
| bool | Serialize (FILE *fp) const |
| |
| bool | DeSerialize (bool swap, FILE *fp) |
| |
| int | NumShapes () const |
| |
| const UNICHARSET & | unicharset () const |
| |
| void | set_unicharset (const UNICHARSET &unicharset) |
| |
| STRING | DebugStr (int shape_id) const |
| |
| STRING | SummaryStr () const |
| |
| int | AddShape (int unichar_id, int font_id) |
| |
| int | AddShape (const Shape &other) |
| |
| void | DeleteShape (int shape_id) |
| |
| void | AddToShape (int shape_id, int unichar_id, int font_id) |
| |
| void | AddShapeToShape (int shape_id, const Shape &other) |
| |
| int | FindShape (int unichar_id, int font_id) const |
| |
| void | GetFirstUnicharAndFont (int shape_id, int *unichar_id, int *font_id) const |
| |
| const Shape & | GetShape (int shape_id) const |
| |
| Shape * | MutableShape (int shape_id) |
| |
| int | BuildFromShape (const Shape &shape, const ShapeTable &master_shapes) |
| |
| bool | AlreadyMerged (int shape_id1, int shape_id2) const |
| |
| bool | AnyMultipleUnichars () const |
| |
| int | MaxNumUnichars () const |
| |
| void | ForceFontMerges (int start, int end) |
| |
| int | MasterUnicharCount (int shape_id) const |
| |
| int | MasterFontCount (int shape_id) const |
| |
| int | MergedUnicharCount (int shape_id1, int shape_id2) const |
| |
| void | MergeShapes (int shape_id1, int shape_id2) |
| |
| void | AppendMasterShapes (const ShapeTable &other) |
| |
| int | NumMasterShapes () const |
| |
| int | MasterDestinationIndex (int shape_id) const |
| |
Definition at line 126 of file shapetable.h.
| tesseract::ShapeTable::ShapeTable |
( |
| ) |
|
| tesseract::ShapeTable::ShapeTable |
( |
const UNICHARSET & |
unicharset | ) |
|
|
explicit |
| int tesseract::ShapeTable::AddShape |
( |
int |
unichar_id, |
|
|
int |
font_id |
|
) |
| |
Definition at line 249 of file shapetable.cpp.
250 int index = shape_table_.size();
251 Shape* shape =
new Shape;
252 shape->AddToShape(unichar_id, font_id);
253 shape_table_.push_back(shape);
| int tesseract::ShapeTable::AddShape |
( |
const Shape & |
other | ) |
|
Definition at line 259 of file shapetable.cpp.
260 int index = shape_table_.size();
261 Shape* shape =
new Shape(other);
262 shape_table_.push_back(shape);
| void tesseract::ShapeTable::AddShapeToShape |
( |
int |
shape_id, |
|
|
const Shape & |
other |
|
) |
| |
Definition at line 281 of file shapetable.cpp.
282 Shape& shape = *shape_table_[shape_id];
283 shape.AddShape(other);
| void tesseract::ShapeTable::AddToShape |
( |
int |
shape_id, |
|
|
int |
unichar_id, |
|
|
int |
font_id |
|
) |
| |
Definition at line 275 of file shapetable.cpp.
276 Shape& shape = *shape_table_[shape_id];
277 shape.AddToShape(unichar_id, font_id);
| bool tesseract::ShapeTable::AlreadyMerged |
( |
int |
shape_id1, |
|
|
int |
shape_id2 |
|
) |
| const |
Definition at line 342 of file shapetable.cpp.
int MasterDestinationIndex(int shape_id) const
| bool tesseract::ShapeTable::AnyMultipleUnichars |
( |
| ) |
const |
Definition at line 347 of file shapetable.cpp.
349 for (
int s1 = 0; s1 < num_shapes; ++s1) {
const Shape & GetShape(int shape_id) const
int MasterDestinationIndex(int shape_id) const
| void tesseract::ShapeTable::AppendMasterShapes |
( |
const ShapeTable & |
other | ) |
|
Definition at line 439 of file shapetable.cpp.
440 for (
int s = 0; s < other.shape_table_.size(); ++s) {
441 if (other.shape_table_[s]->destination_index() < 0) {
int AddShape(int unichar_id, int font_id)
| int tesseract::ShapeTable::BuildFromShape |
( |
const Shape & |
shape, |
|
|
const ShapeTable & |
master_shapes |
|
) |
| |
Definition at line 317 of file shapetable.cpp.
320 for (
int u_ind = 0; u_ind < shape.size(); ++u_ind) {
321 for (
int f_ind = 0; f_ind < shape[u_ind].font_ids.size(); ++f_ind) {
322 int c = shape[u_ind].unichar_id;
323 int f = shape[u_ind].font_ids[f_ind];
326 int master_id = master_shapes.FindShape(c, f);
327 if (master_id >= 0 && shape.size() > 1) {
328 const Shape& master = master_shapes.GetShape(master_id);
329 if (master.IsSubsetOf(shape) && !shape.IsSubsetOf(master)) {
331 shape_table_[shape_id]->AddShape(master);
int AddShape(int unichar_id, int font_id)
int FindShape(int unichar_id, int font_id) const
| STRING tesseract::ShapeTable::DebugStr |
( |
int |
shape_id | ) |
const |
Definition at line 194 of file shapetable.cpp.
195 if (shape_id < 0 || shape_id >= shape_table_.size())
196 return STRING(
"INVALID_UNICHAR_ID");
197 const Shape& shape =
GetShape(shape_id);
200 if (shape.size() > 100) {
201 result.
add_str_int(
" Num unichars=", shape.size());
204 for (
int c = 0; c < shape.size(); ++c) {
208 if (shape.size() < 10) {
209 result.
add_str_int(
", ", shape[c].font_ids.size());
210 result +=
" fonts =";
211 int num_fonts = shape[c].font_ids.
size();
212 if (num_fonts > 10) {
214 result.
add_str_int(
" ... ", shape[c].font_ids[num_fonts - 1]);
216 for (
int f = 0;
f < num_fonts; ++
f) {
const char *const id_to_unichar(UNICHAR_ID id) const
const Shape & GetShape(int shape_id) const
void add_str_int(const char *str, int number)
| void tesseract::ShapeTable::DeleteShape |
( |
int |
shape_id | ) |
|
Definition at line 267 of file shapetable.cpp.
268 delete shape_table_[shape_id];
269 shape_table_[shape_id] =
NULL;
270 shape_table_.remove(shape_id);
| bool tesseract::ShapeTable::DeSerialize |
( |
bool |
swap, |
|
|
FILE * |
fp |
|
) |
| |
Definition at line 188 of file shapetable.cpp.
189 if (!shape_table_.DeSerialize(swap, fp))
return false;
| int tesseract::ShapeTable::FindShape |
( |
int |
unichar_id, |
|
|
int |
font_id |
|
) |
| const |
Definition at line 290 of file shapetable.cpp.
291 for (
int s = 0; s < shape_table_.size(); ++s) {
293 for (
int c = 0; c < shape.size(); ++c) {
294 if (shape[c].unichar_id == unichar_id) {
297 for (
int f = 0;
f < shape[c].font_ids.size(); ++
f) {
298 if (shape[c].font_ids[
f] == font_id)
const Shape & GetShape(int shape_id) const
| void tesseract::ShapeTable::ForceFontMerges |
( |
int |
start, |
|
|
int |
end |
|
) |
| |
Definition at line 371 of file shapetable.cpp.
372 for (
int s1 = start; s1 < end; ++s1) {
374 int unichar_id =
GetShape(s1)[0].unichar_id;
375 for (
int s2 = s1 + 1; s2 < end; ++s2) {
377 unichar_id ==
GetShape(s2)[0].unichar_id) {
384 compacted.AppendMasterShapes(*
this);
const Shape & GetShape(int shape_id) const
int MasterDestinationIndex(int shape_id) const
void MergeShapes(int shape_id1, int shape_id2)
| void tesseract::ShapeTable::GetFirstUnicharAndFont |
( |
int |
shape_id, |
|
|
int * |
unichar_id, |
|
|
int * |
font_id |
|
) |
| const |
Definition at line 308 of file shapetable.cpp.
310 const UnicharAndFonts& unichar_and_fonts = (*shape_table_[shape_id])[0];
311 *unichar_id = unichar_and_fonts.unichar_id;
312 *font_id = unichar_and_fonts.font_ids[0];
| const Shape& tesseract::ShapeTable::GetShape |
( |
int |
shape_id | ) |
const |
|
inline |
Definition at line 179 of file shapetable.h.
180 return *shape_table_[shape_id];
| int tesseract::ShapeTable::MasterDestinationIndex |
( |
int |
shape_id | ) |
const |
Definition at line 427 of file shapetable.cpp.
428 int dest_id = shape_table_[shape_id]->destination_index();
429 if (dest_id == shape_id || dest_id < 0)
431 int master_id = shape_table_[dest_id]->destination_index();
432 if (master_id == dest_id || master_id < 0)
int MasterDestinationIndex(int shape_id) const
| int tesseract::ShapeTable::MasterFontCount |
( |
int |
shape_id | ) |
const |
Definition at line 395 of file shapetable.cpp.
397 const Shape& shape =
GetShape(master_id);
399 for (
int c = 0; c < shape.size(); ++c) {
400 font_count += shape[c].font_ids.size();
const Shape & GetShape(int shape_id) const
int MasterDestinationIndex(int shape_id) const
| int tesseract::ShapeTable::MasterUnicharCount |
( |
int |
shape_id | ) |
const |
Definition at line 389 of file shapetable.cpp.
const Shape & GetShape(int shape_id) const
int MasterDestinationIndex(int shape_id) const
| int tesseract::ShapeTable::MaxNumUnichars |
( |
| ) |
const |
Definition at line 358 of file shapetable.cpp.
359 int max_num_unichars = 0;
361 for (
int s = 0; s < num_shapes; ++s) {
362 if (
GetShape(s).size() > max_num_unichars)
365 return max_num_unichars;
const Shape & GetShape(int shape_id) const
| int tesseract::ShapeTable::MergedUnicharCount |
( |
int |
shape_id1, |
|
|
int |
shape_id2 |
|
) |
| const |
Definition at line 406 of file shapetable.cpp.
410 Shape combined_shape(*shape_table_[master_id1]);
411 combined_shape.AddShape(*shape_table_[master_id2]);
412 return combined_shape.size();
int MasterDestinationIndex(int shape_id) const
| void tesseract::ShapeTable::MergeShapes |
( |
int |
shape_id1, |
|
|
int |
shape_id2 |
|
) |
| |
Definition at line 416 of file shapetable.cpp.
420 shape_table_[master_id2]->set_destination_index(master_id1);
422 shape_table_[master_id1]->AddShape(*shape_table_[master_id2]);
int MasterDestinationIndex(int shape_id) const
| Shape* tesseract::ShapeTable::MutableShape |
( |
int |
shape_id | ) |
|
|
inline |
Definition at line 182 of file shapetable.h.
183 return shape_table_[shape_id];
| int tesseract::ShapeTable::NumMasterShapes |
( |
| ) |
const |
Definition at line 448 of file shapetable.cpp.
450 for (
int s = 0; s < shape_table_.size(); ++s) {
451 if (shape_table_[s]->destination_index() < 0)
| int tesseract::ShapeTable::NumShapes |
( |
| ) |
const |
|
inline |
Definition at line 140 of file shapetable.h.
141 return shape_table_.size();
| bool tesseract::ShapeTable::Serialize |
( |
FILE * |
fp | ) |
const |
Definition at line 182 of file shapetable.cpp.
183 if (!shape_table_.Serialize(fp))
return false;
| void tesseract::ShapeTable::set_unicharset |
( |
const UNICHARSET & |
unicharset | ) |
|
|
inline |
Definition at line 148 of file shapetable.h.
const UNICHARSET & unicharset() const
| STRING tesseract::ShapeTable::SummaryStr |
( |
| ) |
const |
Definition at line 226 of file shapetable.cpp.
227 int max_unichars = 0;
228 int num_multi_shapes = 0;
229 int num_master_shapes = 0;
230 for (
int s = 0; s < shape_table_.size(); ++s) {
236 if (shape_size > max_unichars)
237 max_unichars = shape_size;
240 result.
add_str_int(
"Number of shapes = ", num_master_shapes);
241 result.
add_str_int(
" max unichars = ", max_unichars);
242 result.
add_str_int(
" number with multiple unichars = ", num_multi_shapes);
const Shape & GetShape(int shape_id) const
int MasterDestinationIndex(int shape_id) const
void add_str_int(const char *str, int number)
| const UNICHARSET& tesseract::ShapeTable::unicharset |
( |
| ) |
const |
|
inline |
The documentation for this class was generated from the following files:
- /home/abuild/rpmbuild/BUILD/tesseract-ocr-3.02.02/classify/shapetable.h
- /home/abuild/rpmbuild/BUILD/tesseract-ocr-3.02.02/classify/shapetable.cpp