From 6ae6c0a0427dec5030532a36b002d1306fdbd837 Mon Sep 17 00:00:00 2001 From: theraysmith Date: Thu, 30 Aug 2007 18:20:10 +0000 Subject: [PATCH] Made some preliminary changes for improving xheights git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@107 d0cd1f9f-072b-0410-8dd7-cf729c803f20 --- ccmain/control.cpp | 7 ++++--- ccmain/fixspace.cpp | 1 + ccmain/tfacepp.cpp | 4 +++- ccstruct/pageres.cpp | 22 ++++++++++++---------- wordrec/chopper.cpp | 2 ++ 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/ccmain/control.cpp b/ccmain/control.cpp index 0c47d9ab..f1437a88 100644 --- a/ccmain/control.cpp +++ b/ccmain/control.cpp @@ -606,7 +606,7 @@ void classify_word_pass1( //recog one word check_debug_pt (word, 0); matcher_pass = 0; - bln_word = make_bln_copy (word->word, row, row->x_height (), &word->denorm); + bln_word = make_bln_copy (word->word, row, word->x_height, &word->denorm); word->best_choice = tess_segment_pass1 (bln_word, &word->denorm, tess_default_matcher, @@ -744,14 +744,15 @@ void classify_word_pass2( //word to do if (!word->done || tessedit_training_tess || tessedit_training_wiseowl || tessedit_dump_choices) { - word->x_height = row->x_height (); word->caps_height = 0.0; + if (word->x_height == 0.0f) + word->x_height = row->x_height(); if (word->outword != NULL) { delete word->outword; //get rid of junk delete word->best_choice; delete word->raw_choice; } - match_word_pass2 (word, row, row->x_height ()); + match_word_pass2 (word, row, word->x_height); done_this_pass = TRUE; check_debug_pt (word, 40); } diff --git a/ccmain/fixspace.cpp b/ccmain/fixspace.cpp index b9fe9479..9a7b7c6d 100644 --- a/ccmain/fixspace.cpp +++ b/ccmain/fixspace.cpp @@ -431,6 +431,7 @@ void transform_to_next_perm(WERD_RES_LIST &words) { //deep copy combo = new WERD_RES (copy_word); combo->combination = TRUE; + combo->x_height = prev_word->x_height; prev_word->part_of_combo = TRUE; prev_word_it.add_before_then_move (combo); } diff --git a/ccmain/tfacepp.cpp b/ccmain/tfacepp.cpp index a34bf3e6..3112eff6 100644 --- a/ccmain/tfacepp.cpp +++ b/ccmain/tfacepp.cpp @@ -348,8 +348,10 @@ LIST call_matcher( //call a matcher char choice_lengths[2] = {0, 0}; blob = make_ed_blob (tessblob);//convert blob - if (blob == NULL) + if (blob == NULL) { + tprintf("Failed to convert blob for recognition!\n"); return NULL; //can't do it + } pblob = ptblob != NULL ? make_ed_blob (ptblob) : NULL; nblob = ntblob != NULL ? make_ed_blob (ntblob) : NULL; (*tess_matcher) (pblob, blob, nblob, tess_word, tess_denorm, ratings); diff --git a/ccstruct/pageres.cpp b/ccstruct/pageres.cpp index 4a542b39..7c94cb0f 100644 --- a/ccstruct/pageres.cpp +++ b/ccstruct/pageres.cpp @@ -34,8 +34,8 @@ CLISTIZE (BLOCK_RES) ELISTIZE (ROW_RES) ELISTIZE (WERD_RES) PAGE_RES::PAGE_RES( //recursive construct BLOCK_LIST *the_block_list //real page ) { - BLOCK_IT block_it(the_block_list); - BLOCK_RES_IT block_res_it(&block_res_list); + BLOCK_IT block_it(the_block_list); + BLOCK_RES_IT block_res_it(&block_res_list); char_count = 0; rej_count = 0; @@ -58,7 +58,7 @@ BLOCK_RES::BLOCK_RES( //recursive construct BLOCK *the_block //real BLOCK ) { ROW_IT row_it (the_block->row_list ()); - ROW_RES_IT row_res_it(&row_res_list); + ROW_RES_IT row_res_it(&row_res_list); char_count = 0; rej_count = 0; @@ -87,7 +87,7 @@ ROW_RES::ROW_RES( //recursive construct ROW *the_row //real ROW ) { WERD_IT word_it (the_row->word_list ()); - WERD_RES_IT word_res_it(&word_res_list); + WERD_RES_IT word_res_it(&word_res_list); WERD_RES *combo = NULL; //current combination of fuzzies WERD_RES *word_res; //current word WERD *copy_word; @@ -104,6 +104,7 @@ ROW_RES::ROW_RES( //recursive construct for (word_it.mark_cycle_pt (); !word_it.cycled_list (); word_it.forward ()) { word_res = new WERD_RES (word_it.data ()); + word_res->x_height = the_row->x_height(); if (word_res->word->flag (W_FUZZY_NON)) { ASSERT_HOST (combo != NULL); @@ -116,6 +117,7 @@ ROW_RES::ROW_RES( //recursive construct //deep copy *copy_word = *(word_it.data ()); combo = new WERD_RES (copy_word); + combo->x_height = the_row->x_height(); combo->combination = TRUE; word_res_it.add_to_end (combo); } @@ -207,7 +209,7 @@ WERD_RES::~WERD_RES () { * Set things up at the start of the page *************************************************************************/ -WERD_RES *PAGE_RES_IT::restart_page() { +WERD_RES *PAGE_RES_IT::restart_page() { block_res_it.set_to_list (&page_res->block_res_list); block_res_it.mark_cycle_pt (); block_res = NULL; @@ -216,7 +218,7 @@ WERD_RES *PAGE_RES_IT::restart_page() { next_block_res = NULL; next_row_res = NULL; next_word_res = NULL; - internal_forward(TRUE); + internal_forward(TRUE); return internal_forward (FALSE); } @@ -230,7 +232,7 @@ WERD_RES *PAGE_RES_IT::restart_page() { * boundaries. NULL values denote start and end of the page. *************************************************************************/ -WERD_RES *PAGE_RES_IT::internal_forward(BOOL8 new_block) { +WERD_RES *PAGE_RES_IT::internal_forward(BOOL8 new_block) { BOOL8 found_next_word = FALSE; BOOL8 new_row = FALSE; @@ -291,7 +293,7 @@ WERD_RES *PAGE_RES_IT::internal_forward(BOOL8 new_block) { * the block, the prev block, row and word are all NULL. *************************************************************************/ -WERD_RES *PAGE_RES_IT::forward_block() { +WERD_RES *PAGE_RES_IT::forward_block() { if (block_res == next_block_res) { block_res_it.forward ();; block_res = NULL; @@ -300,13 +302,13 @@ WERD_RES *PAGE_RES_IT::forward_block() { next_block_res = NULL; next_row_res = NULL; next_word_res = NULL; - internal_forward(TRUE); + internal_forward(TRUE); } return internal_forward (FALSE); } -void PAGE_RES_IT::rej_stat_word() { +void PAGE_RES_IT::rej_stat_word() { INT16 chars_in_word; INT16 rejects_in_word = 0; diff --git a/wordrec/chopper.cpp b/wordrec/chopper.cpp index 820e6f90..b65d20c2 100644 --- a/wordrec/chopper.cpp +++ b/wordrec/chopper.cpp @@ -434,6 +434,8 @@ CHOICES_LIST chop_word_main(register TWERD *word, (CHOICES) classify_blob (pblob, blob, blob->next, NULL, fx, "chop_word:", Green, &chop_states[0], &best_state, matcher_pass, index); + if (match_result == NULL) + cprintf("Null classifier output!\n"); char_choices = array_push (char_choices, match_result); pblob = blob; } -- GitLab