tesseract  5.0.0
wordclass.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * File: wordclass.cpp (Formerly wordclass.c)
4  * Description: Word classifier
5  * Author: Mark Seaman, OCR Technology
6  *
7  * (c) Copyright 1990, Hewlett-Packard Company.
8  ** Licensed under the Apache License, Version 2.0 (the "License");
9  ** you may not use this file except in compliance with the License.
10  ** You may obtain a copy of the License at
11  ** http://www.apache.org/licenses/LICENSE-2.0
12  ** Unless required by applicable law or agreed to in writing, software
13  ** distributed under the License is distributed on an "AS IS" BASIS,
14  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  ** See the License for the specific language governing permissions and
16  ** limitations under the License.
17  *
18  *****************************************************************************/
19 /*----------------------------------------------------------------------
20  I N C L U D E S
21 ----------------------------------------------------------------------*/
22 
23 #include "blamer.h" // for blamer_bundle
24 #include "params.h" // for BoolParam
25 #include "render.h" // for display_blob, blob_window, wordrec_blob_pause
26 #include "wordrec.h" // for Wordrec
27 
28 class BLOB_CHOICE_LIST;
29 
30 struct TBLOB;
31 
32 // Include automatically generated configuration file if running autoconf.
33 #ifdef HAVE_CONFIG_H
34 # include "config_auto.h"
35 #endif
36 
37 /*----------------------------------------------------------------------
38  F u n c t i o n s
39 ----------------------------------------------------------------------*/
40 namespace tesseract {
52 BLOB_CHOICE_LIST *Wordrec::classify_blob(TBLOB *blob, const char *string, ScrollView::Color color,
53  BlamerBundle *blamer_bundle) {
54 #ifndef GRAPHICS_DISABLED
56  display_blob(blob, color);
57  }
58 #endif
59  // TODO(rays) collapse with call_matcher and move all to wordrec.cpp.
60  BLOB_CHOICE_LIST *choices = call_matcher(blob);
61  // If a blob with the same bounding box as one of the truth character
62  // bounding boxes is not classified as the corresponding truth character
63  // blame character classifier for incorrect answer.
64  if (blamer_bundle != nullptr) {
65  blamer_bundle->BlameClassifier(getDict().getUnicharset(), blob->bounding_box(), *choices,
66  wordrec_debug_blamer);
67  }
68 #ifndef GRAPHICS_DISABLED
69  if (classify_debug_level && string) {
70  print_ratings_list(string, choices, getDict().getUnicharset());
71  }
72 
73  if (wordrec_blob_pause) {
74  blob_window->Wait();
75  }
76 #endif
77 
78  return choices;
79 }
80 
81 } // namespace tesseract
ScrollView * blob_window
Definition: render.cpp:36
void print_ratings_list(const char *msg, BLOB_CHOICE_LIST *ratings, const UNICHARSET &current_unicharset)
Definition: ratngs.cpp:804
bool wordrec_display_all_blobs
Definition: render.cpp:41
bool wordrec_blob_pause
Definition: render.cpp:43
void display_blob(TBLOB *blob, ScrollView::Color color)
Definition: render.cpp:54
void BlameClassifier(const UNICHARSET &unicharset, const TBOX &blob_box, const BLOB_CHOICE_LIST &choices, bool debug)
Definition: blamer.cpp:260
TBOX bounding_box() const
Definition: blobs.cpp:466
virtual Dict & getDict()
Definition: classify.h:98
BLOB_CHOICE_LIST * call_matcher(TBLOB *blob)
Definition: tface.cpp:132
BLOB_CHOICE_LIST * classify_blob(TBLOB *blob, const char *string, ScrollView::Color color, BlamerBundle *blamer_bundle)
Definition: wordclass.cpp:52