/** * @name classify_blob * * Classify the this blob if it is not already recorded in the match * table. Attempt to recognize this blob as a character. The recognition * rating for this blob will be stored as a part of the blob. This value * will also be returned to the caller. * @param blob Current blob * @param string The string to display in ScrollView * @param color The colour to use when displayed with ScrollView */ BLOB_CHOICE_LIST *Wordrec::classify_blob(TBLOB *blob, const char *string, C_COL color, BlamerBundle *blamer_bundle) { #ifndef GRAPHICS_DISABLED if (wordrec_display_all_blobs) display_blob(blob, color); #endif // TODO(rays) collapse with call_matcher and move all to wordrec.cpp. BLOB_CHOICE_LIST* choices = call_matcher(blob); // If a blob with the same bounding box as one of the truth character // bounding boxes is not classified as the corresponding truth character // blame character classifier for incorrect answer. if (blamer_bundle != NULL) { blamer_bundle->BlameClassifier(getDict().getUnicharset(), blob->bounding_box(), *choices, wordrec_debug_blamer); } #ifndef GRAPHICS_DISABLED if (classify_debug_level && string) print_ratings_list(string, choices, getDict().getUnicharset()); if (wordrec_blob_pause) window_wait(blob_window); #endif return choices; }
/********************************************************************** * classify_blob * * Classify the this blob if it is not already recorded in the match * table. Attempt to recognize this blob as a character. The recognition * rating (probability) for this blob will be stored as a part of the * blob. This value will also be returned to the caller. **********************************************************************/ CHOICES classify_blob(TBLOB *pblob, TBLOB *blob, TBLOB *nblob, TEXTROW *row, int fx, const char *string, C_COL color, STATE *this_state, STATE *best_state, INT32 pass, INT32 blob_index) { CHOICES rating; INT32 old_index; chars_classified++; /* Global value */ if (blob_skip) return (NIL); #ifndef GRAPHICS_DISABLED if (display_all_blobs) display_blob(blob, color); #endif rating = get_match (blob); if (rating == NIL) { if (pass) { old_index = blob_index; //?cast to int* blob_type = compare_states (best_state, this_state, (int *) &blob_index); blob_answer = word_answer[blob_index]; if (blob_answer < '!') fprintf (matcher_fp, "Bad compare states: best state=0x%x%x, this=0x%x%x, bits=" INT32FORMAT ", index=" INT32FORMAT ", outdex=" INT32FORMAT ", word=%s\n", best_state->part1, best_state->part2, this_state->part1, this_state->part2, bits_in_states, old_index, blob_index, word_answer); } else blob_type = 0; rating = /*(*blob_matchers [fx]) */ (CHOICES) call_matcher (pblob, blob, nblob, NULL, row); put_match(blob, rating); } #ifndef GRAPHICS_DISABLED if (display_ratings && string) print_choices(string, rating); if (blob_pause) window_wait(blob_window); #endif return (rating); }