tesseract  5.0.0-alpha-619-ge9db
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 "callcpp.h" // for window_wait, C_COL
25 #include "params.h" // for BoolParam
26 #include "render.h" // for display_blob, blob_window, wordrec_blob_pause
27 #include "wordrec.h" // for Wordrec
28 
29 class BLOB_CHOICE_LIST;
30 
31 struct TBLOB;
32 
33 // Include automatically generated configuration file if running autoconf.
34 #ifdef HAVE_CONFIG_H
35 #include "config_auto.h"
36 #endif
37 
38 /*----------------------------------------------------------------------
39  F u n c t i o n s
40 ----------------------------------------------------------------------*/
41 namespace tesseract {
53 BLOB_CHOICE_LIST *Wordrec::classify_blob(TBLOB *blob,
54  const char *string, C_COL color,
55  BlamerBundle *blamer_bundle) {
56 #ifndef GRAPHICS_DISABLED
58  display_blob(blob, color);
59 #endif
60  // TODO(rays) collapse with call_matcher and move all to wordrec.cpp.
61  BLOB_CHOICE_LIST* choices = call_matcher(blob);
62  // If a blob with the same bounding box as one of the truth character
63  // bounding boxes is not classified as the corresponding truth character
64  // blame character classifier for incorrect answer.
65  if (blamer_bundle != nullptr) {
66  blamer_bundle->BlameClassifier(getDict().getUnicharset(),
67  blob->bounding_box(),
68  *choices,
70  }
71  #ifndef GRAPHICS_DISABLED
72  if (classify_debug_level && string)
73  print_ratings_list(string, choices, getDict().getUnicharset());
74 
77 #endif
78 
79  return choices;
80 }
81 
82 } // namespace tesseract;
render.h
blob_window
ScrollView * blob_window
Definition: render.cpp:31
BlamerBundle::BlameClassifier
void BlameClassifier(const UNICHARSET &unicharset, const TBOX &blob_box, const BLOB_CHOICE_LIST &choices, bool debug)
Definition: blamer.cpp:263
wordrec_blob_pause
bool wordrec_blob_pause
Definition: render.cpp:39
params.h
wordrec.h
tesseract::Classify::getDict
virtual Dict & getDict()
Definition: classify.h:107
display_blob
void display_blob(TBLOB *blob, C_COL color)
Definition: render.cpp:49
C_COL
C_COL
Definition: callcpp.h:26
tesseract
Definition: baseapi.h:65
callcpp.h
TBLOB::bounding_box
TBOX bounding_box() const
Definition: blobs.cpp:466
tesseract::Wordrec::wordrec_debug_blamer
bool wordrec_debug_blamer
Definition: wordrec.h:231
TBLOB
Definition: blobs.h:282
tesseract::Wordrec::call_matcher
BLOB_CHOICE_LIST * call_matcher(TBLOB *blob)
Definition: tface.cpp:154
tesseract::Wordrec::classify_blob
BLOB_CHOICE_LIST * classify_blob(TBLOB *blob, const char *string, C_COL color, BlamerBundle *blamer_bundle)
Definition: wordclass.cpp:52
print_ratings_list
void print_ratings_list(const char *msg, BLOB_CHOICE_LIST *ratings, const UNICHARSET &current_unicharset)
Definition: ratngs.cpp:835
BlamerBundle
Definition: blamer.h:103
blamer.h
window_wait
char window_wait(ScrollView *win)
Definition: callcpp.cpp:103
wordrec_display_all_blobs
bool wordrec_display_all_blobs
Definition: render.cpp:37
tesseract::Classify::classify_debug_level
int classify_debug_level
Definition: classify.h:430