Definition at line 288 of file cjkpitch.cpp.
◆ FPRow()
tesseract::FPRow::FPRow |
( |
| ) |
|
|
inline |
Definition at line 290 of file cjkpitch.cpp.
290 : all_pitches_(), all_gaps_(), good_pitches_(), good_gaps_(), heights_(), characters_() {}
◆ ~FPRow()
tesseract::FPRow::~FPRow |
( |
| ) |
|
|
default |
◆ box()
const TBOX& tesseract::FPRow::box |
( |
int |
i | ) |
|
|
inline |
Definition at line 366 of file cjkpitch.cpp.
367 return characters_[i].box();
◆ center_x()
float tesseract::FPRow::center_x |
( |
int |
i | ) |
|
|
inline |
Definition at line 378 of file cjkpitch.cpp.
379 return (characters_[i].
box().left() + characters_[i].
box().right()) / 2.0;
◆ character()
FPChar* tesseract::FPRow::character |
( |
int |
i | ) |
|
|
inline |
◆ clear_alignment()
void tesseract::FPRow::clear_alignment |
( |
int |
i | ) |
|
|
inline |
◆ DebugOutputResult()
void tesseract::FPRow::DebugOutputResult |
( |
int |
row_index | ) |
|
Definition at line 686 of file cjkpitch.cpp.
689 "Row %d: pitch_decision=%d, fixed_pitch=%f, max_nonspace=%d, "
690 "space_size=%f, space_threshold=%d, xheight=%f\n",
695 for (
unsigned i = 0; i <
num_chars(); i++) {
void tprintf(const char *format,...)
PITCH_TYPE pitch_decision
FPChar * character(int i)
◆ estimated_pitch()
float tesseract::FPRow::estimated_pitch |
( |
| ) |
|
|
inline |
◆ EstimatePitch()
void tesseract::FPRow::EstimatePitch |
( |
bool |
pass1 | ) |
|
Definition at line 615 of file cjkpitch.cpp.
616 good_pitches_.
Clear();
617 all_pitches_.
Clear();
626 bool prev_was_good =
is_good(0);
630 for (
size_t i = 1; i <
num_chars(); i++) {
632 int32_t
pitch = cx1 - cx0;
638 if (
pitch > height_ * 0.5) {
649 (prev_was_good && std::fabs(estimated_pitch_ -
pitch) < kFPTolerance * estimated_pitch_)) {
655 prev_was_good =
true;
657 prev_was_good =
false;
669 height_ = heights_.
ile(0.875);
670 if (all_pitches_.
empty()) {
673 }
else if (good_pitches_.
size() < 2) {
676 pitch_ = all_pitches_.
median();
678 gap_ = all_gaps_.
ile(0.125);
680 pitch_ = good_pitches_.
median();
682 gap_ = good_gaps_.
ile(0.125);
bool is_box_modified(int i)
const TBOX & real_body(int i)
◆ finalize()
void tesseract::FPRow::finalize |
( |
int |
i | ) |
|
|
inline |
Definition at line 386 of file cjkpitch.cpp.
387 characters_[i].set_final(
true);
◆ FinalizeLargeChars()
void tesseract::FPRow::FinalizeLargeChars |
( |
| ) |
|
Definition at line 870 of file cjkpitch.cpp.
872 for (
size_t i = 0; i <
num_chars(); i++) {
884 TBOX ibody(cx - 0.5 * row_pitch, 0, cx + 0.5 * row_pitch, 1);
889 if (x_overlap_fraction(ibody,
box(i - 1)) > 0.1) {
894 merged +=
box(i - 1);
895 if (merged.width() < row_pitch) {
904 if (x_overlap_fraction(ibody,
box(i + 1)) > 0.1) {
909 merged +=
box(i + 1);
910 if (merged.width() < row_pitch) {
923 for (
size_t i = 0; i <
num_chars(); i++) {
927 bool good_pitch =
false;
928 bool bad_pitch =
false;
930 if (is_good_pitch(row_pitch,
box(i - 1),
box(i))) {
937 if (is_good_pitch(row_pitch,
box(i),
box(i + 1))) {
943 if (good_pitch && !bad_pitch) {
945 }
else if (!good_pitch && bad_pitch) {
◆ gap()
float tesseract::FPRow::gap |
( |
| ) |
|
|
inline |
◆ good_pitches()
int tesseract::FPRow::good_pitches |
( |
| ) |
|
|
inline |
◆ height()
float tesseract::FPRow::height |
( |
| ) |
|
|
inline |
◆ height_pitch_ratio()
float tesseract::FPRow::height_pitch_ratio |
( |
| ) |
|
|
inline |
Definition at line 348 of file cjkpitch.cpp.
349 if (good_pitches_.
size() < 2) {
352 return height_ / good_pitches_.
median();
◆ Init()
void tesseract::FPRow::Init |
( |
TO_ROW * |
row | ) |
|
Definition at line 496 of file cjkpitch.cpp.
502 BLOBNBOX_IT blob_it = row->blob_list();
505 for (blob_it.mark_cycle_pt(); !blob_it.cycled_list(); blob_it.forward()) {
506 if (is_interesting_blob(blob_it.data())) {
508 fp_char.Init(blob_it.data());
510 if (!characters_.empty() && significant_overlap(fp_char.box(), characters_.back().box())) {
511 characters_.back().Merge(fp_char);
513 characters_.push_back(fp_char);
515 TBOX bound = blob_it.data()->bounding_box();
516 if (bound.height() * 3.0 > bound.width()) {
517 heights_.
Add(bound.height());
522 height_ = heights_.
ile(0.875);
◆ is_box_modified()
bool tesseract::FPRow::is_box_modified |
( |
int |
i | ) |
|
|
inline |
Definition at line 374 of file cjkpitch.cpp.
375 return !(characters_[i].box() == characters_[i].real_body());
◆ is_final()
bool tesseract::FPRow::is_final |
( |
int |
i | ) |
|
|
inline |
Definition at line 382 of file cjkpitch.cpp.
383 return characters_[i].is_final();
◆ is_good()
bool tesseract::FPRow::is_good |
( |
int |
i | ) |
|
|
inline |
◆ mark_bad()
void tesseract::FPRow::mark_bad |
( |
int |
i | ) |
|
|
inline |
◆ mark_good()
void tesseract::FPRow::mark_good |
( |
int |
i | ) |
|
|
inline |
◆ MergeFragments()
void tesseract::FPRow::MergeFragments |
( |
| ) |
|
Definition at line 854 of file cjkpitch.cpp.
857 for (
size_t j = 0; j <
num_chars(); ++j) {
bool merge_to_prev() const
void Merge(const FPChar &next)
void set_delete_flag(bool flag)
void set_merge_to_prev(bool flag)
void clear_alignment(int i)
◆ num_chars()
size_t tesseract::FPRow::num_chars |
( |
| ) |
|
|
inline |
Definition at line 359 of file cjkpitch.cpp.
360 return characters_.size();
◆ OutputEstimations()
void tesseract::FPRow::OutputEstimations |
( |
| ) |
|
Definition at line 525 of file cjkpitch.cpp.
526 if (good_pitches_.
empty()) {
532 pitch_ = good_pitches_.
median();
538 std::min(good_gaps_.
ile(0.125), std::max(pitch_ - height_, 0.0f));
541 if (good_pitches_.
size() < all_pitches_.
size() * kFixedPitchThreshold) {
550 }
else if (good_pitches_.
size() > all_pitches_.
size() * 0.75) {
564 std::max(pitch_ * 0.25 + good_gaps_.
minimum(),
static_cast<double>(good_gaps_.
ile(0.875)));
567 static_cast<int>(real_row_->
xheight));
571 for (
size_t i = 0; i <
num_chars(); ++i) {
572 if (characters_[i].max_gap() > real_row_->
max_nonspace) {
577 static_cast<int>(real_row_->
xheight));
581 ICOORDELT_IT cell_it = &real_row_->
char_cells;
582 auto *cell =
new ICOORDELT(
real_body(0).left(), 0);
583 cell_it.add_after_then_move(cell);
586 for (
size_t i = 1; i <
num_chars(); ++i) {
593 cell =
new ICOORDELT(right + 1, 0);
594 cell_it.add_after_then_move(cell);
595 while (right + pitch_ <
box(i).left()) {
597 cell =
new ICOORDELT(right + 1, 0);
598 cell_it.add_after_then_move(cell);
602 cell =
new ICOORDELT((right +
real_body(i).left()) / 2, 0);
603 cell_it.add_after_then_move(cell);
607 cell =
new ICOORDELT(right + 1, 0);
608 cell_it.add_after_then_move(cell);
ICOORDELT_LIST char_cells
int x_gap(const TBOX &box) const
◆ Pass1Analyze()
void tesseract::FPRow::Pass1Analyze |
( |
| ) |
|
Definition at line 703 of file cjkpitch.cpp.
708 if (estimated_pitch_ > 0.0f) {
709 for (
size_t i = 2; i <
num_chars(); i++) {
710 if (is_good_pitch(estimated_pitch_,
box(i - 2),
box(i - 1)) &&
711 is_good_pitch(estimated_pitch_,
box(i - 1),
box(i))) {
716 for (
size_t i = 2; i <
num_chars(); i++) {
717 if (is_good_pitch(box_pitch(
box(i - 2),
box(i - 1)),
box(i - 1),
box(i))) {
void set_alignment(Alignment alignment)
◆ Pass2Analyze()
bool tesseract::FPRow::Pass2Analyze |
( |
| ) |
|
Definition at line 726 of file cjkpitch.cpp.
727 bool changed =
false;
728 if (
num_chars() <= 1 || estimated_pitch_ == 0.0f) {
731 for (
size_t i = 0; i <
num_chars(); i++) {
737 bool intersecting =
false;
738 bool not_intersecting =
false;
744 bool skipped_whitespaces =
false;
745 float c1 =
center_x(i + 1) - 1.5 * estimated_pitch_;
746 while (c1 >
box(i).right()) {
747 skipped_whitespaces =
true;
748 c1 -= estimated_pitch_;
750 TBOX ibody(c1,
box(i).bottom(), c1 + estimated_pitch_,
box(i).top());
756 while (j >= 0 && !
is_final(j) && mostly_overlap(ibody,
box(j)) &&
757 merged.bounding_union(
box(j)).
height() < estimated_pitch_ * (1 + kFPTolerance)) {
762 if (j >= 0 && significant_overlap(ibody,
box(j))) {
769 not_intersecting =
true;
775 if (!skipped_whitespaces) {
781 if (
box(i).width() <= estimated_pitch_ * 0.5) {
788 for (
int k = i; k > j + 1; k--) {
799 bool skipped_whitespaces =
false;
800 float c1 =
center_x(i - 1) + 1.5 * estimated_pitch_;
801 while (c1 <
box(i).left()) {
802 skipped_whitespaces =
true;
803 c1 += estimated_pitch_;
805 TBOX ibody(c1 - estimated_pitch_,
box(i).bottom(), c1,
box(i).top());
810 merged.bounding_union(
box(j)).
height() < estimated_pitch_ * (1 + kFPTolerance)) {
815 if (j <
num_chars() && significant_overlap(ibody,
box(j))) {
820 not_intersecting =
true;
823 if (!skipped_whitespaces) {
826 if (
box(i).width() <= estimated_pitch_ * 0.5) {
833 for (
size_t k = i + 1; k < j; k++) {
843 if (intersecting && !not_intersecting) {
const Alignment & alignment() const
void set_box(const TBOX &box)
◆ pitch()
float tesseract::FPRow::pitch |
( |
| ) |
|
|
inline |
◆ real_body()
const TBOX& tesseract::FPRow::real_body |
( |
int |
i | ) |
|
|
inline |
Definition at line 370 of file cjkpitch.cpp.
371 return characters_[i].real_body();
◆ set_estimated_pitch()
void tesseract::FPRow::set_estimated_pitch |
( |
float |
v | ) |
|
|
inline |
The documentation for this class was generated from the following file: