tesseract v5.3.3.20231005
tesseract::ShapeTable Class Reference

#include <shapetable.h>

Public Member Functions

 ShapeTable ()
 
 ShapeTable (const UNICHARSET &unicharset)
 
 ~ShapeTable ()
 
bool Serialize (FILE *fp) const
 
bool DeSerialize (TFile *fp)
 
unsigned NumShapes () const
 
const UNICHARSETunicharset () const
 
int NumFonts () const
 
void set_unicharset (const UNICHARSET &unicharset)
 
void ReMapClassIds (const std::vector< int > &unicharset_map)
 
std::string DebugStr (unsigned shape_id) const
 
std::string SummaryStr () const
 
unsigned AddShape (int unichar_id, int font_id)
 
unsigned AddShape (const Shape &other)
 
void DeleteShape (unsigned shape_id)
 
void AddToShape (unsigned shape_id, int unichar_id, int font_id)
 
void AddShapeToShape (unsigned shape_id, const Shape &other)
 
int FindShape (int unichar_id, int font_id) const
 
void GetFirstUnicharAndFont (unsigned shape_id, int *unichar_id, int *font_id) const
 
const ShapeGetShape (unsigned shape_id) const
 
ShapeMutableShape (unsigned shape_id)
 
int BuildFromShape (const Shape &shape, const ShapeTable &master_shapes)
 
bool AlreadyMerged (unsigned shape_id1, unsigned shape_id2) const
 
bool AnyMultipleUnichars () const
 
int MaxNumUnichars () const
 
void ForceFontMerges (unsigned start, unsigned end)
 
unsigned MasterUnicharCount (unsigned shape_id) const
 
int MasterFontCount (unsigned shape_id) const
 
int MergedUnicharCount (unsigned shape_id1, unsigned shape_id2) const
 
void MergeShapes (unsigned shape_id1, unsigned shape_id2)
 
void SwapShapes (unsigned shape_id1, unsigned shape_id2)
 
void AppendMasterShapes (const ShapeTable &other, std::vector< int > *shape_map)
 
int NumMasterShapes () const
 
unsigned MasterDestinationIndex (unsigned shape_id) const
 
bool SubsetUnichar (unsigned shape_id1, unsigned shape_id2) const
 
bool MergeSubsetUnichar (int merge_id1, int merge_id2, unsigned shape_id) const
 
bool EqualUnichars (unsigned shape_id1, unsigned shape_id2) const
 
bool MergeEqualUnichars (int merge_id1, int merge_id2, unsigned shape_id) const
 
bool CommonUnichars (unsigned shape_id1, unsigned shape_id2) const
 
bool CommonFont (unsigned shape_id1, unsigned shape_id2) const
 
void AddShapeToResults (const ShapeRating &shape_rating, std::vector< int > *unichar_map, std::vector< UnicharRating > *results) const
 

Detailed Description

Definition at line 230 of file shapetable.h.

Constructor & Destructor Documentation

◆ ShapeTable() [1/2]

tesseract::ShapeTable::ShapeTable ( )

Definition at line 246 of file shapetable.cpp.

246: unicharset_(nullptr), num_fonts_(0) {}

◆ ShapeTable() [2/2]

tesseract::ShapeTable::ShapeTable ( const UNICHARSET unicharset)
explicit

Definition at line 247 of file shapetable.cpp.

247: unicharset_(&unicharset), num_fonts_(0) {}
const UNICHARSET & unicharset() const
Definition: shapetable.h:251

◆ ~ShapeTable()

tesseract::ShapeTable::~ShapeTable ( )
inline

Definition at line 236 of file shapetable.h.

236 {
237 for (auto data : shape_table_) {
238 delete data;
239 }
240 }

Member Function Documentation

◆ AddShape() [1/2]

unsigned tesseract::ShapeTable::AddShape ( const Shape other)

Definition at line 362 of file shapetable.cpp.

362 {
363 unsigned index;
364 for (index = 0; index < shape_table_.size() && !(other == *shape_table_[index]); ++index) {
365 continue;
366 }
367 if (index == shape_table_.size()) {
368 auto *shape = new Shape(other);
369 shape_table_.push_back(shape);
370 }
371 num_fonts_ = 0;
372 return index;
373}

◆ AddShape() [2/2]

unsigned tesseract::ShapeTable::AddShape ( int  unichar_id,
int  font_id 
)

Definition at line 351 of file shapetable.cpp.

351 {
352 auto index = shape_table_.size();
353 auto *shape = new Shape;
354 shape->AddToShape(unichar_id, font_id);
355 shape_table_.push_back(shape);
356 num_fonts_ = std::max(num_fonts_, font_id + 1);
357 return index;
358}

◆ AddShapeToResults()

void tesseract::ShapeTable::AddShapeToResults ( const ShapeRating shape_rating,
std::vector< int > *  unichar_map,
std::vector< UnicharRating > *  results 
) const

Definition at line 716 of file shapetable.cpp.

717 {
718 if (shape_rating.joined) {
719 AddUnicharToResults(UNICHAR_JOINED, shape_rating.rating, unichar_map, results);
720 }
721 if (shape_rating.broken) {
722 AddUnicharToResults(UNICHAR_BROKEN, shape_rating.rating, unichar_map, results);
723 }
724 const Shape &shape = GetShape(shape_rating.shape_id);
725 for (int u = 0; u < shape.size(); ++u) {
726 int result_index =
727 AddUnicharToResults(shape[u].unichar_id, shape_rating.rating, unichar_map, results);
728 for (int font_id : shape[u].font_ids) {
729 (*results)[result_index].fonts.emplace_back(font_id,
730 IntCastRounded(shape_rating.rating * INT16_MAX));
731 }
732 }
733}
int IntCastRounded(double x)
Definition: helpers.h:170
@ UNICHAR_BROKEN
Definition: unicharset.h:38
@ UNICHAR_JOINED
Definition: unicharset.h:37
const Shape & GetShape(unsigned shape_id) const
Definition: shapetable.h:292

◆ AddShapeToShape()

void tesseract::ShapeTable::AddShapeToShape ( unsigned  shape_id,
const Shape other 
)

Definition at line 390 of file shapetable.cpp.

390 {
391 Shape &shape = *shape_table_[shape_id];
392 shape.AddShape(other);
393 num_fonts_ = 0;
394}

◆ AddToShape()

void tesseract::ShapeTable::AddToShape ( unsigned  shape_id,
int  unichar_id,
int  font_id 
)

Definition at line 383 of file shapetable.cpp.

383 {
384 Shape &shape = *shape_table_[shape_id];
385 shape.AddToShape(unichar_id, font_id);
386 num_fonts_ = std::max(num_fonts_, font_id + 1);
387}

◆ AlreadyMerged()

bool tesseract::ShapeTable::AlreadyMerged ( unsigned  shape_id1,
unsigned  shape_id2 
) const

Definition at line 453 of file shapetable.cpp.

453 {
454 return MasterDestinationIndex(shape_id1) == MasterDestinationIndex(shape_id2);
455}
unsigned MasterDestinationIndex(unsigned shape_id) const
Definition: shapetable.cpp:548

◆ AnyMultipleUnichars()

bool tesseract::ShapeTable::AnyMultipleUnichars ( ) const

Definition at line 458 of file shapetable.cpp.

458 {
459 auto num_shapes = NumShapes();
460 for (unsigned s1 = 0; s1 < num_shapes; ++s1) {
461 if (MasterDestinationIndex(s1) != s1) {
462 continue;
463 }
464 if (GetShape(s1).size() > 1) {
465 return true;
466 }
467 }
468 return false;
469}
unsigned NumShapes() const
Definition: shapetable.h:248

◆ AppendMasterShapes()

void tesseract::ShapeTable::AppendMasterShapes ( const ShapeTable other,
std::vector< int > *  shape_map 
)

Definition at line 683 of file shapetable.cpp.

683 {
684 if (shape_map != nullptr) {
685 shape_map->clear();
686 shape_map->resize(other.NumShapes(), -1);
687 }
688 for (unsigned s = 0; s < other.shape_table_.size(); ++s) {
689 if (other.shape_table_[s]->destination_index() < 0) {
690 int index = AddShape(*other.shape_table_[s]);
691 if (shape_map != nullptr) {
692 (*shape_map)[s] = index;
693 }
694 }
695 }
696}
unsigned AddShape(int unichar_id, int font_id)
Definition: shapetable.cpp:351

◆ BuildFromShape()

int tesseract::ShapeTable::BuildFromShape ( const Shape shape,
const ShapeTable master_shapes 
)

Definition at line 428 of file shapetable.cpp.

428 {
429 BitVector shape_map(master_shapes.NumShapes());
430 for (int u_ind = 0; u_ind < shape.size(); ++u_ind) {
431 for (unsigned f_ind = 0; f_ind < shape[u_ind].font_ids.size(); ++f_ind) {
432 int c = shape[u_ind].unichar_id;
433 int f = shape[u_ind].font_ids[f_ind];
434 int master_id = master_shapes.FindShape(c, f);
435 if (master_id >= 0) {
436 shape_map.SetBit(master_id);
437 } else if (FindShape(c, f) < 0) {
438 AddShape(c, f);
439 }
440 }
441 }
442 int num_masters = 0;
443 for (unsigned s = 0; s < master_shapes.NumShapes(); ++s) {
444 if (shape_map[s]) {
445 AddShape(master_shapes.GetShape(s));
446 ++num_masters;
447 }
448 }
449 return num_masters;
450}
int FindShape(int unichar_id, int font_id) const
Definition: shapetable.cpp:400

◆ CommonFont()

bool tesseract::ShapeTable::CommonFont ( unsigned  shape_id1,
unsigned  shape_id2 
) const

Definition at line 667 of file shapetable.cpp.

667 {
668 const Shape &shape1 = GetShape(shape_id1);
669 const Shape &shape2 = GetShape(shape_id2);
670 for (int c1 = 0; c1 < shape1.size(); ++c1) {
671 const std::vector<int> &font_list1 = shape1[c1].font_ids;
672 for (int f : font_list1) {
673 if (shape2.ContainsFont(f)) {
674 return true;
675 }
676 }
677 }
678 return false;
679}

◆ CommonUnichars()

bool tesseract::ShapeTable::CommonUnichars ( unsigned  shape_id1,
unsigned  shape_id2 
) const

Definition at line 654 of file shapetable.cpp.

654 {
655 const Shape &shape1 = GetShape(shape_id1);
656 const Shape &shape2 = GetShape(shape_id2);
657 for (int c1 = 0; c1 < shape1.size(); ++c1) {
658 int unichar_id1 = shape1[c1].unichar_id;
659 if (shape2.ContainsUnichar(unichar_id1)) {
660 return true;
661 }
662 }
663 return false;
664}

◆ DebugStr()

std::string tesseract::ShapeTable::DebugStr ( unsigned  shape_id) const

Definition at line 292 of file shapetable.cpp.

292 {
293 if (shape_id >= shape_table_.size()) {
294 return "INVALID_UNICHAR_ID";
295 }
296 const Shape &shape = GetShape(shape_id);
297 std::string result;
298 result += "Shape" + std::to_string(shape_id);
299 if (shape.size() > 100) {
300 result += " Num unichars=" + std::to_string(shape.size());
301 return result;
302 }
303 for (int c = 0; c < shape.size(); ++c) {
304 result += " c_id=" + std::to_string(shape[c].unichar_id);
305 result += "=";
306 result += unicharset_->id_to_unichar(shape[c].unichar_id);
307 if (shape.size() < 10) {
308 result += ", " + std::to_string(shape[c].font_ids.size());
309 result += " fonts =";
310 int num_fonts = shape[c].font_ids.size();
311 if (num_fonts > 10) {
312 result += " " + std::to_string(shape[c].font_ids[0]);
313 result += " ... " + std::to_string(shape[c].font_ids[num_fonts - 1]);
314 } else {
315 for (int f = 0; f < num_fonts; ++f) {
316 result += " " + std::to_string(shape[c].font_ids[f]);
317 }
318 }
319 }
320 }
321 return result;
322}
const char * id_to_unichar(UNICHAR_ID id) const
Definition: unicharset.cpp:279

◆ DeleteShape()

void tesseract::ShapeTable::DeleteShape ( unsigned  shape_id)

Definition at line 376 of file shapetable.cpp.

376 {
377 delete shape_table_[shape_id];
378 shape_table_.erase(shape_table_.begin() + shape_id);
379}

◆ DeSerialize()

bool tesseract::ShapeTable::DeSerialize ( TFile fp)

Definition at line 255 of file shapetable.cpp.

255 {
256 if (!fp->DeSerialize(shape_table_)) {
257 return false;
258 }
259 num_fonts_ = 0;
260 return true;
261}

◆ EqualUnichars()

bool tesseract::ShapeTable::EqualUnichars ( unsigned  shape_id1,
unsigned  shape_id2 
) const

Definition at line 609 of file shapetable.cpp.

609 {
610 const Shape &shape1 = GetShape(shape_id1);
611 const Shape &shape2 = GetShape(shape_id2);
612 for (int c1 = 0; c1 < shape1.size(); ++c1) {
613 int unichar_id1 = shape1[c1].unichar_id;
614 if (!shape2.ContainsUnichar(unichar_id1)) {
615 return false;
616 }
617 }
618 for (int c2 = 0; c2 < shape2.size(); ++c2) {
619 int unichar_id2 = shape2[c2].unichar_id;
620 if (!shape1.ContainsUnichar(unichar_id2)) {
621 return false;
622 }
623 }
624 return true;
625}

◆ FindShape()

int tesseract::ShapeTable::FindShape ( int  unichar_id,
int  font_id 
) const

Definition at line 400 of file shapetable.cpp.

400 {
401 for (unsigned s = 0; s < shape_table_.size(); ++s) {
402 const Shape &shape = GetShape(s);
403 for (int c = 0; c < shape.size(); ++c) {
404 if (shape[c].unichar_id == unichar_id) {
405 if (font_id < 0) {
406 return s; // We don't care about the font.
407 }
408 for (int f : shape[c].font_ids) {
409 if (f == font_id) {
410 return s;
411 }
412 }
413 }
414 }
415 }
416 return -1;
417}

◆ ForceFontMerges()

void tesseract::ShapeTable::ForceFontMerges ( unsigned  start,
unsigned  end 
)

Definition at line 485 of file shapetable.cpp.

485 {
486 for (unsigned s1 = start; s1 < end; ++s1) {
487 if (MasterDestinationIndex(s1) == s1 && GetShape(s1).size() == 1) {
488 int unichar_id = GetShape(s1)[0].unichar_id;
489 for (auto s2 = s1 + 1; s2 < end; ++s2) {
490 if (MasterDestinationIndex(s2) == s2 && GetShape(s2).size() == 1 &&
491 unichar_id == GetShape(s2)[0].unichar_id) {
492 MergeShapes(s1, s2);
493 }
494 }
495 }
496 }
497 ShapeTable compacted(*unicharset_);
498 compacted.AppendMasterShapes(*this, nullptr);
499 *this = compacted;
500}
void MergeShapes(unsigned shape_id1, unsigned shape_id2)
Definition: shapetable.cpp:530

◆ GetFirstUnicharAndFont()

void tesseract::ShapeTable::GetFirstUnicharAndFont ( unsigned  shape_id,
int *  unichar_id,
int *  font_id 
) const

Definition at line 420 of file shapetable.cpp.

420 {
421 const UnicharAndFonts &unichar_and_fonts = (*shape_table_[shape_id])[0];
422 *unichar_id = unichar_and_fonts.unichar_id;
423 *font_id = unichar_and_fonts.font_ids[0];
424}

◆ GetShape()

const Shape & tesseract::ShapeTable::GetShape ( unsigned  shape_id) const
inline

Definition at line 292 of file shapetable.h.

292 {
293 return *shape_table_[shape_id];
294 }

◆ MasterDestinationIndex()

unsigned tesseract::ShapeTable::MasterDestinationIndex ( unsigned  shape_id) const

Definition at line 548 of file shapetable.cpp.

548 {
549 auto dest_id = shape_table_[shape_id]->destination_index();
550 if (static_cast<unsigned>(dest_id) == shape_id || dest_id < 0) {
551 return shape_id; // Is master already.
552 }
553 auto master_id = shape_table_[dest_id]->destination_index();
554 if (master_id == dest_id || master_id < 0) {
555 return dest_id; // Dest is the master and shape_id points to it.
556 }
557 master_id = MasterDestinationIndex(master_id);
558 return master_id;
559}

◆ MasterFontCount()

int tesseract::ShapeTable::MasterFontCount ( unsigned  shape_id) const

Definition at line 509 of file shapetable.cpp.

509 {
510 int master_id = MasterDestinationIndex(shape_id);
511 const Shape &shape = GetShape(master_id);
512 int font_count = 0;
513 for (int c = 0; c < shape.size(); ++c) {
514 font_count += shape[c].font_ids.size();
515 }
516 return font_count;
517}

◆ MasterUnicharCount()

unsigned tesseract::ShapeTable::MasterUnicharCount ( unsigned  shape_id) const

Definition at line 503 of file shapetable.cpp.

503 {
504 int master_id = MasterDestinationIndex(shape_id);
505 return GetShape(master_id).size();
506}
int size() const
Definition: shapetable.h:169

◆ MaxNumUnichars()

int tesseract::ShapeTable::MaxNumUnichars ( ) const

Definition at line 472 of file shapetable.cpp.

472 {
473 int max_num_unichars = 0;
474 int num_shapes = NumShapes();
475 for (int s = 0; s < num_shapes; ++s) {
476 if (GetShape(s).size() > max_num_unichars) {
477 max_num_unichars = GetShape(s).size();
478 }
479 }
480 return max_num_unichars;
481}

◆ MergedUnicharCount()

int tesseract::ShapeTable::MergedUnicharCount ( unsigned  shape_id1,
unsigned  shape_id2 
) const

Definition at line 520 of file shapetable.cpp.

520 {
521 // Do it the easy way for now.
522 int master_id1 = MasterDestinationIndex(shape_id1);
523 int master_id2 = MasterDestinationIndex(shape_id2);
524 Shape combined_shape(*shape_table_[master_id1]);
525 combined_shape.AddShape(*shape_table_[master_id2]);
526 return combined_shape.size();
527}

◆ MergeEqualUnichars()

bool tesseract::ShapeTable::MergeEqualUnichars ( int  merge_id1,
int  merge_id2,
unsigned  shape_id 
) const

Definition at line 628 of file shapetable.cpp.

628 {
629 const Shape &merge1 = GetShape(merge_id1);
630 const Shape &merge2 = GetShape(merge_id2);
631 const Shape &shape = GetShape(shape_id);
632 for (int cs = 0; cs < shape.size(); ++cs) {
633 int unichar_id = shape[cs].unichar_id;
634 if (!merge1.ContainsUnichar(unichar_id) && !merge2.ContainsUnichar(unichar_id)) {
635 return false; // Shape has a unichar that appears in neither merge.
636 }
637 }
638 for (int cm1 = 0; cm1 < merge1.size(); ++cm1) {
639 int unichar_id1 = merge1[cm1].unichar_id;
640 if (!shape.ContainsUnichar(unichar_id1)) {
641 return false; // Merge has a unichar that is not in shape.
642 }
643 }
644 for (int cm2 = 0; cm2 < merge2.size(); ++cm2) {
645 int unichar_id2 = merge2[cm2].unichar_id;
646 if (!shape.ContainsUnichar(unichar_id2)) {
647 return false; // Merge has a unichar that is not in shape.
648 }
649 }
650 return true;
651}

◆ MergeShapes()

void tesseract::ShapeTable::MergeShapes ( unsigned  shape_id1,
unsigned  shape_id2 
)

Definition at line 530 of file shapetable.cpp.

530 {
531 auto master_id1 = MasterDestinationIndex(shape_id1);
532 auto master_id2 = MasterDestinationIndex(shape_id2);
533 // Point master_id2 (and all merged shapes) to master_id1.
534 shape_table_[master_id2]->set_destination_index(master_id1);
535 // Add all the shapes of master_id2 to master_id1.
536 shape_table_[master_id1]->AddShape(*shape_table_[master_id2]);
537}

◆ MergeSubsetUnichar()

bool tesseract::ShapeTable::MergeSubsetUnichar ( int  merge_id1,
int  merge_id2,
unsigned  shape_id 
) const

Definition at line 582 of file shapetable.cpp.

582 {
583 const Shape &merge1 = GetShape(merge_id1);
584 const Shape &merge2 = GetShape(merge_id2);
585 const Shape &shape = GetShape(shape_id);
586 int cm1, cm2, cs;
587 for (cs = 0; cs < shape.size(); ++cs) {
588 int unichar_id = shape[cs].unichar_id;
589 if (!merge1.ContainsUnichar(unichar_id) && !merge2.ContainsUnichar(unichar_id)) {
590 break; // Shape is not a subset of the merge.
591 }
592 }
593 for (cm1 = 0; cm1 < merge1.size(); ++cm1) {
594 int unichar_id1 = merge1[cm1].unichar_id;
595 if (!shape.ContainsUnichar(unichar_id1)) {
596 break; // Merge is not a subset of shape
597 }
598 }
599 for (cm2 = 0; cm2 < merge2.size(); ++cm2) {
600 int unichar_id2 = merge2[cm2].unichar_id;
601 if (!shape.ContainsUnichar(unichar_id2)) {
602 break; // Merge is not a subset of shape
603 }
604 }
605 return cs == shape.size() || (cm1 == merge1.size() && cm2 == merge2.size());
606}

◆ MutableShape()

Shape * tesseract::ShapeTable::MutableShape ( unsigned  shape_id)
inline

Definition at line 295 of file shapetable.h.

295 {
296 return shape_table_[shape_id];
297 }

◆ NumFonts()

int tesseract::ShapeTable::NumFonts ( ) const

Definition at line 265 of file shapetable.cpp.

265 {
266 if (num_fonts_ <= 0) {
267 for (auto shape_id : shape_table_) {
268 const Shape &shape = *shape_id;
269 for (int c = 0; c < shape.size(); ++c) {
270 for (int font_id : shape[c].font_ids) {
271 if (font_id >= num_fonts_) {
272 num_fonts_ = font_id + 1;
273 }
274 }
275 }
276 }
277 }
278 return num_fonts_;
279}

◆ NumMasterShapes()

int tesseract::ShapeTable::NumMasterShapes ( ) const

Definition at line 699 of file shapetable.cpp.

699 {
700 int num_shapes = 0;
701 for (auto s : shape_table_) {
702 if (s->destination_index() < 0) {
703 ++num_shapes;
704 }
705 }
706 return num_shapes;
707}

◆ NumShapes()

unsigned tesseract::ShapeTable::NumShapes ( ) const
inline

Definition at line 248 of file shapetable.h.

248 {
249 return shape_table_.size();
250 }

◆ ReMapClassIds()

void tesseract::ShapeTable::ReMapClassIds ( const std::vector< int > &  unicharset_map)

Definition at line 283 of file shapetable.cpp.

283 {
284 for (auto shape : shape_table_) {
285 for (int c = 0; c < shape->size(); ++c) {
286 shape->SetUnicharId(c, unicharset_map[(*shape)[c].unichar_id]);
287 }
288 }
289}

◆ Serialize()

bool tesseract::ShapeTable::Serialize ( FILE *  fp) const

Definition at line 250 of file shapetable.cpp.

250 {
251 return tesseract::Serialize(fp, shape_table_);
252}
bool Serialize(FILE *fp, const std::vector< T > &data)
Definition: helpers.h:236

◆ set_unicharset()

void tesseract::ShapeTable::set_unicharset ( const UNICHARSET unicharset)
inline

Definition at line 259 of file shapetable.h.

259 {
260 unicharset_ = &unicharset;
261 }

◆ SubsetUnichar()

bool tesseract::ShapeTable::SubsetUnichar ( unsigned  shape_id1,
unsigned  shape_id2 
) const

Definition at line 562 of file shapetable.cpp.

562 {
563 const Shape &shape1 = GetShape(shape_id1);
564 const Shape &shape2 = GetShape(shape_id2);
565 int c1, c2;
566 for (c1 = 0; c1 < shape1.size(); ++c1) {
567 int unichar_id1 = shape1[c1].unichar_id;
568 if (!shape2.ContainsUnichar(unichar_id1)) {
569 break;
570 }
571 }
572 for (c2 = 0; c2 < shape2.size(); ++c2) {
573 int unichar_id2 = shape2[c2].unichar_id;
574 if (!shape1.ContainsUnichar(unichar_id2)) {
575 break;
576 }
577 }
578 return c1 == shape1.size() || c2 == shape2.size();
579}

◆ SummaryStr()

std::string tesseract::ShapeTable::SummaryStr ( ) const

Definition at line 325 of file shapetable.cpp.

325 {
326 int max_unichars = 0;
327 int num_multi_shapes = 0;
328 int num_master_shapes = 0;
329 for (unsigned s = 0; s < shape_table_.size(); ++s) {
330 if (MasterDestinationIndex(s) != s) {
331 continue;
332 }
333 ++num_master_shapes;
334 int shape_size = GetShape(s).size();
335 if (shape_size > 1) {
336 ++num_multi_shapes;
337 }
338 if (shape_size > max_unichars) {
339 max_unichars = shape_size;
340 }
341 }
342 std::string result;
343 result += "Number of shapes = " + std::to_string(num_master_shapes);
344 result += " max unichars = " + std::to_string(max_unichars);
345 result += " number with multiple unichars = " + std::to_string(num_multi_shapes);
346 return result;
347}

◆ SwapShapes()

void tesseract::ShapeTable::SwapShapes ( unsigned  shape_id1,
unsigned  shape_id2 
)

Definition at line 540 of file shapetable.cpp.

540 {
541 Shape *tmp = shape_table_[shape_id1];
542 shape_table_[shape_id1] = shape_table_[shape_id2];
543 shape_table_[shape_id2] = tmp;
544}

◆ unicharset()

const UNICHARSET & tesseract::ShapeTable::unicharset ( ) const
inline

Definition at line 251 of file shapetable.h.

251 {
252 return *unicharset_;
253 }

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